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
3from .scenario import Scenario
4
5import os
6import sys
7from math import sqrt
8
9sys.path.insert(0, os.path.abspath("../equations"))
10from equations import Acoustic
11
12
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
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
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 )