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