Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F60244511
PadeOrthogonalLagrange.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
Sun, Apr 28, 14:33
Size
4 KB
Mime Type
text/x-python
Expires
Tue, Apr 30, 14:33 (2 d)
Engine
blob
Format
Raw Data
Handle
17324205
Attached To
R6746 RationalROMPy
PadeOrthogonalLagrange.py
View Options
import
numpy
as
np
from
rrompy.hfengines.scipy
import
HelmholtzSquareBubbleProblemEngine
as
HSBPE
from
rrompy.hfengines.scipy
import
HelmholtzSquareTransmissionProblemEngine
as
HSTPE
from
rrompy.hfengines.scipy
import
HelmholtzBoxScatteringProblemEngine
as
HBSPE
from
rrompy.reduction_methods.lagrange
import
ApproximantLagrangePadeOrthogonal
as
Pade
from
rrompy.utilities.parameter_sampling
import
QuadratureSampler
as
QS
testNo
=
2
verb
=
5
homog
=
True
#homog = False
if
testNo
==
1
:
k0s
=
np
.
power
([
10
+
0.j
,
14
+
0.j
],
.
5
)
k0
=
np
.
mean
(
k0s
)
ktar
=
(
11
+
0.j
)
**
.
5
rescaling
=
lambda
x
:
np
.
power
(
x
,
2.
)
rescalingInv
=
lambda
x
:
np
.
power
(
x
,
.
5
)
params
=
{
'N'
:
4
,
'M'
:
3
,
'S'
:
5
,
'POD'
:
True
,
'sampler'
:
QS
(
k0s
,
"CHEBYSHEV"
,
rescaling
,
rescalingInv
)}
solver
=
HSBPE
(
kappa
=
12
**
.
5
,
theta
=
np
.
pi
/
3
,
n
=
40
,
verbosity
=
verb
)
solver
.
omega
=
np
.
real
(
k0
)
approx
=
Pade
(
solver
,
mu0
=
k0
,
approxParameters
=
params
,
verbosity
=
verb
)
approx
.
setupApprox
()
# approx.plotSamples()
approx
.
plotApp
(
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
==
2
:
k0s
=
[
3.85
+
0.j
,
4.15
+
0.j
]
k0
=
np
.
mean
(
k0s
)
ktar
=
4
+
0.j
rescaling
=
lambda
x
:
np
.
power
(
x
,
2.
)
rescalingInv
=
lambda
x
:
np
.
power
(
x
,
.
5
)
params
=
{
'N'
:
8
,
'M'
:
9
,
'S'
:
10
,
'POD'
:
True
,
'sampler'
:
QS
(
k0s
,
"CHEBYSHEV"
,
rescaling
,
rescalingInv
)}
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
.
plotApp
(
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
==
3
:
k0s
=
[
2
,
5
]
k0
=
np
.
mean
(
k0s
)
ktar
=
4.5
-
.
1j
params
=
{
'N'
:
10
,
'M'
:
10
,
'S'
:
11
,
'POD'
:
True
,
'sampler'
:
QS
(
k0s
,
"CHEBYSHEV"
)}
solver
=
HBSPE
(
R
=
7
,
kappa
=
3
,
theta
=
-
np
.
pi
*
75
/
180
,
n
=
40
,
verbosity
=
verb
)
solver
.
omega
=
np
.
real
(
k0
)
approx
=
Pade
(
solver
,
mu0
=
k0
,
approxParameters
=
params
,
verbosity
=
verb
,
homogeneized
=
homog
)
approx
.
setupApprox
()
approx
.
plotSamples
()
approx
.
plotApp
(
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