ryujin 2.1.1 revision 0348cbb53a3e4b1da2a4c037e81f88f2d21ce219
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 by the ryujin authors
4//
5
6#pragma once
7
8#include "equation_of_state.h"
9
10#include <deal.II/base/function_parser.h>
11
12namespace ryujin
13{
14 namespace EquationOfStateLibrary
15 {
22 {
23 public:
28
29 Function(const std::string &subsection)
30 : EquationOfState("function", subsection)
31 {
32 p_expression_ = "(1.4 - 1.0) * rho * e";
33 add_parameter(
34 "pressure",
35 p_expression_,
36 "A function expression for the pressure as a function of density, "
37 "rho, and specific internal energy, e: p(rho, e)");
38
39 sie_expression_ = "p / (rho * (1.4 - 1.0))";
40 add_parameter(
41 "specific internal energy",
42 sie_expression_,
43 "A function expression for the specific internal energy as a "
44 "function of density, rho, and pressure, p: e(rho, p)");
45
46 temperature_expression_ = "e / 718.";
47 add_parameter("temperature",
48 temperature_expression_,
49 "A function expression for the temperature as a "
50 "function of density, rho, and specific internal energy, "
51 "e: T(rho, e)");
52
53 sos_expression_ = "sqrt(1.4 * (1.4 - 1.0) * e)";
54 add_parameter(
55 "speed of sound",
56 sos_expression_,
57 "A function expression for the speed of sound as a function of "
58 "density, rho, and specific internal energy, e: s(rho, e)");
59
60 add_parameter(
61 "interpolatory covolume b",
62 this->interpolation_b_,
63 "The interpolatory maximum compressibility constant b used when "
64 "constructing the interpolatory equation of state");
65
66 add_parameter("interpolatory reference pressure",
68 "The interpolatory reference pressure p_infty used when "
69 "constructing the interpolatory equation of state");
70
71 add_parameter(
72 "interpolatory reference specific internal energy",
73 this->interpolation_q_,
74 "The interpolatory reference specific internal energy q used when "
75 "constructing the interpolatory equation of state");
76
77 /*
78 * Set up the muparser object with the final equation of state
79 * description from the parameter file:
80 */
81 const auto set_up_muparser = [this] {
82 p_function_ = std::make_unique<dealii::FunctionParser<2>>();
83 p_function_->initialize("rho,e", p_expression_, {});
84
85 sie_function_ = std::make_unique<dealii::FunctionParser<2>>();
86 sie_function_->initialize("rho,p", sie_expression_, {});
87
88 temperature_function_ = std::make_unique<dealii::FunctionParser<2>>();
89 temperature_function_->initialize(
90 "rho,e", temperature_expression_, {});
91
92 sos_function_ = std::make_unique<dealii::FunctionParser<2>>();
93 sos_function_->initialize("rho,e", sos_expression_, {});
94 };
95
96 set_up_muparser();
97 ParameterAcceptor::parse_parameters_call_back.connect(set_up_muparser);
98 }
99
100 double pressure(double rho, double e) const final
101 {
102 return p_function_->value(dealii::Point<2>(rho, e));
103 }
104
105 double specific_internal_energy(double rho, double p) const final
106 {
107 return sie_function_->value(dealii::Point<2>(rho, p));
108 }
109
110 double temperature(double rho, double e) const final
111 {
112 return temperature_function_->value(dealii::Point<2>(rho, e));
113 }
114
115 double speed_of_sound(double rho, double e) const final
116 {
117 return sos_function_->value(dealii::Point<2>(rho, e));
118 }
119
120 private:
121 std::string p_expression_;
122 std::string sie_expression_;
123 std::string sos_expression_;
124 std::string temperature_expression_;
125
126 std::unique_ptr<dealii::FunctionParser<2>> p_function_;
127 std::unique_ptr<dealii::FunctionParser<2>> sie_function_;
128 std::unique_ptr<dealii::FunctionParser<2>> sos_function_;
129 std::unique_ptr<dealii::FunctionParser<2>> temperature_function_;
130 };
131 } // namespace EquationOfStateLibrary
132} // 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 rho, double e) const =0
virtual double temperature(double rho, double e) const =0
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 pressure(double rho, double e) const final