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