ryujin 2.1.1 revision 46bf70e400e423a8ffffe8300887eeb35b8dfb2c
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 <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 ParameterAcceptor::parse_parameters_call_back.connect([this] {
55 this->interpolation_b_ = b_;
56 /*
57 * FIXME: The van der Waals EOS allows for negative pressures. We
58 * should thus come up with a sensible way of setting
59 * "interpolation_pinfty_"...
60 */
61 });
62 }
63
70 double pressure(double rho, double e) const final
71 {
72 const auto intermolecular = a_ * rho * rho;
73 const auto numerator = rho * e + intermolecular;
74 const auto covolume = 1. - b_ * rho;
75 return (gamma_ - 1.) * numerator / covolume - intermolecular;
76 }
77
85 double specific_internal_energy(double rho, double p) const final
86 {
87 const auto intermolecular = a_ * rho * rho;
88 const auto covolume = 1. - b_ * rho;
89 const auto numerator = (p + intermolecular) * covolume;
90 const auto denominator = rho * (gamma_ - 1.);
91 return numerator / denominator - a_ * rho;
92 }
93
100 double temperature(double rho, double e) const final
101 {
102 return (e + a_ * rho) / cv_;
103 }
104
112 double speed_of_sound(double rho, double e) const final
113 {
114 const auto covolume = 1. - b_ * rho;
115 const auto numerator = gamma_ * (gamma_ - 1.) * (e + a_ * rho);
116 return std::sqrt(numerator / (covolume * covolume) - 2. * a_ * rho);
117 }
118
119 private:
120 double gamma_;
121 double b_;
122 double a_;
123 double R_;
124 double cv_;
125 };
126 } // namespace EquationOfStateLibrary
127} /* 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