Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F65524564
fracture_pod_nodomain.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Jun 4, 10:15
Size
6 KB
Mime Type
text/x-python
Expires
Thu, Jun 6, 10:15 (2 d)
Engine
blob
Format
Raw Data
Handle
18086976
Attached To
R6746 RationalROMPy
fracture_pod_nodomain.py
View Options
import
numpy
as
np
from
rrompy.hfengines.linear_problem
import
MembraneFractureEngineNoDomain
\
as
MFEND
from
rrompy.reduction_methods.centered
import
RationalPade
as
RP
from
rrompy.reduction_methods.distributed
import
RationalInterpolant
as
RI
from
rrompy.reduction_methods.centered
import
RBCentered
as
RBC
from
rrompy.reduction_methods.distributed
import
RBDistributed
as
RBD
from
rrompy.parameter.parameter_sampling
import
(
QuadratureSampler
as
QS
,
QuadratureSamplerTotal
as
QST
,
ManualSampler
as
MS
,
RandomSampler
as
RS
)
verb
=
5
size
=
3
show_sample
=
True
show_norm
=
True
ignore_forcing
=
True
ignore_forcing
=
False
clip
=
-
1
#clip = .4
#clip = .6
homogeneize
=
False
#homogeneize = True
M
=
5
N
=
6
R
=
max
(
M
,
N
)
+
1
S
=
R
samples
=
"centered"
samples
=
"centered_fake"
samples
=
"distributed"
algo
=
"rational"
#algo = "RB"
sampling
=
"quadrature"
sampling
=
"quadrature_total"
sampling
=
"random"
if
samples
==
"distributed"
:
radial
=
0
# radial = "gaussian"
# radial = "thinplate"
# radial = "multiquadric"
radialWeight
=
np
.
array
([
2.
])
if
size
==
1
:
# below
mu0Aug
=
[
40
**
.
5
,
.
4
]
mu0
=
mu0Aug
[
0
]
mutar
=
45
**
.
5
murange
=
[[
30
**
.
5
],
[
50
**
.
5
]]
elif
size
==
2
:
# top
mu0Aug
=
[
40
**
.
5
,
.
6
]
mu0
=
mu0Aug
[
0
]
mutar
=
45
**
.
5
murange
=
[[
30
**
.
5
],
[
50
**
.
5
]]
elif
size
==
3
:
# interesting
mu0Aug
=
[
40
**
.
5
,
.
5
]
mu0
=
mu0Aug
[
0
]
mutar
=
45
**
.
5
murange
=
[[
30
**
.
5
],
[
50
**
.
5
]]
elif
size
==
4
:
# wide_low
mu0Aug
=
[
40
**
.
5
,
.
2
]
mu0
=
mu0Aug
[
0
]
mutar
=
45
**
.
5
murange
=
[[
10
**
.
5
],
[
70
**
.
5
]]
elif
size
==
5
:
# wide_hi
mu0Aug
=
[
40
**
.
5
,
.
8
]
mu0
=
mu0Aug
[
0
]
mutar
=
45
**
.
5
murange
=
[[
10
**
.
5
],
[
70
**
.
5
]]
elif
size
==
6
:
# top_zoom
mu0Aug
=
[
50
**
.
5
,
.
8
]
mu0
=
mu0Aug
[
0
]
mutar
=
55
**
.
5
murange
=
[[
40
**
.
5
],
[
60
**
.
5
]]
aEff
=
1.
#25
bEff
=
1.
-
aEff
murangeEff
=
[[(
aEff
*
murange
[
0
][
0
]
**
2.
+
bEff
*
murange
[
1
][
0
]
**
2.
)
**
.
5
],
[(
aEff
*
murange
[
1
][
0
]
**
2.
+
bEff
*
murange
[
0
][
0
]
**
2.
)
**
.
5
]]
H
=
1.
L
=
.
75
delta
=
.
05
n
=
20
solver
=
MFEND
(
mu0
=
mu0Aug
,
H
=
H
,
L
=
L
,
delta
=
delta
,
n
=
n
,
verbosity
=
verb
)
rescaling
=
lambda
x
:
np
.
power
(
x
,
2.
)
rescalingInv
=
lambda
x
:
np
.
power
(
x
,
.
5
)
if
algo
==
"rational"
:
params
=
{
'N'
:
N
,
'M'
:
M
,
'S'
:
S
,
'POD'
:
True
}
if
samples
==
"distributed"
:
params
[
'polybasis'
]
=
"CHEBYSHEV"
# params['polybasis'] = "LEGENDRE"
# params['polybasis'] = "MONOMIAL"
params
[
'E'
]
=
max
(
M
,
N
)
params
[
'radialBasis'
]
=
radial
params
[
'radialBasisWeights'
]
=
radialWeight
method
=
RI
elif
samples
==
"centered_fake"
:
params
[
'polybasis'
]
=
"MONOMIAL"
params
[
'S'
]
=
R
method
=
RI
else
:
params
[
'S'
]
=
R
method
=
RP
else
:
#if algo == "RB":
params
=
{
'R'
:
R
,
'S'
:
S
,
'POD'
:
True
}
if
samples
==
"distributed"
:
method
=
RBD
elif
samples
==
"centered_fake"
:
params
[
'S'
]
=
R
method
=
RBD
else
:
params
[
'S'
]
=
R
method
=
RBC
if
samples
==
"distributed"
:
if
sampling
==
"quadrature"
:
params
[
'sampler'
]
=
QS
(
murange
,
"CHEBYSHEV"
,
scaling
=
rescaling
,
scalingInv
=
rescalingInv
)
# params['sampler'] = QS(murange, "GAUSSLEGENDRE", scaling = rescaling,
# scalingInv = rescalingInv)
# params['sampler'] = QS(murange, "UNIFORM", scaling = rescaling,
# scalingInv = rescalingInv)
params
[
'S'
]
=
[
max
(
j
,
M
+
1
,
N
+
1
)
for
j
in
params
[
'S'
]]
elif
sampling
==
"quadrature_total"
:
params
[
'sampler'
]
=
QST
(
murange
,
"CHEBYSHEV"
,
scaling
=
rescaling
,
scalingInv
=
rescalingInv
)
params
[
'S'
]
=
R
else
:
# if sampling == "random":
params
[
'sampler'
]
=
RS
(
murange
,
"HALTON"
,
scaling
=
rescaling
,
scalingInv
=
rescalingInv
)
params
[
'S'
]
=
R
elif
samples
==
"centered_fake"
:
params
[
'sampler'
]
=
MS
(
murange
,
points
=
[
mu0
],
scaling
=
rescaling
,
scalingInv
=
rescalingInv
)
approx
=
method
(
solver
,
mu0
=
mu0
,
approxParameters
=
params
,
verbosity
=
verb
,
homogeneized
=
homogeneize
)
if
samples
==
"distributed"
:
approx
.
samplingEngine
.
allowRepeatedSamples
=
False
approx
.
setupApprox
()
if
show_sample
:
import
ufl
import
fenics
as
fen
from
rrompy.solver.fenics
import
affine_warping
L
=
solver
.
lFrac
y
=
fen
.
SpatialCoordinate
(
solver
.
V
.
mesh
())[
1
]
warp1
,
warpI1
=
affine_warping
(
solver
.
V
.
mesh
(),
np
.
array
([[
1
,
0
],
[
0
,
2.
*
L
]]))
warp2
,
warpI2
=
affine_warping
(
solver
.
V
.
mesh
(),
np
.
array
([[
1
,
0
],
[
0
,
2.
-
2.
*
L
]]))
warp
=
ufl
.
conditional
(
ufl
.
ge
(
y
,
0.
),
warp1
,
warp2
)
warpI
=
ufl
.
conditional
(
ufl
.
ge
(
y
,
0.
),
warpI1
,
warpI2
)
approx
.
plotApprox
(
mutar
,
[
warp
,
warpI
],
name
=
'u_app'
,
homogeneized
=
False
,
what
=
"REAL"
)
approx
.
plotHF
(
mutar
,
[
warp
,
warpI
],
name
=
'u_HF'
,
homogeneized
=
False
,
what
=
"REAL"
)
approx
.
plotErr
(
mutar
,
[
warp
,
warpI
],
name
=
'err'
,
homogeneized
=
False
,
what
=
"REAL"
)
# approx.plotRes(mutar, [warp, warpI], name = 'res',
# homogeneized = False, what = "REAL")
appErr
=
approx
.
normErr
(
mutar
,
homogeneized
=
homogeneize
)
solNorm
=
approx
.
normHF
(
mutar
,
homogeneized
=
homogeneize
)
resNorm
=
approx
.
normRes
(
mutar
,
homogeneized
=
homogeneize
)
RHSNorm
=
approx
.
normRHS
(
mutar
,
homogeneized
=
homogeneize
)
print
((
'SolNorm:
\t
{}
\n
Err:
\t
{}
\n
ErrRel:
\t
{}'
)
.
format
(
solNorm
,
appErr
,
np
.
divide
(
appErr
,
solNorm
)))
print
((
'RHSNorm:
\t
{}
\n
Res:
\t
{}
\n
ResRel:
\t
{}'
)
.
format
(
RHSNorm
,
resNorm
,
np
.
divide
(
resNorm
,
RHSNorm
)))
if
algo
==
"rational"
:
from
plot_zero_set
import
plotZeroSet1
muZeroVals
,
Qvals
=
plotZeroSet1
(
murange
,
murangeEff
,
approx
,
mu0
,
1000
,
2.
)
if
show_norm
:
solver
.
_solveBatchSize
=
10
from
plot_inf_set
import
plotInfSet1
muInfVals
,
normEx
,
normApp
,
normRes
,
normErr
,
beta
=
plotInfSet1
(
murange
,
murangeEff
,
approx
,
mu0
,
200
,
2.
)
Event Timeline
Log In to Comment