Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90344821
helmholtz_external.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
Thu, Oct 31, 18:28
Size
2 KB
Mime Type
text/x-python
Expires
Sat, Nov 2, 18:28 (2 d)
Engine
blob
Format
Raw Data
Handle
22058110
Attached To
R6746 RationalROMPy
helmholtz_external.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
pytest
import
numpy
as
np
from
rrompy.hfengines.linear_problem
import
(
HelmholtzCavityScatteringProblemEngine
,
HelmholtzBoxScatteringProblemEngine
)
def
test_helmholtz_square_scattering
():
solver
=
HelmholtzCavityScatteringProblemEngine
(
kappa
=
4
,
gamma
=
2.
,
n
=
20
,
verbosity
=
0
)
mu
=
5
uh
=
solver
.
solve
(
mu
)[
0
]
assert
np
.
isclose
(
solver
.
norm
(
uh
),
19.9362
,
rtol
=
1e-2
)
assert
np
.
isclose
(
solver
.
norm
(
solver
.
residual
(
uh
,
mu
)[
0
]),
4.25056407e-13
,
rtol
=
1e-1
)
def
test_helmholtz_scattering_copy
(
capsys
):
solver1
=
HelmholtzCavityScatteringProblemEngine
(
kappa
=
4
,
gamma
=
2.
,
n
=
20
,
verbosity
=
0
)
mu
=
5
uh1
=
solver1
.
solve
(
mu
)[
0
]
solver2
=
HelmholtzCavityScatteringProblemEngine
(
kappa
=
4
,
gamma
=
2.
,
n
=
20
,
verbosity
=
100
)
assert
solver1
.
As
[
0
]
is
not
None
and
solver1
.
bs
[
0
]
is
not
None
assert
solver2
.
As
[
0
]
is
None
and
solver2
.
bs
[
0
]
is
None
solver2
.
setAs
(
solver1
.
As
)
solver2
.
setbs
(
solver1
.
bs
)
uh2
=
solver2
.
solve
(
mu
)[
0
]
assert
np
.
allclose
(
uh1
,
uh2
,
rtol
=
1e-8
)
out
,
err
=
capsys
.
readouterr
()
assert
(
"Assembling operator term"
not
in
out
and
"Assembling forcing term"
not
in
out
)
assert
len
(
err
)
==
0
@pytest.mark.xfail
(
raises
=
RuntimeError
(
'Invalid DISPLAY variable'
),
reason
=
"no graphical interface"
)
def
test_helmholtz_box_scattering
():
solver
=
HelmholtzBoxScatteringProblemEngine
(
R
=
2
,
kappa
=
10.
,
theta
=
np
.
pi
*
30
/
180
,
n
=
20
,
verbosity
=
0
)
mu
=
15
uh
=
solver
.
solve
(
mu
)[
0
]
solver
.
plotmesh
(
show
=
False
,
figsize
=
(
7
,
7
))
assert
np
.
isclose
(
solver
.
norm
(
uh
),
62.113
,
rtol
=
1e-2
)
assert
np
.
isclose
(
solver
.
norm
(
solver
.
residual
(
uh
,
mu
)[
0
]),
9.62989935e-13
,
rtol
=
1e-1
)
from
matplotlib
import
pyplot
as
plt
plt
.
close
(
'all'
)
Event Timeline
Log In to Comment