Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F62993189
helmholtz_box_scattering_problem_engine.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
Fri, May 17, 00:22
Size
2 KB
Mime Type
text/x-python
Expires
Sun, May 19, 00:22 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17717423
Attached To
R6746 RationalROMPy
helmholtz_box_scattering_problem_engine.py
View Options
#!/usr/bin/python
# 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
import
fenics
as
fen
from
rrompy.hfengines.fenics.scattering_problem_engine
import
ScatteringProblemEngine
__all__
=
[
'HelmholtzBoxScatteringProblemEngine'
]
class
HelmholtzBoxScatteringProblemEngine
(
ScatteringProblemEngine
):
"""
Solver for scattering problem outside a box with parametric wavenumber.
- \Delta u - omega^2 * n^2 * u = 0 in \Omega
u = 0 on \Gamma_D
\partial_nu - i k u = 0 on \Gamma_R
with exact solution a transmitted plane wave.
"""
def
__init__
(
self
,
R
:
float
,
kappa
:
float
,
theta
:
float
,
n
:
int
):
super
()
.
__init__
(
self
)
import
mshr
scatterer
=
mshr
.
Polygon
([
fen
.
Point
(
-
1
,
-.
5
),
fen
.
Point
(
1
,
-.
5
),
fen
.
Point
(
1
,
.
5
),
fen
.
Point
(
.
8
,
.
5
),
fen
.
Point
(
.
8
,
-.
3
),
fen
.
Point
(
-.
8
,
-.
3
),
fen
.
Point
(
-.
8
,
.
5
),
fen
.
Point
(
-
1
,
.
5
),])
mesh
=
mshr
.
generate_mesh
(
mshr
.
Circle
(
fen
.
Point
(
0
,
0
),
R
)
-
scatterer
,
n
)
self
.
V
=
fen
.
FunctionSpace
(
mesh
,
"P"
,
3
)
self
.
DirichletBoundary
=
(
lambda
x
,
on_boundary
:
on_boundary
and
(
x
[
0
]
**
2
+
x
[
1
]
**
2
)
**.
5
<
.
95
*
R
)
self
.
RobinBoundary
=
(
lambda
x
,
on_boundary
:
on_boundary
and
(
x
[
0
]
**
2
+
x
[
1
]
**
2
)
**.
5
>
.
95
*
R
)
import
sympy
as
sp
x
,
y
=
sp
.
symbols
(
'x[0] x[1]'
,
real
=
True
)
phiex
=
kappa
*
(
x
*
np
.
cos
(
theta
)
+
y
*
np
.
sin
(
theta
))
u0ex
=
-
sp
.
exp
(
1.j
*
phiex
)
u0
=
[
sp
.
printing
.
ccode
(
sp
.
simplify
(
sp
.
re
(
u0ex
))),
sp
.
printing
.
ccode
(
sp
.
simplify
(
sp
.
im
(
u0ex
)))]
self
.
DirichletDatum
=
[
fen
.
Expression
(
x
,
degree
=
3
)
for
x
in
u0
]
Event Timeline
Log In to Comment