ryujin 2.5.0 revision c64172211cf21344cb9b9b0f3a1266aa6400d392
Loading...
Searching...
No Matches
equation_of_state_polytropic_gas.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 <ryujin/base/compile_time_options.h>
10
11namespace ryujin
12{
13 namespace EquationsOfState
14 {
21 {
22 public:
27
28 PolytropicGas(const std::string &subsection)
29 : EquationOfState("polytropic gas", subsection)
30 {
31 gamma_ = 7. / 5.;
32 this->add_parameter("gamma", gamma_, "The ratio of specific heats");
33
34 /*
35 * R is the specific gas constant with units [J / (Kg K)]. More details
36 * can be found at:
37 * https://en.wikipedia.org/wiki/Gas_constant#Specific_gas_constant
38 */
39 R_ = 287.052874;
40 this->add_parameter(
41 "gas constant R", R_, "The specific gas constant R");
42
43 cv_ = R_ / (gamma_ - 1.);
44
45 s0_ = 0.;
46 this->add_parameter("reference specific entropy",
47 s0_,
48 "The reference specific entropy");
49
50 /* Update the EOS interpolation parameters on parameter read in: */
51 ParameterAcceptor::parse_parameters_call_back.connect(
52 [this] { cv_ = R_ / (gamma_ - 1.); });
53 }
54
61 double pressure(double rho, double e) const final
62 {
63 return (gamma_ - 1.) * rho * e;
64 }
65
72 double specific_internal_energy(double rho, double p) const final
73 {
74 return p / (rho * (gamma_ - 1.));
75 }
76
83 double temperature(double /*rho*/, double e) const final
84 {
85 return e / cv_;
86 }
87
94 double cold_curve_bound(double /*rho*/) const final
95 {
96 return 0.;
97 }
98
106 double specific_entropy(double rho, double e) const final
107 {
108 const auto gm1 = gamma_ - 1.;
109 const auto p = gm1 * rho * e;
110 return cv_ * (std::log(p) - gamma_ * std::log(gm1 * cv_ * rho)) + s0_;
111 }
112
120 double speed_of_sound(double /*rho*/, double e) const final
121 {
122 return std::sqrt(gamma_ * (gamma_ - 1.) * e);
123 }
124
125 private:
126 double gamma_;
127 double R_;
128 double cv_;
129 double s0_;
130 };
131 } // namespace EquationsOfState
132} // 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
double pressure(double rho, double e) const final
double speed_of_sound(double, double e) const final
double specific_entropy(double rho, double e) const final
double specific_internal_energy(double rho, double p) const final