Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F60261042
rational_interpolant_2d.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, 17:42
Size
2 KB
Mime Type
text/x-python
Expires
Tue, Apr 30, 17:42 (2 d)
Engine
blob
Format
Raw Data
Handle
17286036
Attached To
R6746 RationalROMPy
rational_interpolant_2d.py
View Options
# Copyright (C) 2018-2020 by the RROMPy authors
#
# This file is part of RROMPy.
#
# RROMPy is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RROMPy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with RROMPy. If not, see <http://www.gnu.org/licenses/>.
#
import
numpy
as
np
from
matrix_random
import
matrixRandom
from
rrompy.reduction_methods
import
RationalInterpolant
as
RI
from
rrompy.parameter.parameter_sampling
import
(
QuadratureSampler
as
QS
,
ManualSampler
as
MS
)
def
test_monomials
(
capsys
):
mu
=
[
5.05
,
7.1
]
mu0
=
[
5.
,
7.
]
solver
=
matrixRandom
()
uh
=
solver
.
solve
(
mu
)[
0
]
params
=
{
"POD"
:
False
,
"S"
:
16
,
"QTol"
:
1e-6
,
"interpTol"
:
1e-3
,
"polybasis"
:
"MONOMIAL"
,
"sampler"
:
QS
([[
4.9
,
6.85
],
[
5.1
,
7.15
]],
"UNIFORM"
)}
approx
=
RI
(
solver
,
mu0
,
params
,
verbosity
=
100
)
approx
.
setupApprox
()
uhP1
=
approx
.
getApprox
(
mu
)[
0
]
errP
=
approx
.
getErr
(
mu
)[
0
]
errNP
=
approx
.
normErr
(
mu
)[
0
]
myerrP
=
uhP1
-
uh
assert
np
.
allclose
(
np
.
abs
(
errP
-
myerrP
),
0.
,
rtol
=
1e-3
)
assert
np
.
isclose
(
solver
.
norm
(
errP
),
errNP
,
rtol
=
1e-3
)
resP
=
approx
.
getRes
(
mu
)[
0
]
resNP
=
approx
.
normRes
(
mu
)
assert
np
.
isclose
(
solver
.
norm
(
resP
),
resNP
,
rtol
=
1e-3
)
assert
np
.
allclose
(
np
.
abs
(
resP
-
(
solver
.
b
(
mu
)
-
solver
.
A
(
mu
)
.
dot
(
uhP1
))),
0.
,
rtol
=
1e-3
)
assert
np
.
isclose
(
errNP
/
solver
.
norm
(
uh
),
5.2667e-05
,
rtol
=
1
)
out
,
err
=
capsys
.
readouterr
()
assert
(
"poorly conditioned. Reducing N "
in
out
)
assert
len
(
err
)
==
0
def
test_well_cond
():
mu
=
[
5.05
,
7.1
]
mu0
=
[
5.
,
7.
]
solver
=
matrixRandom
()
params
=
{
"POD"
:
True
,
"M"
:
3
,
"N"
:
3
,
"S"
:
16
,
"interpTol"
:
1e-10
,
"polybasis"
:
"CHEBYSHEV"
,
"sampler"
:
QS
([[
4.9
,
6.85
],
[
5.1
,
7.15
]],
"UNIFORM"
)}
approx
=
RI
(
solver
,
mu0
,
params
,
verbosity
=
0
)
approx
.
setupApprox
()
assert
np
.
isclose
(
approx
.
normErr
(
mu
)[
0
]
/
approx
.
normHF
(
mu
)[
0
],
5.98695e-05
,
rtol
=
1e-1
)
def
test_hermite
():
mu
=
[
5.05
,
7.1
]
mu0
=
[
5.
,
7.
]
solver
=
matrixRandom
()
sampler0
=
QS
([[
4.9
,
6.85
],
[
5.1
,
7.15
]],
"UNIFORM"
)
params
=
{
"POD"
:
True
,
"M"
:
3
,
"N"
:
3
,
"S"
:
25
,
"polybasis"
:
"CHEBYSHEV"
,
"sampler"
:
MS
([[
4.9
,
6.85
],
[
5.1
,
7.15
]],
points
=
sampler0
.
generatePoints
(
9
))}
approx
=
RI
(
solver
,
mu0
,
params
,
verbosity
=
0
)
approx
.
setupApprox
()
assert
np
.
isclose
(
approx
.
normErr
(
mu
)[
0
]
/
approx
.
normHF
(
mu
)[
0
],
5.50053e-05
,
rtol
=
5e-1
)
Event Timeline
Log In to Comment