Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90784623
square_pod_hermite.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
Mon, Nov 4, 17:48
Size
3 KB
Mime Type
text/x-python
Expires
Wed, Nov 6, 17:48 (2 d)
Engine
blob
Format
Raw Data
Handle
22134338
Attached To
R6746 RationalROMPy
square_pod_hermite.py
View Options
import
numpy
as
np
from
rrompy.hfengines.linear_problem.bidimensional
import
\
HelmholtzSquareDomainProblemEngine
as
HSDPE
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
,
RandomSampler
as
RS
,
ManualSampler
as
MS
)
verb
=
0
size
=
1
show_sample
=
False
show_norm
=
True
MN
=
4
R
=
(
MN
+
2
)
*
(
MN
+
1
)
//
2
MN0
=
2
R0
=
(
MN0
+
2
)
*
(
MN0
+
1
)
//
2
S0Tensorized
=
(
MN0
+
1
)
**
2
algo
=
"rational"
#algo = "RB"
sampling
=
"quadrature"
sampling
=
"random"
if
size
==
1
:
# small
mu0
=
[
4
**
.
5
,
1.5
**
.
5
]
mutar
=
[
5
**
.
5
,
1.75
**
.
5
]
murange
=
[[
2
**
.
5
,
1.
**
.
5
],
[
6
**
.
5
,
2.
**
.
5
]]
elif
size
==
2
:
# medium
mu0
=
[
4
**
.
5
,
1.75
**
.
5
]
mutar
=
[
4.5
**
.
5
,
1.25
**
.
5
]
murange
=
[[
1
**
.
5
,
1.
**
.
5
],
[
7
**
.
5
,
2.5
**
.
5
]]
elif
size
==
3
:
# large
mu0
=
[
6
**
.
5
,
4
**
.
5
]
mutar
=
[
2
**
.
5
,
2.5
**
.
5
]
murange
=
[[
0
**
.
5
,
2
**
.
5
],
[
12
**
.
5
,
6
**
.
5
]]
elif
size
==
4
:
# crowded
mu0
=
[
10
**
.
5
,
2
**
.
5
]
mutar
=
[
9
**
.
5
,
2.25
**
.
5
]
murange
=
[[
8
**
.
5
,
1.5
**
.
5
],
[
12
**
.
5
,
2.5
**
.
5
]]
aEff
=
1.25
bEff
=
1.
-
aEff
murangeEff
=
[[(
aEff
*
murange
[
0
][
0
]
**
2.
+
bEff
*
murange
[
1
][
0
]
**
2.
)
**
.
5
,
(
aEff
*
murange
[
0
][
1
]
**
2.
+
bEff
*
murange
[
1
][
1
]
**
2.
)
**
.
5
],
[(
aEff
*
murange
[
1
][
0
]
**
2.
+
bEff
*
murange
[
0
][
0
]
**
2.
)
**
.
5
,
(
aEff
*
murange
[
1
][
1
]
**
2.
+
bEff
*
murange
[
0
][
1
]
**
2.
)
**
.
5
]]
solver
=
HSDPE
(
kappa
=
2.5
,
theta
=
np
.
pi
/
3
,
mu0
=
mu0
,
n
=
20
,
verbosity
=
verb
)
rescalingExp
=
[
2.
,
1.
]
if
algo
==
"rational"
:
params
=
{
'N'
:
MN
,
'M'
:
MN
,
'S'
:
R
,
'POD'
:
True
}
params
[
'polybasis'
]
=
"CHEBYSHEV"
method
=
RI
else
:
#if algo == "RB":
params
=
{
'R'
:
R
,
'S'
:
R
,
'POD'
:
True
}
method
=
RB
if
sampling
==
"quadrature"
:
sampler0
=
QS
(
murange
,
"CHEBYSHEV"
,
scalingExp
=
rescalingExp
)
S0
=
S0Tensorized
else
:
# if sampling == "random":
sampler0
=
RS
(
murange
,
"SOBOL"
,
scalingExp
=
rescalingExp
)
S0
=
R0
params
[
'sampler'
]
=
MS
(
murange
,
points
=
sampler0
.
generatePoints
(
S0
))
approx
=
method
(
solver
,
mu0
=
mu0
,
approxParameters
=
params
,
verbosity
=
verb
)
approx
.
setupApprox
()
if
show_sample
:
approx
.
plotApprox
(
mutar
,
name
=
'u_app'
)
approx
.
plotHF
(
mutar
,
name
=
'u_HF'
)
approx
.
plotErr
(
mutar
,
name
=
'err'
)
approx
.
plotRes
(
mutar
,
name
=
'res'
)
appErr
,
solNorm
=
approx
.
normErr
(
mutar
),
approx
.
normHF
(
mutar
)
resNorm
,
RHSNorm
=
approx
.
normRes
(
mutar
),
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"
:
from
plot_zero_set
import
plotZeroSet2
muZeroVals
,
Qvals
=
plotZeroSet2
(
murange
,
murangeEff
,
approx
,
mu0
,
200
,
[
2.
,
2.
])
if
show_norm
:
from
plot_inf_set
import
plotInfSet2
muInfVals
,
normEx
,
normApp
,
normRes
,
normErr
,
beta
=
plotInfSet2
(
murange
,
murangeEff
,
approx
,
mu0
,
25
,
[
2.
,
2.
])
Event Timeline
Log In to Comment