Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F95673251
HelmholtzRBLagrangeApproximant.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, Dec 18, 06:15
Size
2 KB
Mime Type
text/x-python
Expires
Fri, Dec 20, 06:15 (2 d)
Engine
blob
Format
Raw Data
Handle
23038815
Attached To
R6746 RationalROMPy
HelmholtzRBLagrangeApproximant.py
View Options
import
numpy
as
np
from
rrompy.hfengines.fenics
import
HelmholtzSquareBubbleProblemEngine
as
HSBPE
from
rrompy.hfengines.fenics
import
HelmholtzSquareTransmissionProblemEngine
as
HSTPE
from
rrompy.hfengines.fenics
import
HelmholtzBoxScatteringProblemEngine
as
HBSPE
from
rrompy.hsengines.fenics
import
HSEngine
as
HS
from
rrompy.reduction_methods.lagrange
import
ApproximantLagrangeRB
as
RB
from
rrompy.sampling
import
QuadratureSampler
as
QS
testNo
=
3
if
testNo
==
1
:
z0s
=
[
10
+
0.j
,
14
+
0.j
]
z0
=
np
.
mean
(
z0s
)
ztar
=
11
+
.
5j
params
=
{
'S'
:
5
,
'R'
:
4
,
'POD'
:
True
,
'sampler'
:
QS
(
z0s
,
"CHEBYSHEV"
)}
solver
=
HSBPE
(
kappa
=
12
**
.
5
,
theta
=
np
.
pi
/
3
,
n
=
40
)
plotter
=
HS
(
solver
.
V
)
approx
=
RB
(
solver
,
plotter
,
mu0
=
z0
,
approxParameters
=
params
)
#,
# plotSnap = 'ALL')
approx
.
plotApp
(
ztar
,
name
=
'u_RB'
)
approx
.
plotHF
(
ztar
,
name
=
'u_HF'
)
approx
.
plotErr
(
ztar
,
name
=
'err'
)
appErr
,
solNorm
=
approx
.
approxError
(
ztar
),
approx
.
HFNorm
(
ztar
)
print
((
'SolNorm:
\t
{}
\n
Err:
\t
{}
\n
ErrRel:
\t
{}'
)
.
format
(
solNorm
,
appErr
,
np
.
divide
(
appErr
,
solNorm
)))
print
(
'
\n
Poles RB:'
)
print
(
approx
.
getPoles
())
############
elif
testNo
==
2
:
z0s
=
np
.
power
([
3.85
+
0.j
,
4.15
+
0.j
],
2.
)
z0
=
np
.
mean
(
z0s
)
ztar
=
(
4
+
.
15j
)
**
2.
params
=
{
'S'
:
10
,
'R'
:
9
,
'POD'
:
True
,
'sampler'
:
QS
(
z0s
,
"CHEBYSHEV"
)}
solver
=
HSTPE
(
nT
=
2
,
nB
=
1
,
theta
=
np
.
pi
*
45
/
180
,
kappa
=
4.
,
n
=
50
)
plotter
=
HS
(
solver
.
V
)
approx
=
RB
(
solver
,
plotter
,
mu0
=
z0
,
approxParameters
=
params
,
plotSnap
=
'ALL'
)
approx
.
plotApp
(
ztar
,
name
=
'u_RB'
)
approx
.
plotHF
(
ztar
,
name
=
'u_HF'
)
approx
.
plotErr
(
ztar
,
name
=
'err'
)
appErr
,
solNorm
=
approx
.
approxError
(
ztar
),
approx
.
HFNorm
(
ztar
)
print
((
'SolNorm:
\t
{}
\n
Err:
\t
{}
\n
ErrRel:
\t
{}'
)
.
format
(
solNorm
,
appErr
,
np
.
divide
(
appErr
,
solNorm
)))
print
(
'
\n
Poles RB:'
)
print
(
approx
.
getPoles
())
############
elif
testNo
==
3
:
k0s
=
[
2
,
5
]
k0
=
np
.
mean
(
k0s
)
ktar
=
4.5
-
.
2j
params
=
{
'S'
:
15
,
'R'
:
10
,
'POD'
:
True
,
'sampler'
:
QS
(
k0s
,
"CHEBYSHEV"
)}
solver
=
HBSPE
(
R
=
7
,
kappa
=
3
,
theta
=
-
np
.
pi
*
75
/
180
,
n
=
40
)
plotter
=
HS
(
solver
.
V
)
approx
=
RB
(
solver
,
plotter
,
mu0
=
k0
,
approxParameters
=
params
)
approx
.
plotApp
(
ktar
,
name
=
'u_RB'
)
approx
.
plotHF
(
ktar
,
name
=
'u_HF'
)
approx
.
plotErr
(
ktar
,
name
=
'err'
)
appErr
,
solNorm
=
approx
.
approxError
(
ktar
),
approx
.
HFNorm
(
ktar
)
print
((
'SolNorm:
\t
{}
\n
Err:
\t
{}
\n
ErrRel:
\t
{}'
)
.
format
(
solNorm
,
appErr
,
np
.
divide
(
appErr
,
solNorm
)))
print
(
'
\n
Poles RB:'
)
print
(
approx
.
getPoles
())
Event Timeline
Log In to Comment