ryujin 2.1.1 revision 0348cbb53a3e4b1da2a4c037e81f88f2d21ce219
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:
26
27 VanDerWaals(const std::string &subsection)
28 : EquationOfState("van der waals", subsection)
29 {
30 gamma_ = 7. / 5.;
31 this->add_parameter("gamma", gamma_, "The ratio of specific heats");
32
33 a_ = 0.;
34 this->add_parameter("vdw a", a_, "The vdw a constant");
35
36 b_ = 0.;
37 this->add_parameter(
38 "covolume b", b_, "The maximum compressibility constant");
39
40 /*
41 * R is the specific gas constant with units [J / (Kg K)]. More details
42 * can be found at:
43 * https://en.wikipedia.org/wiki/Gas_constant#Specific_gas_constant
44 */
45 R_ = 0.4;
46 this->add_parameter(
47 "gas constant R", R_, "The specific gas constant R");
48
49 cv_ = R_ / (gamma_ - 1.);
50
51 /* Update the EOS interpolation parameters on parameter read in: */
52 ParameterAcceptor::parse_parameters_call_back.connect([this] {
53 this->interpolation_b_ = b_;
54 /*
55 * FIXME: The van der Waals EOS allows for negative pressures. We
56 * should thus come up with a sensible way of setting
57 * "interpolation_pinfty_"...
58 */
59 });
60 }
61
68 double pressure(double rho, double e) const final
69 {
70 const auto intermolecular = a_ * rho * rho;
71 const auto numerator = rho * e + intermolecular;
72 const auto covolume = 1. - b_ * rho;
73 return (gamma_ - 1.) * numerator / covolume - intermolecular;
74 }
75
83 double specific_internal_energy(double rho, double p) const final
84 {
85 const auto intermolecular = a_ * rho * rho;
86 const auto covolume = 1. - b_ * rho;
87 const auto numerator = (p + intermolecular) * covolume;
88 const auto denominator = rho * (gamma_ - 1.);
89 return numerator / denominator - a_ * rho;
90 }
91
98 double temperature(double rho, double e) const final
99 {
100 return (e + a_ * rho) / cv_;
101 }
102
110 double speed_of_sound(double rho, double e) const final
111 {
112 const auto covolume = 1. - b_ * rho;
113 const auto numerator = gamma_ * (gamma_ - 1.) * (e + a_ * rho);
114 return std::sqrt(numerator / (covolume * covolume) - 2. * a_ * rho);
115 }
116
117 private:
118 double gamma_;
119 double b_;
120 double a_;
121 double R_;
122 double cv_;
123 };
124 } // namespace EquationOfStateLibrary
125} /* 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 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