ryujin 2.1.1 revision 336b16a72e829721302c626ec7071b92032b8248
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:
24 Function(const std::string &subsection)
25 : EquationOfState("function", subsection)
26 {
27 p_expression_ = "(1.4 - 1.0) * rho * e";
28 add_parameter(
29 "pressure",
30 p_expression_,
31 "A function expression for the pressure as a function of density, "
32 "rho, and specific internal energy, e: p(rho, e)");
33
34 sie_expression_ = "p / (rho * (1.4 - 1.0))";
35 add_parameter(
36 "specific internal energy",
37 sie_expression_,
38 "A function expression for the specific internal energy as a "
39 "function of density, rho, and pressure, p: e(rho, p)");
40
41 temperature_expression_ = "e / 718.";
42 add_parameter("temperature",
43 temperature_expression_,
44 "A function expression for the temperature as a "
45 "function of density, rho, and specific internal energy, "
46 "e: T(rho, e)");
47
48 sos_expression_ = "sqrt(1.4 * (1.4 - 1.0) * e)";
49 add_parameter(
50 "speed of sound",
51 sos_expression_,
52 "A function expression for the speed of sound as a function of "
53 "density, rho, and specific internal energy, e: s(rho, e)");
54
55 /*
56 * Set up the muparser object with the final equation of state
57 * description from the parameter file:
58 */
59 const auto set_up_muparser = [this] {
60 p_function_ = std::make_unique<dealii::FunctionParser<2>>();
61 p_function_->initialize("rho,e", p_expression_, {});
62
63 sie_function_ = std::make_unique<dealii::FunctionParser<2>>();
64 sie_function_->initialize("rho,p", sie_expression_, {});
65
66 temperature_function_ = std::make_unique<dealii::FunctionParser<2>>();
67 temperature_function_->initialize(
68 "rho,e", temperature_expression_, {});
69
70 sos_function_ = std::make_unique<dealii::FunctionParser<2>>();
71 sos_function_->initialize("rho,e", sos_expression_, {});
72 };
73
74 set_up_muparser();
75 ParameterAcceptor::parse_parameters_call_back.connect(set_up_muparser);
76 }
77
78 double pressure(double rho, double e) const final
79 {
80 return p_function_->value(dealii::Point<2>(rho, e));
81 }
82
83 double specific_internal_energy(double rho, double p) const final
84 {
85 return sie_function_->value(dealii::Point<2>(rho, p));
86 }
87
88 double temperature(double rho, double e) const final
89 {
90 return temperature_function_->value(dealii::Point<2>(rho, e));
91 }
92
93 double speed_of_sound(double rho, double e) const final
94 {
95 return sos_function_->value(dealii::Point<2>(rho, e));
96 }
97
98 private:
99 std::string p_expression_;
100 std::string sie_expression_;
101 std::string sos_expression_;
102 std::string temperature_expression_;
103
104 std::unique_ptr<dealii::FunctionParser<2>> p_function_;
105 std::unique_ptr<dealii::FunctionParser<2>> sie_function_;
106 std::unique_ptr<dealii::FunctionParser<2>> sos_function_;
107 std::unique_ptr<dealii::FunctionParser<2>> temperature_function_;
108 };
109 } // namespace EquationOfStateLibrary
110} // namespace ryujin
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