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
"""
15
Scenario reproduced from Dumbser & Käser, https://doi.org/10.1111/j.1365-246X.2006.03120.x (Chapter 5, p. 328)
16
"""
17
18
_plot_dt = 0.0
19
_offset = -1.0
20
_domain_size = 2.0
21
_periodic_bc =
True
22
23
def
__init__
(self, dimensions, iterations=2):
24
self.
_dimensions
_dimensions
= dimensions
25
self.
_end_time
_end_time
= iterations * sqrt(dimensions)
26
self.
_K0
= 4.0
27
self.
_rho
= 1.0
28
self.
_equation
_equation
=
Acoustic
(dimensions, rho=self.
_rho
, K0=self.
_K0
)
29
30
def
initial_conditions
(self):
31
return
(
32
"""
33
// simple translation in positive diagonal direction
34
const double val = cos( - std::numbers::pi*(
35
x[0] + x[1]
36
#if DIMENSIONS==3
37
+ x[2]
38
#endif
39
));
40
41
Q[1] = val;
42
Q[2] = val;
43
#if DIMENSIONS==3
44
Q[3] = val;
45
#endif
46
47
constexpr double K0 = """
48
+ str(self.
_K0
)
49
+
""";
50
constexpr double rho = """
51
+ str(self.
_rho
)
52
+
""";
53
54
// These are defined by the eigenvector of the plane wave operator
55
#if DIMENSIONS==3
56
const double kr = K0*std::sqrt(rho/(3.0*K0)) + 2*std::sqrt(K0*rho/3.0);
57
#else
58
const double kr = std::sqrt(2*K0*rho);
59
#endif
60
61
Q[0] = kr*val;
62
"""
63
)
64
65
def
analytical_solution
(self):
66
return
(
67
"""
68
const double w = 2*std::sqrt(DIMENSIONS)*M_PI;
69
70
const double val = cos( w*t - std::numbers::pi*(
71
x[0] + x[1]
72
#if DIMENSIONS==3
73
+ x[2]
74
#endif
75
));
76
77
solution[1] = val;
78
solution[2] = val;
79
80
constexpr double K0 = """
81
+ str(self.
_K0
)
82
+
""";
83
constexpr double rho = """
84
+ str(self.
_rho
)
85
+
""";
86
87
#if DIMENSIONS==3
88
solution[3] = val;
89
const double kr = K0*std::sqrt(rho/(3.0*K0)) + 2*std::sqrt(K0*rho/3.0);
90
#else
91
const double kr = std::sqrt(2*K0*rho);
92
#endif
93
94
solution[0] = kr*val;
95
"""
96
)
equations.acoustic.Acoustic
Definition
acoustic.py:6
scenarios.acoustic_planar_waves.AcousticPlanarWaves
Scenario reproduced from Dumbser & Käser, https://doi.org/10.1111/j.1365-246X.2006....
Definition
acoustic_planar_waves.py:13
scenarios.acoustic_planar_waves.AcousticPlanarWaves._equation
_equation
Definition
acoustic_planar_waves.py:28
scenarios.acoustic_planar_waves.AcousticPlanarWaves._dimensions
_dimensions
Definition
acoustic_planar_waves.py:24
scenarios.acoustic_planar_waves.AcousticPlanarWaves.initial_conditions
initial_conditions(self)
Definition
acoustic_planar_waves.py:30
scenarios.acoustic_planar_waves.AcousticPlanarWaves._rho
_rho
Definition
acoustic_planar_waves.py:27
scenarios.acoustic_planar_waves.AcousticPlanarWaves._K0
_K0
Definition
acoustic_planar_waves.py:26
scenarios.acoustic_planar_waves.AcousticPlanarWaves._end_time
_end_time
Definition
acoustic_planar_waves.py:25
scenarios.acoustic_planar_waves.AcousticPlanarWaves.__init__
__init__(self, dimensions, iterations=2)
Definition
acoustic_planar_waves.py:23
scenarios.acoustic_planar_waves.AcousticPlanarWaves.analytical_solution
analytical_solution(self)
Definition
acoustic_planar_waves.py:65
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
aderdg
scenarios
acoustic_planar_waves.py
Generated on Wed Apr 1 2026 00:01:45 for Peano by
1.10.0