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