Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F122124514
PadeTaylor.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
Tue, Jul 15, 22:53
Size
3 KB
Mime Type
text/x-python
Expires
Thu, Jul 17, 22:53 (2 d)
Engine
blob
Format
Raw Data
Handle
27437707
Attached To
R6746 RationalROMPy
PadeTaylor.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.taylor
import
ApproximantTaylorPade
as
Pade
testNo
=
2
verb
=
0
homog
=
True
#homog = False
if
testNo
==
1
:
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
)
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
:
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
,
homogeneize
=
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
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
,
homogeneize
=
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