Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F85087596
funnel_output.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
Thu, Sep 26, 16:59
Size
2 KB
Mime Type
text/x-python
Expires
Sat, Sep 28, 16:59 (2 d)
Engine
blob
Format
Raw Data
Handle
21127325
Attached To
R6746 RationalROMPy
funnel_output.py
View Options
import
numpy
as
np
from
funnel_output_engine
import
FunnelOutputEngine
as
engine
from
rrompy.reduction_methods
import
(
NearestNeighbor
as
NN
,
RationalInterpolant
as
RI
,
RationalInterpolantGreedy
as
RIG
)
from
rrompy.parameter.parameter_sampling
import
(
QuadratureSampler
as
QS
,
EmptySampler
as
ES
)
ks
=
[
5.
,
10.
]
k0
,
n
=
np
.
mean
(
ks
),
50
solver
=
engine
(
k0
,
n
)
k
=
6.5
for
method
in
[
"RI"
,
"RI_GREEDY"
]:
print
(
"Testing {} method"
.
format
(
method
))
if
"GREEDY"
not
in
method
:
params
=
{
'S'
:
20
,
'POD'
:
True
,
'polybasis'
:
"CHEBYSHEV"
,
'sampler'
:
QS
(
ks
,
"CHEBYSHEV"
)}
algo
=
RI
if
"GREEDY"
in
method
:
params
=
{
'S'
:
2
,
'POD'
:
True
,
'polybasis'
:
"LEGENDRE"
,
'greedyTol'
:
1e-1
,
'maxIter'
:
25
,
'sampler'
:
QS
(
ks
,
"UNIFORM"
),
'errorEstimatorKind'
:
"LOOK_AHEAD_OUTPUT"
}
algo
=
RIG
approx
=
algo
(
solver
,
mu0
=
k0
,
approxParameters
=
params
,
verbosity
=
5
)
if
"GREEDY"
not
in
method
:
approx
.
setupApprox
()
else
:
approx
.
setupApprox
(
"LAST"
)
print
(
"--- Approximant ---"
)
approx
.
plotApprox
(
k
,
name
=
'u_app'
)
approx
.
plotHF
(
k
,
name
=
'u_HF'
)
approx
.
plotErr
(
k
,
name
=
'err_app'
)
err
=
approx
.
getErr
(
k
)[
0
]
sol
=
approx
.
getHF
(
k
)[
0
]
normErr
=
np
.
abs
(
solver
.
L2NormMatrix
.
dot
(
err
)
.
dot
(
err
.
conj
()))
**
.
5
normSol
=
np
.
abs
(
solver
.
L2NormMatrix
.
dot
(
sol
)
.
dot
(
sol
.
conj
()))
**
.
5
print
(
"SolNorm:
\t
{:.5e}
\n
Err_app:
\t
{:.5e}
\n
ErrRel_app:
\t
{:.5e}"
.
format
(
normSol
,
normErr
,
normErr
/
normSol
))
print
(
"--- Closest snapshot ---"
)
approxNN
=
NN
(
solver
,
mu0
=
k0
,
verbosity
=
0
,
approxParameters
=
{
'S'
:
approx
.
samplingEngine
.
nsamples
,
'POD'
:
True
,
'sampler'
:
ES
()})
approxNN
.
setSamples
(
approx
.
samplingEngine
)
approxNN
.
plotApprox
(
k
,
name
=
'u_close'
)
approxNN
.
plotHF
(
k
,
name
=
'u_HF'
)
approxNN
.
plotErr
(
k
,
name
=
'err_close'
)
err
=
approxNN
.
getErr
(
k
)[
0
]
sol
=
approxNN
.
getHF
(
k
)[
0
]
normErr
=
np
.
abs
(
solver
.
L2NormMatrix
.
dot
(
err
)
.
dot
(
err
.
conj
()))
**
.
5
normSol
=
np
.
abs
(
solver
.
L2NormMatrix
.
dot
(
sol
)
.
dot
(
sol
.
conj
()))
**
.
5
print
(
"SolNorm:
\t
{:.5e}
\n
Err_close:
\t
{:.5e}
\n
ErrRel_close:
\t
{:.5e}"
.
format
(
normSol
,
normErr
,
normErr
/
normSol
))
print
(
"Poles:
\n
{}"
.
format
(
approx
.
getPoles
()))
print
(
"
\n
"
)
Event Timeline
Log In to Comment