ryujin 2.1.1 revision fa044d3939298da517bf6a5839b34e00b155547d
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 <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 temperature_expression_ = "e / 718.";
49 add_parameter("temperature",
50 temperature_expression_,
51 "A function expression for the temperature as a "
52 "function of density, rho, and specific internal energy, "
53 "e: T(rho, e)");
54
55 sos_expression_ = "sqrt(1.4 * (1.4 - 1.0) * e)";
56 add_parameter(
57 "speed of sound",
58 sos_expression_,
59 "A function expression for the speed of sound as a function of "
60 "density, rho, and specific internal energy, e: s(rho, e)");
61
62 add_parameter(
63 "interpolatory covolume b",
64 this->interpolation_b_,
65 "The interpolatory maximum compressibility constant b used when "
66 "constructing the interpolatory equation of state");
67
68 add_parameter("interpolatory reference pressure",
70 "The interpolatory reference pressure p_infty used when "
71 "constructing the interpolatory equation of state");
72
73 add_parameter(
74 "interpolatory reference specific internal energy",
75 this->interpolation_q_,
76 "The interpolatory reference specific internal energy q used when "
77 "constructing the interpolatory equation of state");
78
79 /*
80 * Set up the muparser object with the final equation of state
81 * description from the parameter file:
82 */
83 const auto set_up_muparser = [this] {
84 p_function_ = std::make_unique<dealii::FunctionParser<2>>();
85 p_function_->initialize("rho,e", p_expression_, {});
86
87 sie_function_ = std::make_unique<dealii::FunctionParser<2>>();
88 sie_function_->initialize("rho,p", sie_expression_, {});
89
90 temperature_function_ = std::make_unique<dealii::FunctionParser<2>>();
91 temperature_function_->initialize(
92 "rho,e", temperature_expression_, {});
93
94 sos_function_ = std::make_unique<dealii::FunctionParser<2>>();
95 sos_function_->initialize("rho,e", sos_expression_, {});
96 };
97
98 set_up_muparser();
99 ParameterAcceptor::parse_parameters_call_back.connect(set_up_muparser);
100 }
101
102 double pressure(double rho, double e) const final
103 {
104 return p_function_->value(dealii::Point<2>(rho, e));
105 }
106
107 double specific_internal_energy(double rho, double p) const final
108 {
109 return sie_function_->value(dealii::Point<2>(rho, p));
110 }
111
112 double temperature(double rho, double e) const final
113 {
114 return temperature_function_->value(dealii::Point<2>(rho, e));
115 }
116
117 double speed_of_sound(double rho, double e) const final
118 {
119 return sos_function_->value(dealii::Point<2>(rho, e));
120 }
121
122 private:
123 std::string p_expression_;
124 std::string sie_expression_;
125 std::string sos_expression_;
126 std::string temperature_expression_;
127
128 std::unique_ptr<dealii::FunctionParser<2>> p_function_;
129 std::unique_ptr<dealii::FunctionParser<2>> sie_function_;
130 std::unique_ptr<dealii::FunctionParser<2>> sos_function_;
131 std::unique_ptr<dealii::FunctionParser<2>> temperature_function_;
132 };
133 } // namespace EquationOfStateLibrary
134} // 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