Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F73609830
rb_centered.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
Tue, Jul 23, 03:23
Size
2 KB
Mime Type
text/x-python
Expires
Thu, Jul 25, 03:23 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
19234918
Attached To
R6746 RationalROMPy
rb_centered.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.centered
import
RBCentered
as
RBC
def
test_R
():
mu
=
1.5
mu0
=
2.
+
1.j
solver
=
matrixFFT
()
uh
=
solver
.
solve
(
mu
)
params
=
{
"POD"
:
True
,
"R"
:
5
,
"E"
:
10
}
approx
=
RBC
(
solver
,
mu0
,
params
,
verbosity
=
0
)
approx
.
setupApprox
()
uhP
=
approx
.
getApprox
(
mu
)
errP
=
approx
.
getErr
(
mu
)
errNP
=
approx
.
normErr
(
mu
)
assert
np
.
allclose
(
np
.
abs
(
errP
-
(
uhP
-
uh
)),
0.
,
rtol
=
1e-3
)
# assert np.isclose(errNP, 0.023691832, rtol = 1e-1)
poles
=
approx
.
getPoles
()
assert
np
.
isclose
(
np
.
min
(
np
.
abs
(
poles
-
2.
)),
0.
,
atol
=
1e-4
)
assert
np
.
isclose
(
np
.
min
(
np
.
abs
(
poles
-
1.
)),
0.
,
atol
=
1e-2
)
assert
np
.
isclose
(
np
.
min
(
np
.
abs
(
poles
-
3.
)),
0.
,
atol
=
1e-2
)
def
test_moments
():
mu0
=
2.
+
1.j
solver
=
matrixFFT
()
params
=
{
"POD"
:
True
,
"E"
:
10
}
approx
=
RBC
(
solver
,
mu0
,
params
,
verbosity
=
0
)
approx
.
setupApprox
()
assert
np
.
isclose
(
approx
.
normErr
(
mu0
),
0.
,
atol
=
1e-10
)
def
test_load_copy
(
capsys
):
mu
=
1.5
mu0
=
2.
+
1.j
solver
=
matrixFFT
()
params
=
{
"POD"
:
True
,
"E"
:
10
}
approx1
=
RBC
(
solver
,
mu0
,
params
,
verbosity
=
100
)
approx1
.
setupApprox
()
err1
=
approx1
.
normErr
(
mu
)
out
,
err
=
capsys
.
readouterr
()
assert
"Solving HF model for mu ="
in
out
assert
len
(
err
)
==
0
approx2
=
RBC
(
solver
,
mu0
,
params
,
verbosity
=
100
)
approx2
.
setApprox
(
approx1
.
trainedModel
)
approx2
.
setHF
(
mu
,
approx1
.
uHF
)
err2
=
approx2
.
normErr
(
mu
)
out
,
err
=
capsys
.
readouterr
()
assert
"Solving HF model for mu ="
not
in
out
assert
len
(
err
)
==
0
assert
np
.
isclose
(
err1
,
err2
,
rtol
=
1e-10
)
Event Timeline
Log In to Comment