3from .scenario
import Scenario
8sys.path.insert(0, os.path.abspath(
"../equations"))
9from equations
import NavierStokes
14 Scenarios described in doi.org/10.1007/978-3-030-43229-4_27
16 Simulation of cloud formations via the compressible Navier-Stokes equations.
17 See the function 'mapQuantities' below for a note on the visualisation.
29 cv = 1 / (1.4 - 1) * 287.058
33 use_background_state=
True,
39 reference_viscosity=0.01,
43 _reference_pressure = 100000.0
44 _background_potential_temperature = 300.0
50 raise NotImplementedError(
"perturbation should be defined in child classes")
54 const auto pressure = std::pow(
56 (std::pow(std::pow(gamma, gamma / (gamma - 1)) *
58 (gamma - 1) / gamma) /
60 gravity * std::pow(referencePressure, gasConstant / cp) * x[DIMENSIONS-1] /
61 (gasConstant * backgroundPotentialTemperature)),
70 constexpr auto gamma = 1.4;
71 constexpr auto gasConstant = 287.058;
72 constexpr auto cp = gamma / (gamma - 1) * gasConstant;
73 constexpr auto referencePressure = """
76 constexpr auto backgroundPotentialTemperature = """
79 constexpr auto gravity = 9.81;
80 constexpr auto q0 = 0.0;
86 auto potentialT = backgroundPotentialTemperature;
87 potentialT += perturbation;
89 std::fill_n(Q, NumberOfUnknowns+NumberOfAuxiliaryVariables, 0.0);
91 // First compute overall state """
94 const auto temperature = potentialT *
95 std::pow((pressure / referencePressure), gasConstant / cp
98 auto rho = pressure / (gasConstant * temperature);
99 auto height = x[DIMENSIONS-1];
100 Q[Shortcuts::rho] = rho;
101 Q[Shortcuts::height] = height;
103 auto j = &Q[Shortcuts::j];
104 auto Z = perturbation;
111 // Then compute background state (without pot.T. perturbation)
112 const auto backgroundTemperature = backgroundPotentialTemperature *
113 std::pow((pressure / referencePressure), gasConstant / cp
115 const auto backgroundRho = pressure / (gasConstant * backgroundTemperature);
116 Q[Shortcuts::backgroundstate+0] = backgroundRho;
117 Q[Shortcuts::backgroundstate+1] = pressure;
124 constexpr auto gamma = 1.4;
125 constexpr auto gasConstant = 287.058;
126 constexpr auto cp = gamma / (gamma - 1) * gasConstant;
127 constexpr auto referencePressure = """
130 constexpr auto backgroundPotentialTemperature = """
133 constexpr auto gravity = 9.81;
134 constexpr auto q0 = 0.0;
136 std::copy_n(Qinside, NumberOfUnknowns+NumberOfAuxiliaryVariables, Qoutside);
138 // Normal velocity zero after Riemann.
139 Qoutside[Shortcuts::j+normal] = -Qinside[Shortcuts::j+normal];
141 // First compute overall state """
144 const auto T = backgroundPotentialTemperature *
145 std::pow((pressure / referencePressure), gasConstant / cp);
147 auto rho = pressure / (gasConstant * T);
148 auto height = Qoutside[Shortcuts::height];
149 auto j = &Qoutside[Shortcuts::j];
151 Qoutside[Shortcuts::rho] = rho;
152 Qoutside[Shortcuts::backgroundstate+0] = Qoutside[Shortcuts::rho];
153 Qoutside[Shortcuts::backgroundstate+1] = pressure;
159 Qoutside[Shortcuts::E] = E;
171void tests::exahype2::aderdg::ADERDGSolver::mapQuantities(
172 [[maybe_unused]] const double* const NOALIAS Q, // Q[4+3]
173 [[maybe_unused]] double* const NOALIAS outputQuantities // Q[4+3]
175 constexpr auto gamma = 1.4;
176 constexpr auto gasConstant = 287.058;
177 constexpr auto cp = gamma / (gamma - 1) * gasConstant;
178 constexpr auto referencePressure = """
181 constexpr auto gravity = 9.81;
182 constexpr auto q0 = 0.0;
184 const auto j = &Q[Shortcuts::j];
185 auto E = Q[Shortcuts::E];
186 auto rho = Q[Shortcuts::rho];
187 auto height = Q[Shortcuts::height];
194 outputQuantities[Shortcuts::rho] = rho;
195 outputQuantities[Shortcuts::j+0] = Q[Shortcuts::j+0]/rho;
196 outputQuantities[Shortcuts::j+1] = Q[Shortcuts::j+1]/rho;
198 outputQuantities[Shortcuts::j+2] = Q[Shortcuts::j+2]/rho;
200 outputQuantities[Shortcuts::E] = pressure;
202 const auto temperature = pressure/(gasConstant * rho);
203 const auto potT = temperature / std::pow((pressure / referencePressure), (gasConstant / cp));
205 outputQuantities[Shortcuts::height] = potT;
213 Here we simulate a homogeneous domain containing a single spherical bubble
214 of higher temperature.
215 Due to the higher temperature the bubble will rise and diffuse outward.
217 The bubble is best visualised in the potential temperature
222 // evaluate perturbation
223 tarch::la::Vector<DIMENSIONS, double> bubbleCenter = {
230 constexpr double size = 250;
231 constexpr auto tempDifference = 0.5;
233 const auto dist = tarch::la::norm2(x-bubbleCenter);
234 auto perturbation = dist <= size ?
235 tempDifference / 2 * (1 + std::cos((std::numbers::pi * dist) / size))
242 Here we simulate a homogeneous domain containing two bubbles, one of higher
243 temperature beneath the other of colder temperature.
244 Their repsective temperatures will cause the two bubbles to move towards one
245 another and collide, causing mixing effects.
250 // evaluate perturbation
251 tarch::la::Vector<DIMENSIONS, double> hotBubbleCenter = {
258 tarch::la::Vector<DIMENSIONS, double> coldBubbleCenter = {
265 constexpr double decay = 50.;
266 constexpr double tempDifferenceHot = 0.5;
267 constexpr double tempDifferenceCold = -0.15;
269 const auto d1 = tarch::la::norm2(x-hotBubbleCenter) - 150; // Hot bubble has a radius of 150
270 auto perturbation = d1 <= 0 ? tempDifferenceHot
271 : tempDifferenceHot * std::exp(-(d1 * d1) / (decay * decay));
273 const auto d2 = tarch::la::norm2(x-coldBubbleCenter) - 0; // Cold bubble has a radius of 0
274 perturbation += tempDifferenceCold * std::exp(-(d2 * d2) / (decay * decay));
Scenarios described in doi.org/10.1007/978-3-030-43229-4_27.
float _background_potential_temperature
_background_potential_temperature
evaluate_perturbation(self)
boundary_conditions(self)
evaluate_hydrostatic_pressure(self)
float _reference_pressure
Here we simulate a homogeneous domain containing a single spherical bubble of higher temperature.
evaluate_perturbation(self)
Here we simulate a homogeneous domain containing two bubbles, one of higher temperature beneath the o...
evaluate_perturbation(self)