Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90727300
rational_interpolant.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, 05:36
Size
2 KB
Mime Type
text/x-python
Expires
Wed, Nov 6, 05:36 (2 d)
Engine
blob
Format
Raw Data
Handle
22125628
Attached To
R6746 RationalROMPy
rational_interpolant.py
View Options
# Copyright (C) 2018 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.distributed
import
RationalInterpolant
as
RI
from
rrompy.parameter.parameter_sampling
import
(
QuadratureSampler
as
QS
,
ManualSampler
as
MS
)
def
test_monomials
(
capsys
):
mu
=
1.5
solver
=
matrixFFT
()
params
=
{
"POD"
:
False
,
"M"
:
9
,
"N"
:
9
,
"S"
:
10
,
"robustTol"
:
1e-6
,
"interpRcond"
:
1e-3
,
"polybasis"
:
"MONOMIAL"
,
"sampler"
:
QS
([
1.5
,
6.5
],
"UNIFORM"
)}
approx
=
RI
(
solver
,
4.
,
params
,
verbosity
=
0
)
approx
.
setupApprox
()
out
,
err
=
capsys
.
readouterr
()
assert
((
"poorly conditioned.
\n
Reducing N from 9 to"
in
out
)
and
(
"eigenvalues below tolerance. Reducing N from"
in
out
))
assert
len
(
err
)
==
0
assert
np
.
isclose
(
approx
.
normErr
(
mu
),
.
00773727
,
rtol
=
1e-3
)
def
test_well_cond
():
mu
=
1.5
solver
=
matrixFFT
()
params
=
{
"POD"
:
True
,
"M"
:
9
,
"N"
:
9
,
"S"
:
10
,
"robustTol"
:
1e-14
,
"interpRcond"
:
1e-10
,
"polybasis"
:
"CHEBYSHEV"
,
"sampler"
:
QS
([
1.
,
7.
],
"CHEBYSHEV"
)}
approx
=
RI
(
solver
,
4.
,
params
,
verbosity
=
0
)
approx
.
setupApprox
()
for
mu
in
approx
.
mus
:
assert
np
.
isclose
(
approx
.
normErr
(
mu
),
0.
,
atol
=
1e-8
)
poles
=
approx
.
getPoles
()
for
lambda_
in
np
.
arange
(
1
,
8
):
assert
np
.
isclose
(
np
.
min
(
np
.
abs
(
poles
-
lambda_
)),
0.
,
atol
=
1e-4
)
def
test_hermite
():
mu
=
1.5
solver
=
matrixFFT
()
sampler0
=
QS
([
1.
,
7.
],
"CHEBYSHEV"
)
points
=
np
.
tile
(
sampler0
.
generatePoints
(
4
)[
0
],
3
)
params
=
{
"POD"
:
True
,
"M"
:
11
,
"N"
:
11
,
"S"
:
12
,
"polybasis"
:
"CHEBYSHEV"
,
"sampler"
:
MS
([
1.
,
7.
],
points
=
points
)}
approx
=
RI
(
solver
,
4.
,
params
,
verbosity
=
0
)
approx
.
setupApprox
()
for
mu
in
approx
.
mus
:
assert
np
.
isclose
(
approx
.
normErr
(
mu
),
0.
,
atol
=
1e-8
)
poles
=
approx
.
getPoles
()
for
lambda_
in
np
.
arange
(
1
,
8
):
assert
np
.
isclose
(
np
.
min
(
np
.
abs
(
poles
-
lambda_
)),
0.
,
atol
=
1e-4
)
#_multistorage
Event Timeline
Log In to Comment