Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F73219089
HelmholtzLagrangeApproximantsSweep.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
Fri, Jul 19, 17:32
Size
3 KB
Mime Type
text/x-python
Expires
Sun, Jul 21, 17:32 (2 d)
Engine
blob
Format
Raw Data
Handle
19163328
Attached To
R6746 RationalROMPy
HelmholtzLagrangeApproximantsSweep.py
View Options
#!/usr/bin/env python3
import
numpy
as
np
from
context
import
FreeFemHelmholtzEngine
as
HFEngine
from
context
import
FreeFemHSEngine
as
HSEngine
from
context
import
ROMApproximantLagrangePade
as
Pade
from
context
import
ROMApproximantLagrangeRB
as
RB
from
context
import
ROMApproximantSweeper
as
Sweeper
npoints
=
31
ktars
=
np
.
linspace
(
0
,
21
,
npoints
)
from
FreeFem_snippets
import
SquareHomogeneousBubble
bd
,
V
,
f
=
SquareHomogeneousBubble
(
kappa
=
12
**.
5
,
theta
=
np
.
pi
/
3
,
n
=
10
)
solver
=
HFEngine
(
V
,
12
**.
5
,
forcingTerm
=
f
,
DirichletBoundary
=
"1,2,3,4"
)
plotter
=
HSEngine
(
solver
.
V
)
shift
=
3
nsets
=
3
stride
=
2
Smax
=
stride
*
(
nsets
-
1
)
+
shift
+
2
paramsPade
=
{
'S'
:
Smax
,
'polyBasis'
:
'CHEBYSHEV'
,
'POD'
:
True
}
paramsRB
=
{
'S'
:
Smax
,
'nodesType'
:
'CHEBYSHEV'
,
'POD'
:
True
}
paramsSetsPade
=
[
None
]
*
nsets
paramsSetsRB
=
[
None
]
*
nsets
for
i
in
range
(
nsets
):
paramsSetsPade
[
i
]
=
{
'N'
:
stride
*
i
+
shift
+
1
,
'M'
:
stride
*
i
+
shift
,
'S'
:
stride
*
i
+
shift
+
2
}
paramsSetsRB
[
i
]
=
{
'R'
:
stride
*
i
+
shift
+
1
,
'S'
:
stride
*
i
+
shift
+
2
}
appPade
=
Pade
(
solver
,
plotter
,
ks
=
[
4
+
.
5j
,
14
+
.
5j
],
approxParameters
=
paramsPade
)
appRB
=
RB
(
solver
,
plotter
,
ks
=
[
4
+
.
5j
,
14
+
.
5j
],
approxParameters
=
paramsRB
)
sweeper
=
Sweeper
.
ROMApproximantSweeper
(
ktars
=
ktars
,
mostExpensive
=
'Approx'
)
sweeper
.
ROMEngine
=
appPade
sweeper
.
params
=
paramsSetsPade
filenamePade
=
sweeper
.
sweep
(
'../Data/HelmholtzBubbleLagrangePadeFF.dat'
,
outputs
=
'ALL'
)
sweeper
.
ROMEngine
=
appRB
sweeper
.
params
=
paramsSetsRB
filenameRB
=
sweeper
.
sweep
(
'../Data/HelmholtzBubbleLagrangeRBFF.dat'
,
outputs
=
'ALL'
)
####################
from
matplotlib
import
pyplot
as
plt
for
i
in
range
(
nsets
):
nSamples
=
stride
*
i
+
shift
+
2
PadeOutput
=
sweeper
.
read
(
filenamePade
,
{
'S'
:
nSamples
},
[
'kRe'
,
'HFNorm'
,
'AppNorm'
,
'ErrNorm'
])
RBOutput
=
sweeper
.
read
(
filenameRB
,
{
'S'
:
nSamples
},
[
'kRe'
,
'AppNorm'
,
'ErrNorm'
])
ktarsF
=
PadeOutput
[
'kRe'
]
solNormF
=
PadeOutput
[
'HFNorm'
]
PadektarsF
=
PadeOutput
[
'kRe'
]
PadeNormF
=
PadeOutput
[
'AppNorm'
]
PadeErrorF
=
PadeOutput
[
'ErrNorm'
]
RBktarsF
=
RBOutput
[
'kRe'
]
RBNormF
=
RBOutput
[
'AppNorm'
]
RBErrorF
=
RBOutput
[
'ErrNorm'
]
plt
.
figure
()
plt
.
semilogy
(
ktarsF
,
solNormF
,
'k-'
,
label
=
'Sol norm'
)
plt
.
semilogy
(
PadektarsF
,
PadeNormF
,
'b.--'
,
label
=
'Pade'' norm, S = {}'
.
format
(
nSamples
))
plt
.
semilogy
(
RBktarsF
,
RBNormF
,
'g.--'
,
label
=
'RB norm, S = {}'
.
format
(
nSamples
))
plt
.
legend
()
plt
.
grid
()
plt
.
figure
()
plt
.
semilogy
(
PadektarsF
,
PadeErrorF
,
'b'
,
label
=
'Pade'' error, S = {}'
.
format
(
nSamples
))
plt
.
semilogy
(
RBktarsF
,
RBErrorF
,
'g'
,
label
=
'RB error, S = {}'
.
format
(
nSamples
))
plt
.
legend
()
plt
.
grid
()
plt
.
figure
()
plt
.
semilogy
(
ktarsF
,
PadeErrorF
/
solNormF
,
'b'
,
label
=
'Pade'' relative error, S = {}'
.
format
(
nSamples
))
plt
.
semilogy
(
RBktarsF
,
RBErrorF
/
solNormF
,
'g'
,
label
=
'RB relative error, S = {}'
.
format
(
nSamples
))
plt
.
legend
()
plt
.
grid
()
Event Timeline
Log In to Comment