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" 19 : #include "PointwiseFunctions/Hydro/EquationsOfState/Factory.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 a dark energy fluid 31 : * 32 : * A dark energy fluid equation of state: 33 : * 34 : * \f[ 35 : * p = w(z) \rho ( 1.0 + \epsilon) 36 : * \f] 37 : * 38 : * where \f$\rho\f$ is the rest mass density, \f$\epsilon\f$ is the specific 39 : * internal energy, and \f$w(z) > 0\f$ is a parameter depending on the redshift 40 : * \f$z\f$. 41 : * 42 : * The temperature \f$T\f$ is defined as 43 : * 44 : * \f[ 45 : * T = w(z) \epsilon 46 : * \f] 47 : */ 48 : template <bool IsRelativistic> 49 1 : class DarkEnergyFluid : public EquationOfState<IsRelativistic, 2> { 50 : public: 51 0 : static constexpr size_t thermodynamic_dim = 2; 52 0 : static constexpr bool is_relativistic = IsRelativistic; 53 : static_assert(is_relativistic, 54 : "Dark energy fluid equation of state only makes sense in a " 55 : "relativistic setting."); 56 : 57 0 : std::unique_ptr<EquationOfState<IsRelativistic, 2>> get_clone() 58 : const override; 59 : 60 0 : std::unique_ptr<EquationOfState<IsRelativistic, 3>> promote_to_3d_eos() 61 : const override; 62 : 63 0 : bool is_equal(const EquationOfState<IsRelativistic, 2>& rhs) const override; 64 : 65 : /// \brief Returns `true` if the EOS is barotropic 66 1 : bool is_barotropic() const override { return false; } 67 : 68 0 : bool operator==(const DarkEnergyFluid<IsRelativistic>& rhs) const; 69 : 70 0 : bool operator!=(const DarkEnergyFluid<IsRelativistic>& rhs) const; 71 : 72 0 : struct ParameterW { 73 0 : using type = double; 74 0 : static constexpr Options::String help = {"Parameter w(z)"}; 75 0 : static double lower_bound() { return 0.0; } 76 0 : static double upper_bound() { return 1.0; } 77 : }; 78 : 79 0 : static constexpr Options::String help = { 80 : "A dark energy fluid equation of state.\n" 81 : "The pressure is related to the rest mass density by " 82 : "p = w(z) * rho * (1 + epsilon), where p is the pressure, rho is the " 83 : "rest mass density, epsilon is the specific internal energy, and w(z) is " 84 : "a parameter.\n" 85 : "The temperature T is defined as T=w(z) epsilon."}; 86 : 87 0 : using options = tmpl::list<ParameterW>; 88 : 89 0 : DarkEnergyFluid() = default; 90 0 : DarkEnergyFluid(const DarkEnergyFluid&) = default; 91 0 : DarkEnergyFluid& operator=(const DarkEnergyFluid&) = default; 92 0 : DarkEnergyFluid(DarkEnergyFluid&&) = default; 93 0 : DarkEnergyFluid& operator=(DarkEnergyFluid&&) = default; 94 0 : ~DarkEnergyFluid() override = default; 95 : 96 0 : explicit DarkEnergyFluid(double parameter_w); 97 : 98 : EQUATION_OF_STATE_FORWARD_DECLARE_MEMBERS(DarkEnergyFluid, 2) 99 : 100 0 : WRAPPED_PUPable_decl_base_template( // NOLINT 101 : SINGLE_ARG(EquationOfState<IsRelativistic, 2>), DarkEnergyFluid); 102 : 103 : /// The lower bound of the rest mass density that is valid for this EOS 104 1 : double rest_mass_density_lower_bound() const override { return 0.0; } 105 : 106 : /// The upper bound of the rest mass density that is valid for this EOS 107 1 : double rest_mass_density_upper_bound() const override { 108 : return std::numeric_limits<double>::max(); 109 : } 110 : 111 : /// The lower bound of the specific internal energy that is valid for this EOS 112 : /// at the given rest mass density \f$\rho\f$ 113 1 : double specific_internal_energy_lower_bound( 114 : const double /* rest_mass_density */) const override { 115 : return -1.0; 116 : } 117 : 118 : /// The upper bound of the specific internal energy that is valid for this EOS 119 : /// at the given rest mass density \f$\rho\f$ 120 1 : double specific_internal_energy_upper_bound( 121 : const double /* rest_mass_density */) const override { 122 : return std::numeric_limits<double>::max(); 123 : } 124 : 125 : /// The lower bound of the specific enthalpy that is valid for this EOS 126 1 : double specific_enthalpy_lower_bound() const override { return 0.0; } 127 : 128 : private: 129 : EQUATION_OF_STATE_FORWARD_DECLARE_MEMBER_IMPLS(2) 130 : 131 0 : double parameter_w_ = std::numeric_limits<double>::signaling_NaN(); 132 : }; 133 : 134 : /// \cond 135 : template <bool IsRelativistic> 136 : PUP::able::PUP_ID EquationsOfState::DarkEnergyFluid<IsRelativistic>::my_PUP_ID = 137 : 0; 138 : /// \endcond 139 : } // namespace EquationsOfState