ryujin 2.1.1 revision 336b16a72e829721302c626ec7071b92032b8248
equation_of_state_van_der_waals.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
10namespace ryujin
11{
12 namespace EquationOfStateLibrary
13 {
20 {
21 public:
22 VanDerWaals(const std::string &subsection)
23 : EquationOfState("van der waals", subsection)
24 {
25 gamma_ = 7. / 5.;
26 this->add_parameter("gamma", gamma_, "The ratio of specific heats");
27
28 a_ = 0.;
29 this->add_parameter("vdw a", a_, "The vdw a constant");
30
31 b_ = 0.;
32 this->add_parameter(
33 "covolume b", b_, "The maximum compressibility constant");
34
35 /*
36 * R is the specific gas constant with units [J / (Kg K)]. More details
37 * can be found at:
38 * https://en.wikipedia.org/wiki/Gas_constant#Specific_gas_constant
39 */
40 R_ = 0.4;
41 this->add_parameter(
42 "gas constant R", R_, "The specific gas constant R");
43
44 cv_ = R_ / (gamma_ - 1.);
45
46 /* Update the interpolation_b_ parameter on parameter read in: */
47 ParameterAcceptor::parse_parameters_call_back.connect(
48 [this] { this->interpolation_b_ = b_; });
49 }
50
57 double pressure(double rho, double e) const final
58 {
59 const auto intermolecular = a_ * rho * rho;
60 const auto numerator = rho * e + intermolecular;
61 const auto covolume = 1. - b_ * rho;
62 return (gamma_ - 1.) * numerator / covolume - intermolecular;
63 }
64
72 double specific_internal_energy(double rho, double p) const final
73 {
74 const auto intermolecular = a_ * rho * rho;
75 const auto covolume = 1. - b_ * rho;
76 const auto numerator = (p + intermolecular) * covolume;
77 const auto denominator = rho * (gamma_ - 1.);
78 return numerator / denominator - a_ * rho;
79 }
80
87 double temperature(double rho, double e) const final
88 {
89 return (e + a_ * rho) / cv_;
90 }
91
99 double speed_of_sound(double rho, double e) const final
100 {
101 const auto covolume = 1. - b_ * rho;
102 const auto numerator = gamma_ * (gamma_ - 1.) * (e + a_ * rho);
103 return std::sqrt(numerator / (covolume * covolume) - 2. * a_ * rho);
104 }
105
106 private:
107 double gamma_;
108 double b_;
109 double a_;
110 double R_;
111 double cv_;
112 };
113 } // namespace EquationOfStateLibrary
114} /* namespace ryujin */
double temperature(double rho, double e) const final
double pressure(double rho, double e) const final
double speed_of_sound(double rho, double e) const final
double specific_internal_energy(double rho, double p) const final