Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F104854484
RationalPade.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
Wed, Mar 12, 22:12
Size
4 KB
Mime Type
text/x-python
Expires
Fri, Mar 14, 22:12 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24868210
Attached To
R6746 RationalROMPy
RationalPade.py
View Options
import
numpy
as
np
from
rrompy.hfengines.linear_problem
import
\
HelmholtzSquareBubbleProblemEngine
as
HSBPE
from
rrompy.hfengines.linear_problem
import
\
HelmholtzSquareTransmissionProblemEngine
as
HSTPE
from
rrompy.hfengines.linear_problem
import
\
HelmholtzBoxScatteringProblemEngine
as
HBSPE
from
rrompy.reduction_methods.centered
import
RationalPade
as
Pade
testNo
=
-
1
verb
=
100
homog
=
True
#homog = False
loadName
=
"RationalPadeModel.pkl"
if
testNo
in
[
1
,
-
1
]:
if
testNo
>
0
:
params
=
{
'N'
:
4
,
'M'
:
3
,
'E'
:
4
,
'sampleType'
:
'Arnoldi'
,
'POD'
:
True
}
k0
=
12
**
.
5
ktar
=
10.5
**
.
5
solver
=
HSBPE
(
kappa
=
12
**
.
5
,
theta
=
np
.
pi
/
3
,
n
=
40
,
verbosity
=
verb
)
if
testNo
>
0
:
approx
=
Pade
(
solver
,
mu0
=
k0
,
approxParameters
=
params
,
verbosity
=
verb
)
approx
.
setupApprox
()
# approx.plotSamples()
else
:
approx
=
Pade
(
solver
,
mu0
=
0
,
verbosity
=
verb
)
approx
.
loadTrainedModel
(
loadName
)
approx
.
plotApprox
(
ktar
,
name
=
'u_Pade'''
)
approx
.
plotHF
(
ktar
,
name
=
'u_HF'
)
approx
.
plotErr
(
ktar
,
name
=
'err'
)
approx
.
plotRes
(
ktar
,
name
=
'res'
)
appErr
,
solNorm
=
approx
.
normErr
(
ktar
),
approx
.
normHF
(
ktar
)
resNorm
,
RHSNorm
=
approx
.
normRes
(
ktar
),
approx
.
normRHS
(
ktar
)
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
)))
print
(
'
\n
Poles Pade'':'
)
print
(
approx
.
getPoles
())
if
testNo
>
0
:
approx
.
storeTrainedModel
(
"RationalPadeModel"
,
forceNewFile
=
False
)
print
(
approx
.
trainedModel
.
data
.
__dict__
)
############
elif
testNo
==
2
:
params
=
{
'N'
:
6
,
'M'
:
7
,
'E'
:
7
,
'sampleType'
:
'Arnoldi'
,
'POD'
:
True
}
k0
=
16
**
.
5
ktar
=
15
**
.
5
solver
=
HSTPE
(
nT
=
2
,
nB
=
1
,
theta
=
np
.
pi
*
45
/
180
,
kappa
=
4.
,
n
=
50
,
verbosity
=
verb
)
solver
.
omega
=
np
.
real
(
k0
)
approx
=
Pade
(
solver
,
mu0
=
k0
,
approxParameters
=
params
,
verbosity
=
verb
,
homogeneized
=
homog
)
approx
.
setupApprox
()
# approx.plotSamples()
approx
.
plotApprox
(
ktar
,
name
=
'u_Pade'''
)
approx
.
plotHF
(
ktar
,
name
=
'u_HF'
)
approx
.
plotErr
(
ktar
,
name
=
'err'
)
approx
.
plotRes
(
ktar
,
name
=
'res'
)
appErr
,
solNorm
=
approx
.
normErr
(
ktar
),
approx
.
normHF
(
ktar
)
resNorm
,
RHSNorm
=
approx
.
normRes
(
ktar
),
approx
.
normRHS
(
ktar
)
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
)))
print
(
'
\n
Poles Pade'':'
)
print
(
approx
.
getPoles
())
############
elif
testNo
in
[
3
,
4
]:
if
testNo
==
3
:
params
=
{
'N'
:
7
,
'M'
:
8
,
'E'
:
8
,
'sampleType'
:
'Krylov'
,
'POD'
:
True
}
else
:
params
=
{
'N'
:
7
,
'M'
:
8
,
'E'
:
8
,
'sampleType'
:
'Arnoldi'
,
'POD'
:
True
}
k0
=
3
ktar
=
4.
+
0.j
solver
=
HBSPE
(
R
=
5
,
kappa
=
3
,
theta
=
-
np
.
pi
*
75
/
180
,
n
=
30
,
verbosity
=
verb
)
solver
.
omega
=
np
.
real
(
k0
)
approx
=
Pade
(
solver
,
mu0
=
k0
,
approxParameters
=
params
,
verbosity
=
verb
,
homogeneized
=
homog
)
approx
.
setupApprox
()
approx
.
plotSamples
()
approx
.
plotApprox
(
ktar
,
name
=
'u_Pade'''
)
approx
.
plotHF
(
ktar
,
name
=
'u_HF'
)
approx
.
plotErr
(
ktar
,
name
=
'err'
)
approx
.
plotRes
(
ktar
,
name
=
'res'
)
appErr
,
solNorm
=
approx
.
normErr
(
ktar
),
approx
.
normHF
(
ktar
)
resNorm
,
RHSNorm
=
approx
.
normRes
(
ktar
),
approx
.
normRHS
(
ktar
)
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
)))
print
(
'
\n
Poles Pade'':'
)
print
(
approx
.
getPoles
())
Event Timeline
Log In to Comment