Peano
Loading...
Searching...
No Matches
acoustic_planar_waves.py
Go to the documentation of this file.
1
# This file is part of the ExaHyPE2 project. For conditions of distribution and
2
# use, please see the copyright notice at www.peano-framework.org
3
from
.scenario
import
Scenario
4
5
import
os
6
import
sys
7
from
math
import
sqrt
8
9
sys.path.insert(0, os.path.abspath(
"../equations"
))
10
from
equations
import
Acoustic
11
12
13
class
AcousticPlanarWaves
(
Scenario
):
14
_plot_dt = 0.0
15
_offset = -1.0
16
_domain_size = 2.0
17
_periodic_bc =
True
18
19
def
__init__
(self, dimensions, iterations=2):
20
self.
_dimensions
_dimensions
= dimensions
21
self.
_end_time
_end_time
= iterations * sqrt(dimensions)
22
self.
_K0
= 4.0
23
self.
_rho
= 1.0
24
self.
_equation
_equation
=
Acoustic
(dimensions, rho=self.
_rho
, K0=self.
_K0
)
25
26
def
initial_conditions
(self):
27
return
(
28
"""
29
// simple translation in positive diagonal direction
30
const double val = cos( - std::numbers::pi*(
31
x[0] + x[1]
32
#if Dimensions==3
33
+ x[2]
34
#endif
35
));
36
37
Q[1] = val;
38
Q[2] = val;
39
#if Dimensions==3
40
Q[3] = val;
41
#endif
42
43
constexpr double K0 = """
44
+ str(self.
_K0
)
45
+
""";
46
constexpr double rho = """
47
+ str(self.
_rho
)
48
+
""";
49
50
// These are defined by the eigenvector of the plane wave operator
51
#if Dimensions==3
52
const double kr = K0*std::sqrt(rho/(3.0*K0)) + 2*std::sqrt(K0*rho/3.0);
53
#else
54
const double kr = std::sqrt(2*K0*rho);
55
#endif
56
57
Q[0] = kr*val;
58
"""
59
)
60
61
def
analytical_solution
(self):
62
return
(
63
"""
64
const double w = 2*std::sqrt(Dimensions)*M_PI;
65
66
const double val = cos( w*t - std::numbers::pi*(
67
x[0] + x[1]
68
#if Dimensions==3
69
+ x[2]
70
#endif
71
));
72
73
solution[1] = val;
74
solution[2] = val;
75
76
constexpr double K0 = """
77
+ str(self.
_K0
)
78
+
""";
79
constexpr double rho = """
80
+ str(self.
_rho
)
81
+
""";
82
83
#if Dimensions==3
84
solution[3] = val;
85
const double kr = K0*std::sqrt(rho/(3.0*K0)) + 2*std::sqrt(K0*rho/3.0);
86
#else
87
const double kr = std::sqrt(2*K0*rho);
88
#endif
89
90
solution[0] = kr*val;
91
"""
92
)
acoustic.Acoustic
Definition
acoustic.py:9
scenarios.acoustic_planar_waves.AcousticPlanarWaves
Definition
acoustic_planar_waves.py:13
scenarios.acoustic_planar_waves.AcousticPlanarWaves._equation
_equation
Definition
acoustic_planar_waves.py:24
scenarios.acoustic_planar_waves.AcousticPlanarWaves._dimensions
_dimensions
Definition
acoustic_planar_waves.py:20
scenarios.acoustic_planar_waves.AcousticPlanarWaves.initial_conditions
initial_conditions(self)
Definition
acoustic_planar_waves.py:26
scenarios.acoustic_planar_waves.AcousticPlanarWaves._rho
_rho
Definition
acoustic_planar_waves.py:23
scenarios.acoustic_planar_waves.AcousticPlanarWaves._K0
_K0
Definition
acoustic_planar_waves.py:22
scenarios.acoustic_planar_waves.AcousticPlanarWaves._end_time
_end_time
Definition
acoustic_planar_waves.py:21
scenarios.acoustic_planar_waves.AcousticPlanarWaves.__init__
__init__(self, dimensions, iterations=2)
Definition
acoustic_planar_waves.py:19
scenarios.acoustic_planar_waves.AcousticPlanarWaves.analytical_solution
analytical_solution(self)
Definition
acoustic_planar_waves.py:61
scenarios.scenario.Scenario
Definition
scenario.py:6
scenarios.scenario.Scenario._end_time
float _end_time
Definition
scenario.py:9
scenarios.scenario.Scenario._equation
_equation
Definition
scenario.py:7
scenarios.scenario.Scenario._dimensions
int _dimensions
Definition
scenario.py:8
tests
exahype2
aderdg
scenarios
acoustic_planar_waves.py
Generated on Tue Mar 18 2025 20:03:33 for Peano by
1.10.0