ryujin 2.5.0 revision c64172211cf21344cb9b9b0f3a1266aa6400d392
Loading...
Searching...
No Matches
equation_of_state_function.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
11#include <deal.II/base/function_parser.h>
12
13namespace ryujin
14{
15 namespace EquationsOfState
16 {
23 {
24 public:
29
30 Function(const std::string &subsection)
31 : EquationOfState("function", subsection)
32 {
33 p_expression_ = "(1.4 - 1.0) * rho * e";
34 add_parameter(
35 "pressure",
36 p_expression_,
37 "A function expression for the pressure as a function of density, "
38 "rho, and specific internal energy, e: p(rho, e)");
39
40 sie_expression_ = "p / (rho * (1.4 - 1.0))";
41 add_parameter(
42 "specific internal energy",
43 sie_expression_,
44 "A function expression for the specific internal energy as a "
45 "function of density, rho, and pressure, p: e(rho, p)");
46
47 se_expression_ = "287.052874 / (1.4 - 1.0) * (log((1.4 - 1.0) * rho * "
48 "e) - 1.4 * log(287.052874 * rho))";
49 add_parameter("specific entropy",
50 se_expression_,
51 "A function expression for the specific entropy as a "
52 "function of density, "
53 "rho, and specific internal energy, e: s(rho, e)");
54
55 e0_expression_ = "0";
56 add_parameter("cold curve bound",
57 e0_expression_,
58 "A function expression for the cold curve bound as a "
59 "function of density: e_0(rho)");
60
61 temperature_expression_ = "e * (1.4 - 1.0) / 287.052874";
62 add_parameter("temperature",
63 temperature_expression_,
64 "A function expression for the temperature as a "
65 "function of density, rho, and specific internal energy, "
66 "e: T(rho, e)");
67
68 sos_expression_ = "sqrt(1.4 * (1.4 - 1.0) * e)";
69 add_parameter(
70 "speed of sound",
71 sos_expression_,
72 "A function expression for the speed of sound as a function of "
73 "density, rho, and specific internal energy, e: s(rho, e)");
74
75 add_parameter(
76 "covolume constant",
78 "The maximum compressibility constant b for the equation of state");
79
80 add_parameter("interpolatory reference pressure",
82 "The interpolatory reference pressure p_infty used when "
83 "constructing the interpolatory equation of state");
84
85 add_parameter(
86 "interpolatory reference specific internal energy",
87 this->interpolation_q_,
88 "The interpolatory reference specific internal energy q used when "
89 "constructing the interpolatory equation of state");
90
91 /*
92 * Set up the muparser object with the final equation of state
93 * description from the parameter file:
94 */
95 const auto set_up_muparser = [this] {
96 p_function_ = std::make_unique<dealii::FunctionParser<2>>();
97 p_function_->initialize(
98 "rho,e", p_expression_, {{"b", this->covolume_constant_}});
99
100 sie_function_ = std::make_unique<dealii::FunctionParser<2>>();
101 sie_function_->initialize(
102 "rho,p", sie_expression_, {{"b", this->covolume_constant_}});
103
104 se_function_ = std::make_unique<dealii::FunctionParser<2>>();
105 se_function_->initialize(
106 "rho,e", se_expression_, {{"b", this->covolume_constant_}});
107
108 e0_function_ = std::make_unique<dealii::FunctionParser<1>>();
109 e0_function_->initialize(
110 "rho", e0_expression_, {{"b", this->covolume_constant_}});
111
112 temperature_function_ = std::make_unique<dealii::FunctionParser<2>>();
113 temperature_function_->initialize("rho,e",
114 temperature_expression_,
115 {{"b", this->covolume_constant_}});
116
117 sos_function_ = std::make_unique<dealii::FunctionParser<2>>();
118 sos_function_->initialize("rho,e", sos_expression_, {});
119 };
120
121 set_up_muparser();
122 ParameterAcceptor::parse_parameters_call_back.connect(set_up_muparser);
123 }
124
125 double pressure(double rho, double e) const final
126 {
127 return p_function_->value(dealii::Point<2>(rho, e));
128 }
129
130 double specific_internal_energy(double rho, double p) const final
131 {
132 return sie_function_->value(dealii::Point<2>(rho, p));
133 }
134
135 double specific_entropy(double rho, double e) const final
136 {
137 return se_function_->value(dealii::Point<2>(rho, e));
138 }
139
140 double cold_curve_bound(double rho) const final
141 {
142 return e0_function_->value(dealii::Point<1>(rho));
143 }
144
145 double temperature(double rho, double e) const final
146 {
147 return temperature_function_->value(dealii::Point<2>(rho, e));
148 }
149
150 double speed_of_sound(double rho, double e) const final
151 {
152 return sos_function_->value(dealii::Point<2>(rho, e));
153 }
154
155 private:
156 std::string p_expression_;
157 std::string sie_expression_;
158 std::string se_expression_;
159 std::string e0_expression_;
160 std::string temperature_expression_;
161 std::string sos_expression_;
162
163 std::unique_ptr<dealii::FunctionParser<2>> p_function_;
164 std::unique_ptr<dealii::FunctionParser<2>> sie_function_;
165 std::unique_ptr<dealii::FunctionParser<2>> se_function_;
166 std::unique_ptr<dealii::FunctionParser<1>> e0_function_;
167 std::unique_ptr<dealii::FunctionParser<2>> temperature_function_;
168 std::unique_ptr<dealii::FunctionParser<2>> sos_function_;
169 };
170 } // namespace EquationsOfState
171} // 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 cold_curve_bound(double rho) const final
double specific_internal_energy(double rho, double p) const final
Function(const std::string &subsection)
double temperature(double rho, double e) const final
double specific_entropy(double rho, double e) const final
double speed_of_sound(double rho, double e) const final