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 : // IWYU pragma: no_forward_declare Tensor 28 : 29 : namespace EquationsOfState { 30 : /*! 31 : * \ingroup EquationsOfStateGroup 32 : * \brief Equation of state for a polytropic fluid 33 : * 34 : * A polytropic equation of state \f$p=K\rho^{\Gamma}\f$ where \f$K\f$ is the 35 : * polytropic constant and \f$\Gamma\f$ is the polytropic exponent. The 36 : * polytropic exponent is related to the polytropic index \f$N_p\f$ by 37 : * \f$N_p=1/(\Gamma-1)\f$. 38 : */ 39 : template <bool IsRelativistic> 40 1 : class PolytropicFluid : public EquationOfState<IsRelativistic, 1> { 41 : public: 42 0 : static constexpr size_t thermodynamic_dim = 1; 43 0 : static constexpr bool is_relativistic = IsRelativistic; 44 : 45 0 : struct PolytropicConstant { 46 0 : using type = double; 47 0 : static constexpr Options::String help = {"Polytropic constant K"}; 48 0 : static double lower_bound() { return 0.0; } 49 : }; 50 : 51 0 : struct PolytropicExponent { 52 0 : using type = double; 53 0 : static constexpr Options::String help = {"Polytropic exponent Gamma"}; 54 0 : static double lower_bound() { return 1.0; } 55 : }; 56 : 57 0 : static constexpr Options::String help = { 58 : "A polytropic fluid equation of state.\n" 59 : "The pressure is related to the rest mass density by p = K rho ^ Gamma, " 60 : "where p is the pressure, rho is the rest mass density, K is the " 61 : "polytropic constant, and Gamma is the polytropic exponent. The " 62 : "polytropic index N is defined as Gamma = 1 + 1 / N."}; 63 : 64 0 : using options = tmpl::list<PolytropicConstant, PolytropicExponent>; 65 : 66 0 : PolytropicFluid() = default; 67 0 : PolytropicFluid(const PolytropicFluid&) = default; 68 0 : PolytropicFluid& operator=(const PolytropicFluid&) = default; 69 0 : PolytropicFluid(PolytropicFluid&&) = default; 70 0 : PolytropicFluid& operator=(PolytropicFluid&&) = default; 71 0 : ~PolytropicFluid() override = default; 72 : 73 0 : PolytropicFluid(double polytropic_constant, double polytropic_exponent); 74 : 75 0 : std::unique_ptr<EquationOfState<IsRelativistic, 1>> get_clone() 76 : const override; 77 : 78 1 : std::unique_ptr<EquationOfState<IsRelativistic, 3>> promote_to_3d_eos() 79 : const override; 80 : 81 1 : std::unique_ptr<EquationOfState<IsRelativistic, 2>> promote_to_2d_eos() 82 : const override; 83 : 84 0 : bool is_equal(const EquationOfState<IsRelativistic, 1>& rhs) const override; 85 : 86 0 : bool operator==(const PolytropicFluid<IsRelativistic>& rhs) const; 87 : 88 0 : bool operator!=(const PolytropicFluid<IsRelativistic>& rhs) const; 89 : 90 : EQUATION_OF_STATE_FORWARD_DECLARE_MEMBERS(PolytropicFluid, 1) 91 : 92 0 : WRAPPED_PUPable_decl_base_template( // NOLINT 93 : SINGLE_ARG(EquationOfState<IsRelativistic, 1>), PolytropicFluid); 94 : 95 : /// The lower bound of the rest mass density that is valid for this EOS 96 1 : double rest_mass_density_lower_bound() const override { return 0.0; } 97 : 98 : /// The upper bound of the rest mass density that is valid for this EOS 99 1 : double rest_mass_density_upper_bound() const override; 100 : 101 : /// The lower bound of the specific internal energy that is valid for this EOS 102 : /// at the given rest mass density \f$\rho\f$ 103 1 : double specific_internal_energy_lower_bound( 104 : const double /* rest_mass_density */) const override { 105 : return 0.0; 106 : } 107 : 108 : /// The upper bound of the specific internal energy that is valid for this EOS 109 : /// at the given rest mass density \f$\rho\f$ 110 1 : double specific_internal_energy_upper_bound( 111 : const double /* rest_mass_density */) const override { 112 : return std::numeric_limits<double>::max(); 113 : } 114 : 115 : /// The lower bound of the specific enthalpy that is valid for this EOS 116 1 : double specific_enthalpy_lower_bound() const override { 117 : return IsRelativistic ? 1.0 : 0.0; 118 : } 119 : 120 : /// The vacuum baryon mass for this EoS 121 1 : double baryon_mass() const override { 122 : return hydro::units::geometric::default_baryon_mass; 123 : } 124 : 125 : private: 126 : EQUATION_OF_STATE_FORWARD_DECLARE_MEMBER_IMPLS(1) 127 : 128 0 : double polytropic_constant_ = std::numeric_limits<double>::signaling_NaN(); 129 0 : double polytropic_exponent_ = std::numeric_limits<double>::signaling_NaN(); 130 : }; 131 : 132 : /// \cond 133 : template <bool IsRelativistic> 134 : PUP::able::PUP_ID EquationsOfState::PolytropicFluid<IsRelativistic>::my_PUP_ID = 135 : 0; 136 : /// \endcond 137 : } // namespace EquationsOfState