ryujin 2.5.0 revision c64172211cf21344cb9b9b0f3a1266aa6400d392
Loading...
Searching...
No Matches
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 - 2026 by the ryujin authors
4//
5
6#pragma once
7
8#include <ryujin/base/compile_time_options.h>
10
11namespace ryujin
12{
13 namespace EquationsOfState
14 {
21 {
22 public:
27
28 VanDerWaals(const std::string &subsection)
29 : EquationOfState("van der waals", subsection)
30 {
31 gamma_ = 7. / 5.;
32 this->add_parameter("gamma", gamma_, "The ratio of specific heats");
33
34 a_ = 0.;
35 this->add_parameter("vdw a", a_, "The vdw a constant");
36
37 b_ = 0.;
38 this->add_parameter(
39 "covolume b", b_, "The maximum compressibility constant");
40
41 /*
42 * R is the specific gas constant with units [J / (Kg K)]. More details
43 * can be found at:
44 * https://en.wikipedia.org/wiki/Gas_constant#Specific_gas_constant
45 */
46 R_ = 0.4;
47 this->add_parameter(
48 "gas constant R", R_, "The specific gas constant R");
49
50 cv_ = R_ / (gamma_ - 1.);
51
52 /* Update the EOS interpolation parameters on parameter read in
53 * and the specific heat at constant volume:
54 */
55 ParameterAcceptor::parse_parameters_call_back.connect([this] {
56 this->covolume_constant_ = b_;
57 cv_ = R_ / (gamma_ - 1.);
58 /*
59 * FIXME: The van der Waals EOS allows for negative pressures. We
60 * should thus come up with a sensible way of setting
61 * "interpolation_pinfty_"...
62 */
63 });
64 }
65
72 double pressure(double rho, double e) const final
73 {
74 const auto intermolecular = a_ * rho * rho;
75 const auto numerator = rho * e + intermolecular;
76 const auto covolume = 1. - b_ * rho;
77 return (gamma_ - 1.) * numerator / covolume - intermolecular;
78 }
79
86 double specific_internal_energy(double rho, double p) const final
87 {
88 const auto intermolecular = a_ * rho * rho;
89 const auto covolume = 1. - b_ * rho;
90 const auto numerator = (p + intermolecular) * covolume;
91 const auto denominator = rho * (gamma_ - 1.);
92 return numerator / denominator - a_ * rho;
93 }
94
101 double temperature(double rho, double e) const final
102 {
103 return (e + a_ * rho) / cv_;
104 }
105
112 double cold_curve_bound(double rho) const final
113 {
114 return -a_ * rho;
115 }
116
123 double specific_entropy(double rho, double e) const final
124 {
125 const auto first_term = cv_ * std::log((e + a_ * rho) / cv_);
126 const auto second_term = R_ * std::log(1. / rho - b_);
127 return first_term + second_term;
128 }
129
137 double speed_of_sound(double rho, double e) const final
138 {
139 const auto covolume = 1. - b_ * rho;
140 const auto numerator = gamma_ * (gamma_ - 1.) * (e + a_ * rho);
141 return std::sqrt(numerator / (covolume * covolume) - 2. * a_ * rho);
142 }
143
144 private:
145 double gamma_;
146 double b_;
147 double a_;
148 double R_;
149 double cv_;
150 };
151 } // namespace EquationsOfState
152} // namespace ryujin
virtual double pressure(double rho, double e) const =0
virtual double temperature(double, double) const
virtual double speed_of_sound(double, double) const
virtual double specific_internal_energy(double rho, double p) const =0
double pressure(double rho, double e) const final
double specific_entropy(double rho, double e) const final
double specific_internal_energy(double rho, double p) const final
double speed_of_sound(double rho, double e) const final
double temperature(double rho, double e) const final