Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F60861576
cookie_single_pod.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
Fri, May 3, 00:30
Size
4 KB
Mime Type
text/x-python
Expires
Sun, May 5, 00:30 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17431550
Attached To
R6746 RationalROMPy
cookie_single_pod.py
View Options
import
numpy
as
np
from
rrompy.hfengines.linear_problem.bidimensional
import
\
CookieEngineSingle
as
CES
from
rrompy.reduction_methods.standard
import
RationalInterpolant
as
RI
from
rrompy.reduction_methods.standard
import
ReducedBasis
as
RB
from
rrompy.parameter.parameter_sampling
import
(
QuadratureSampler
as
QS
,
QuadratureSamplerTotal
as
QST
,
ManualSampler
as
MS
,
RandomSampler
as
RS
)
verb
=
5
size
=
1
show_sample
=
True
show_norm
=
True
clip
=
-
1
#clip = .4
#clip = .6
Delta
=
-
10
MN
=
5
R
=
(
MN
+
2
)
*
(
MN
+
1
)
//
2
STensorized
=
(
MN
+
1
)
**
2
PODTol
=
1e-6
samples
=
"centered"
samples
=
"standard"
algo
=
"rational"
#algo = "RB"
sampling
=
"quadrature"
sampling
=
"quadrature_total"
sampling
=
"random"
if
samples
==
"standard"
:
radial
=
""
# radial = "_gaussian"
# radial = "_thinplate"
# radial = "_multiquadric"
rW0
=
1.
radialWeight
=
[
rW0
]
*
2
assert
Delta
<=
0
if
size
==
1
:
# below
mu0
=
[
20
**
.
5
,
1.
**
.
5
]
mutar
=
[
20.5
**
.
5
,
1.05
**
.
5
]
murange
=
[[
18.5
**
.
5
,
.
85
**
.
5
],
[
21.5
**
.
5
,
1.15
**
.
5
]]
aEff
=
1.
#25
bEff
=
1.
-
aEff
murangeEff
=
[[(
aEff
*
murange
[
0
][
0
]
**
2.
+
bEff
*
murange
[
1
][
0
]
**
2.
)
**
.
5
,
aEff
*
murange
[
0
][
1
]
+
bEff
*
murange
[
1
][
1
]],
[(
aEff
*
murange
[
1
][
0
]
**
2.
+
bEff
*
murange
[
0
][
0
]
**
2.
)
**
.
5
,
aEff
*
murange
[
1
][
1
]
+
bEff
*
murange
[
0
][
1
]]]
kappa
=
20.
**
.
5
theta
=
-
np
.
pi
/
6.
n
=
30
Rad
=
1.
L
=
np
.
pi
nX
=
2
nY
=
1
solver
=
CES
(
kappa
=
kappa
,
theta
=
theta
,
n
=
n
,
R
=
Rad
,
L
=
L
,
nX
=
nX
,
nY
=
nY
,
mu0
=
mu0
,
verbosity
=
verb
)
rescalingExp
=
[
2.
]
*
2
if
algo
==
"rational"
:
params
=
{
'N'
:
MN
,
'M'
:
MN
+
Delta
,
'S'
:
R
,
'POD'
:
True
}
if
samples
==
"standard"
:
params
[
'polybasis'
]
=
"CHEBYSHEV"
+
radial
# params['polybasis'] = "LEGENDRE" + radial
# params['polybasis'] = "MONOMIAL" + radial
params
[
'radialDirectionalWeights'
]
=
radialWeight
elif
samples
==
"centered"
:
params
[
'polybasis'
]
=
"MONOMIAL"
method
=
RI
else
:
#if algo == "RB":
params
=
{
'R'
:(
MN
+
2
+
Delta
)
*
(
MN
+
1
+
Delta
)
//
2
,
'S'
:
R
,
'POD'
:
True
,
'PODTolerance'
:
PODTol
}
method
=
RB
if
samples
==
"standard"
:
if
sampling
==
"quadrature"
:
params
[
'sampler'
]
=
QS
(
murange
,
"CHEBYSHEV"
,
scalingExp
=
rescalingExp
)
# params['sampler'] = QS(murange, "GAUSSLEGENDRE", scalingExp = rescalingExp)
# params['sampler'] = QS(murange, "UNIFORM", scalingExp = rescalingExp)
params
[
'S'
]
=
STensorized
elif
sampling
==
"quadrature_total"
:
params
[
'sampler'
]
=
QST
(
murange
,
"CHEBYSHEV"
,
scalingExp
=
rescalingExp
)
else
:
# if sampling == "random":
params
[
'sampler'
]
=
RS
(
murange
,
"HALTON"
,
scalingExp
=
rescalingExp
)
elif
samples
==
"centered"
:
params
[
'sampler'
]
=
MS
(
murange
,
points
=
[
mu0
],
scalingExp
=
rescalingExp
)
approx
=
method
(
solver
,
mu0
=
mu0
,
approxParameters
=
params
,
verbosity
=
verb
)
if
samples
==
"standard"
:
approx
.
samplingEngine
.
allowRepeatedSamples
=
False
approx
.
setupApprox
()
if
show_sample
:
L
=
mutar
[
1
]
approx
.
plotApprox
(
mutar
,
name
=
'u_app'
,
what
=
"REAL"
)
approx
.
plotHF
(
mutar
,
name
=
'u_HF'
,
what
=
"REAL"
)
approx
.
plotErr
(
mutar
,
name
=
'err'
,
what
=
"REAL"
)
# approx.plotRes(mutar, name = 'res', what = "REAL")
appErr
=
approx
.
normErr
(
mutar
)
solNorm
=
approx
.
normHF
(
mutar
)
resNorm
=
approx
.
normRes
(
mutar
)
RHSNorm
=
approx
.
normRHS
(
mutar
)
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"
and
approx
.
N
>
0
:
from
plot_zero_set
import
plotZeroSet2
muZeroVals
,
Qvals
=
plotZeroSet2
(
murange
,
murangeEff
,
approx
,
mu0
,
200
,
[
2.
,
2.
],
clip
=
clip
)
if
show_norm
:
solver
.
_solveBatchSize
=
100
from
plot_inf_set
import
plotInfSet2
muInfVals
,
normEx
,
normApp
,
normRes
,
normErr
,
beta
=
plotInfSet2
(
murange
,
murangeEff
,
approx
,
mu0
,
25
,
[
2.
,
2.
],
clip
=
clip
,
relative
=
False
)
Event Timeline
Log In to Comment