Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90800650
rational_interpolant_1d.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
Mon, Nov 4, 21:28
Size
2 KB
Mime Type
text/x-python
Expires
Wed, Nov 6, 21:28 (2 d)
Engine
blob
Format
Raw Data
Handle
22122499
Attached To
R6746 RationalROMPy
rational_interpolant_1d.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_fft
import
matrixFFT
from
rrompy.reduction_methods
import
RationalInterpolant
as
RI
from
rrompy.parameter.parameter_sampling
import
(
QuadratureSampler
as
QS
,
ManualSampler
as
MS
)
from
rrompy.parameter
import
checkParameterList
def
test_monomials
(
capsys
):
mu
=
1.5
solver
=
matrixFFT
()
params
=
{
"POD"
:
False
,
"S"
:
10
,
"QTol"
:
1e-6
,
"interpTol"
:
1e-3
,
"polybasis"
:
"MONOMIAL"
,
"sampler"
:
QS
([
1.5
,
6.5
],
"UNIFORM"
)}
approx
=
RI
(
solver
,
4.
,
approxParameters
=
params
,
verbosity
=
10
)
approx
.
setupApprox
()
out
,
err
=
capsys
.
readouterr
()
assert
"below tolerance. Reducing N"
in
out
assert
"poorly conditioned. Reducing M "
in
out
assert
len
(
err
)
==
0
assert
np
.
isclose
(
approx
.
normErr
(
mu
)[
0
],
2.8e-4
,
atol
=
1e-2
)
def
test_well_cond
():
mu
=
1.5
solver
=
matrixFFT
()
params
=
{
"POD"
:
True
,
"S"
:
10
,
"QTol"
:
1e-14
,
"interpTol"
:
1e-10
,
"polybasis"
:
"CHEBYSHEV"
,
"sampler"
:
QS
([
1.
,
7.
],
"CHEBYSHEV"
)}
approx
=
RI
(
solver
,
4.
,
approxParameters
=
params
,
verbosity
=
0
)
approx
.
setupApprox
()
poles
=
approx
.
getPoles
()
for
lambda_
in
np
.
arange
(
1
,
8
):
assert
np
.
isclose
(
np
.
min
(
np
.
abs
(
poles
-
lambda_
)),
0.
,
atol
=
1e-4
)
for
mu
in
approx
.
mus
:
assert
np
.
isclose
(
approx
.
normErr
(
mu
)[
0
],
0.
,
atol
=
1e-8
)
def
test_hermite
():
mu
=
1.5
solver
=
matrixFFT
()
sampler0
=
QS
([
1.
,
7.
],
"CHEBYSHEV"
)
points
=
checkParameterList
(
np
.
tile
(
sampler0
.
generatePoints
(
4
)(
0
),
3
))
params
=
{
"POD"
:
True
,
"S"
:
12
,
"polybasis"
:
"CHEBYSHEV"
,
"sampler"
:
MS
([
1.
,
7.
],
points
=
points
)}
approx
=
RI
(
solver
,
4.
,
approxParameters
=
params
,
verbosity
=
0
)
approx
.
setupApprox
()
poles
=
approx
.
getPoles
()
for
lambda_
in
np
.
arange
(
1
,
8
):
assert
np
.
isclose
(
np
.
min
(
np
.
abs
(
poles
-
lambda_
)),
0.
,
atol
=
1e-4
)
for
mu
in
approx
.
mus
:
assert
np
.
isclose
(
approx
.
normErr
(
mu
)[
0
],
0.
,
atol
=
1e-8
)
Event Timeline
Log In to Comment