ryujin 2.5.0 revision c64172211cf21344cb9b9b0f3a1266aa6400d392
Loading...
Searching...
No Matches
equation_of_state_bumpy_barotropic_pressure.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2026 by the ryujin authors
4//
5
6#pragma once
7
8#include <ryujin/base/compile_time_options.h>
10
11namespace ryujin
12{
13 namespace EquationsOfState
14 {
55 {
56 public:
61
62 BumpyBarotropicPressure(const std::string &subsection)
63 : EquationOfState("bumpy barotropic pressure", subsection)
64 {
65 /*
66 * Parameters of the hydrodynamical (Noble-Abel stiffened gas)
67 * constituent:
68 */
69
70 gamma_ = 7. / 5.;
71 this->add_parameter("gamma", gamma_, "The ratio of specific heats");
72
73 /*
74 * R is the specific gas constant with units [J / (Kg K)]. More details
75 * can be found at:
76 * https://en.wikipedia.org/wiki/Gas_constant#Specific_gas_constant
77 */
78 R_ = 287.052874;
79 this->add_parameter(
80 "gas constant R", R_, "The specific gas constant R");
81
82 cv_ = R_ / (gamma_ - 1.);
83
84 b_ = 0.;
85 this->add_parameter(
86 "covolume b", b_, "The maximum compressibility constant");
87
88 q_ = 0.;
89 this->add_parameter("reference specific internal energy",
90 q_,
91 "The reference specific internal energy");
92
93 pinf_ = 0.;
94 this->add_parameter(
95 "reference pressure", pinf_, "The reference pressure p infinity");
96
97 s0_ = 0.;
98 this->add_parameter("reference specific entropy",
99 s0_,
100 "The reference specific entropy");
101
102 /*
103 * Parameters of the barotropic constituent:
104 */
105
106 rho_0_ = 1.;
107 this->add_parameter("barotropic reference density",
108 rho_0_,
109 "The density rho_0 at which the barotropic speed "
110 "of sound is centered");
111
112 c_0_ = 1.;
113 this->add_parameter("barotropic sound speed",
114 c_0_,
115 "The strength c_0 of the barotropic speed of "
116 "sound");
117
118 eps_ = 1.e-2;
119 this->add_parameter("barotropic bump width",
120 eps_,
121 "The width epsilon of the barotropic bump");
122
123 e_0_ = 0.;
124 this->add_parameter("barotropic reference specific internal energy",
125 e_0_,
126 "The (arbitrary) additive constant e_0 of the "
127 "barotropic specific internal energy");
128
129 /*
130 * Update the EOS interpolation parameters on parameter read in
131 * and specific heat at constant volume:
132 *
133 * @note The interpolation parameters are the ones of the
134 * hydrodynamical constituent. They drive the surrogate NASG
135 * interpolation performed in HyperbolicSystemView
136 * (surrogate_gamma(), surrogate_pressure(),
137 * surrogate_specific_entropy(), ...) which is unaware of the
138 * barotropic contribution.
139 */
140 ParameterAcceptor::parse_parameters_call_back.connect([this] {
141 this->covolume_constant_ = b_;
142 this->interpolation_pinfty_ = pinf_;
143 this->interpolation_q_ = q_;
144 cv_ = R_ / (gamma_ - 1.);
145 });
146 }
147
154 double pressure(double rho, double e) const final
155 {
156 const auto e_h = e - barotropic_specific_internal_energy(rho);
157 return hydrodynamic_pressure(rho, e_h) + barotropic_pressure(rho);
158 }
159
160
167 double specific_internal_energy(double rho, double p) const final
168 {
169 const auto p_h = p - barotropic_pressure(rho);
170 return hydrodynamic_specific_internal_energy(rho, p_h) +
171 barotropic_specific_internal_energy(rho);
172 }
173
181 double temperature(double rho, double e) const final
182 {
183 const auto e_h = e - barotropic_specific_internal_energy(rho);
184 return hydrodynamic_temperature(rho, e_h);
185 }
186
195 double cold_curve_bound(double rho) const final
196 {
197 return hydrodynamic_cold_curve_bound(rho) +
198 barotropic_specific_internal_energy(rho);
199 }
200
208 double specific_entropy(double rho, double e) const final
209 {
210 const auto e_h = e - barotropic_specific_internal_energy(rho);
211 return hydrodynamic_specific_entropy(rho, e_h);
212 }
213
222 double speed_of_sound(double rho, double e) const final
223 {
224 const auto e_h = e - barotropic_specific_internal_energy(rho);
225 return std::sqrt(hydrodynamic_sound_speed_squared(rho, e_h) +
226 barotropic_sound_speed_squared(rho));
227 }
228
229 private:
237 double barotropic_sound_speed_squared(double rho) const
238 {
239 const auto radicand = (rho - rho_0_) * (rho - rho_0_) + eps_;
240 return c_0_ * c_0_ / (radicand * std::sqrt(radicand));
241 }
242
252 double barotropic_pressure(double rho) const
253 {
254 const auto s = std::sqrt((rho - rho_0_) * (rho - rho_0_) + eps_);
255 const auto s_0 = std::sqrt(rho_0_ * rho_0_ + eps_);
256 return c_0_ * c_0_ / eps_ * ((rho - rho_0_) / s + rho_0_ / s_0);
257 }
258
276 double barotropic_specific_internal_energy(double rho) const
277 {
278 const auto s = std::sqrt((rho - rho_0_) * (rho - rho_0_) + eps_);
279 const auto s_0_squared = rho_0_ * rho_0_ + eps_;
280 const auto s_0 = std::sqrt(s_0_squared);
281
282 const auto first_term =
283 c_0_ * c_0_ * rho_0_ * (s - s_0) / (eps_ * s_0_squared * rho);
284
285 const auto argument =
286 (2. * rho * rho_0_ - s_0_squared) / ((rho + s) * s_0);
287 const auto second_term =
288 2. * c_0_ * c_0_ / (s_0_squared * s_0) * std::atanh(argument);
289
290 return first_term + second_term + e_0_;
291 }
292
301 double hydrodynamic_pressure(double rho, double e_h) const
302 {
303 return (gamma_ - 1.) * rho * (e_h - q_) / (1. - b_ * rho) -
304 gamma_ * pinf_;
305 }
306
314 double hydrodynamic_specific_internal_energy(double rho, double p_h) const
315 {
316 const auto numerator = (p_h + gamma_ * pinf_) * (1. - b_ * rho);
317 const auto denominator = rho * (gamma_ - 1.);
318 return q_ + numerator / denominator;
319 }
320
327 double hydrodynamic_temperature(double rho, double e_h) const
328 {
329 return (e_h - q_ - pinf_ * (1. / rho - b_)) / cv_;
330 }
331
338 double hydrodynamic_cold_curve_bound(double rho) const
339 {
340 return q_ + pinf_ * (1. / rho - b_);
341 }
342
355 double hydrodynamic_specific_entropy(double rho, double e_h) const
356 {
357 const auto covolume_term = 1. / rho - b_;
358 const auto p_plus_pinf = (gamma_ - 1.) *
359 ((e_h - q_) - pinf_ * covolume_term) /
360 covolume_term;
361 const auto first_term = cv_ * std::log(p_plus_pinf);
362 const auto second_term =
363 cv_ * gamma_ * std::log((gamma_ - 1.) * cv_ / covolume_term);
364 return first_term - second_term + s0_;
365 }
366
376 double hydrodynamic_sound_speed_squared(double rho, double e_h) const
377 {
378 const auto covolume = 1. - b_ * rho;
379 auto result =
380 (rho * (e_h - q_) - pinf_ * covolume) / (covolume * covolume * rho);
381 result *= gamma_ * (gamma_ - 1.);
382 return result;
383 }
384
385 double gamma_;
386 double R_;
387 double cv_;
388 double b_;
389 double q_;
390 double pinf_;
391 double s0_;
392
393 double rho_0_;
394 double c_0_;
395 double eps_;
396 double e_0_;
397 };
398 } // namespace EquationsOfState
399} // namespace ryujin
virtual double pressure(double rho, double e) const =0
virtual double temperature(double, double) const
virtual double speed_of_sound(double, double) const
virtual double specific_internal_energy(double rho, double p) const =0