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