Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <boost/preprocessor/arithmetic/dec.hpp> 7 : #include <boost/preprocessor/arithmetic/inc.hpp> 8 : #include <boost/preprocessor/control/expr_iif.hpp> 9 : #include <boost/preprocessor/list/adt.hpp> 10 : #include <boost/preprocessor/repetition/for.hpp> 11 : #include <boost/preprocessor/repetition/repeat.hpp> 12 : #include <boost/preprocessor/tuple/to_list.hpp> 13 : #include <limits> 14 : #include <pup.h> 15 : 16 : #include "DataStructures/Tensor/TypeAliases.hpp" 17 : #include "Options/String.hpp" 18 : #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp" // IWYU pragma: keep 19 : #include "PointwiseFunctions/Hydro/Units.hpp" 20 : #include "Utilities/Serialization/CharmPupable.hpp" 21 : #include "Utilities/TMPL.hpp" 22 : 23 : /// \cond 24 : class DataVector; 25 : /// \endcond 26 : 27 : namespace EquationsOfState { 28 : /*! 29 : * \ingroup EquationsOfStateGroup 30 : * \brief Equation of state for an ideal fluid 31 : * 32 : * An ideal fluid equation of state: 33 : * 34 : * \f[ 35 : * p = \rho \epsilon(\gamma-1) 36 : * \f] 37 : * 38 : * where \f$\rho\f$ is the rest mass density, \f$\epsilon\f$ is the specific 39 : * internal energy, and \f$\gamma\f$ is the adiabatic index. 40 : * 41 : * The temperature \f$T\f$ is defined as 42 : * 43 : * \f[ 44 : * T = (\gamma - 1) \epsilon 45 : * \f] 46 : */ 47 : template <bool IsRelativistic> 48 1 : class IdealFluid : public EquationOfState<IsRelativistic, 2> { 49 : public: 50 0 : static constexpr size_t thermodynamic_dim = 2; 51 0 : static constexpr bool is_relativistic = IsRelativistic; 52 : 53 0 : struct AdiabaticIndex { 54 0 : using type = double; 55 0 : static constexpr Options::String help = {"Adiabatic index gamma"}; 56 : }; 57 : 58 0 : static constexpr Options::String help = { 59 : "An ideal fluid equation of state.\n" 60 : "The pressure is related to the rest mass density by p = rho * epsilon * " 61 : "(gamma - 1), where p is the pressure, rho is the rest mass density, " 62 : "epsilon is the specific internal energy, and gamma is the adiabatic " 63 : "index.\n" 64 : "The temperature T is defined as T=epsilon."}; 65 : 66 0 : using options = tmpl::list<AdiabaticIndex>; 67 : 68 0 : IdealFluid() = default; 69 0 : IdealFluid(const IdealFluid&) = default; 70 0 : IdealFluid& operator=(const IdealFluid&) = default; 71 0 : IdealFluid(IdealFluid&&) = default; 72 0 : IdealFluid& operator=(IdealFluid&&) = default; 73 0 : ~IdealFluid() override = default; 74 : 75 0 : explicit IdealFluid(double adiabatic_index); 76 : 77 : EQUATION_OF_STATE_FORWARD_DECLARE_MEMBERS(IdealFluid, 2) 78 : 79 0 : std::unique_ptr<EquationOfState<IsRelativistic, 2>> get_clone() 80 : const override; 81 : 82 0 : bool operator==(const IdealFluid<IsRelativistic>& rhs) const; 83 : 84 0 : bool operator!=(const IdealFluid<IsRelativistic>& rhs) const; 85 : 86 0 : bool is_equal(const EquationOfState<IsRelativistic, 2>& rhs) const override; 87 : 88 0 : WRAPPED_PUPable_decl_base_template( // NOLINT 89 : SINGLE_ARG(EquationOfState<IsRelativistic, 2>), IdealFluid); 90 : 91 : /// The lower bound of the rest mass density that is valid for this EOS 92 1 : double rest_mass_density_lower_bound() const override { return 0.0; } 93 : 94 : /// The upper bound of the rest mass density that is valid for this EOS 95 1 : double rest_mass_density_upper_bound() const override { 96 : return std::numeric_limits<double>::max(); 97 : } 98 : 99 : /// The lower bound of the specific internal energy that is valid for this EOS 100 : /// at the given rest mass density \f$\rho\f$ 101 1 : double specific_internal_energy_lower_bound( 102 : const double /* rest_mass_density */) const override { 103 : return 0.0; 104 : } 105 : 106 : /// The upper bound of the specific internal energy that is valid for this EOS 107 : /// at the given rest mass density \f$\rho\f$ 108 1 : double specific_internal_energy_upper_bound( 109 : double rest_mass_density) const override; 110 : 111 : /// The lower bound of the specific enthalpy that is valid for this EOS 112 1 : double specific_enthalpy_lower_bound() const override { 113 : return IsRelativistic ? 1.0 : 0.0; 114 : } 115 : 116 : /// The vacuum baryon mass for this EoS 117 1 : double baryon_mass() const override { 118 : return hydro::units::geometric::default_baryon_mass; 119 : } 120 : 121 : private: 122 : EQUATION_OF_STATE_FORWARD_DECLARE_MEMBER_IMPLS(2) 123 : 124 0 : double adiabatic_index_ = std::numeric_limits<double>::signaling_NaN(); 125 : }; 126 : 127 : /// \cond 128 : template <bool IsRelativistic> 129 : PUP::able::PUP_ID EquationsOfState::IdealFluid<IsRelativistic>::my_PUP_ID = 0; 130 : /// \endcond 131 : } // namespace EquationsOfState