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 <cstddef> 14 : #include <limits> 15 : #include <memory> 16 : #include <pup.h> 17 : 18 : #include "DataStructures/Tensor/TypeAliases.hpp" 19 : #include "Options/String.hpp" 20 : #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp" 21 : #include "PointwiseFunctions/Hydro/Units.hpp" 22 : #include "Utilities/Serialization/CharmPupable.hpp" 23 : #include "Utilities/TMPL.hpp" 24 : 25 : namespace EquationsOfState { 26 : /*! 27 : * \ingroup EquationsOfStateGroup 28 : * \brief A 3D equation of state representing a barotropic fluid. 29 : * 30 : * 31 : * The equation of state takes the form 32 : * 33 : * \f[ 34 : * p = p (\rho , T, Y_e) = p(\rho, 0, Y_e= Y_{e, \beta}) 35 : * \f] 36 : * 37 : * where \f$\rho\f$ is the rest mass density, \f$T\f$ the 38 : * temperature , and \f$Y_e\f$ the electron fraction. The temperature and 39 : * electron fraction are not used, so evaluating this EoS at any arbtirary 40 : * temeperature or electron fraction is equivalent to evaluating it at 41 : * zero temperature and in beta equalibrium. 42 : */ 43 : template <typename ColdEquilEos> 44 1 : class Barotropic3D : public EquationOfState<ColdEquilEos::is_relativistic, 3> { 45 : public: 46 0 : static constexpr size_t thermodynamic_dim = 3; 47 0 : static constexpr bool is_relativistic = ColdEquilEos::is_relativistic; 48 : 49 0 : static std::string name() { 50 : return "Barotropic3D(" + pretty_type::name<ColdEquilEos>() + ")"; 51 : } 52 0 : static constexpr Options::String help = { 53 : "An 3D EoS which is independent of electron fraction and temperature. " 54 : "Contains an underlying 1D EoS which is dependent only " 55 : "on rest mass density."}; 56 0 : struct UnderlyingEos { 57 0 : using type = ColdEquilEos; 58 0 : static std::string name() { 59 : return pretty_type::short_name<ColdEquilEos>(); 60 : } 61 0 : static constexpr Options::String help{ 62 : "The underlying Eos which is being represented as a " 63 : "3D Eos. Must be a 1D EoS"}; 64 : }; 65 : 66 0 : using options = tmpl::list<UnderlyingEos>; 67 : 68 0 : Barotropic3D() = default; 69 0 : Barotropic3D(const Barotropic3D&) = default; 70 0 : Barotropic3D& operator=(const Barotropic3D&) = default; 71 0 : Barotropic3D(Barotropic3D&&) = default; 72 0 : Barotropic3D& operator=(Barotropic3D&&) = default; 73 0 : ~Barotropic3D() override = default; 74 : 75 0 : explicit Barotropic3D(const ColdEquilEos& underlying_eos) 76 : : underlying_eos_(underlying_eos){}; 77 : 78 : EQUATION_OF_STATE_FORWARD_DECLARE_MEMBERS(Barotropic3D, 3) 79 : 80 0 : std::unique_ptr<EquationOfState<ColdEquilEos::is_relativistic, 3>> get_clone() 81 : const override; 82 : 83 0 : bool is_equal(const EquationOfState<ColdEquilEos::is_relativistic, 3>& rhs) 84 : const override; 85 : 86 : /// \brief Returns `true` if the EOS is barotropic 87 1 : bool is_barotropic() const override { return true; } 88 : 89 0 : bool operator==(const Barotropic3D<ColdEquilEos>& rhs) const; 90 : 91 0 : bool operator!=(const Barotropic3D<ColdEquilEos>& rhs) const; 92 : /// @{ 93 : /*! 94 : * Computes the electron fraction in beta-equilibrium \f$Y_e^{\rm eq}\f$ from 95 : * the rest mass density \f$\rho\f$ and the temperature \f$T\f$. 96 : */ 97 1 : Scalar<double> equilibrium_electron_fraction_from_density_temperature( 98 : const Scalar<double>& rest_mass_density, 99 : const Scalar<double>& temperature) const { 100 : return underlying_eos_ 101 : .equilibrium_electron_fraction_from_density_temperature( 102 : rest_mass_density, temperature); 103 : } 104 : 105 1 : Scalar<DataVector> equilibrium_electron_fraction_from_density_temperature( 106 : const Scalar<DataVector>& rest_mass_density, 107 : const Scalar<DataVector>& temperature) const { 108 : return underlying_eos_ 109 : .equilibrium_electron_fraction_from_density_temperature( 110 : rest_mass_density, temperature); 111 : } 112 : /// @} 113 : // 114 : 115 0 : WRAPPED_PUPable_decl_base_template( // NOLINT 116 : SINGLE_ARG(EquationOfState<ColdEquilEos::is_relativistic, 3>), 117 : Barotropic3D); 118 : 119 : /// The lower bound of the electron fraction that is valid for this EOS 120 1 : double electron_fraction_lower_bound() const override { return 0.0; } 121 : 122 : /// The upper bound of the electron fraction that is valid for this EOS 123 1 : double electron_fraction_upper_bound() const override { return 1.0; } 124 : 125 : /// The lower bound of the rest mass density that is valid for this EOS 126 1 : double rest_mass_density_lower_bound() const override { 127 : return underlying_eos_.rest_mass_density_lower_bound(); 128 : } 129 : 130 : /// The upper bound of the rest mass density that is valid for this EOS 131 1 : double rest_mass_density_upper_bound() const override { 132 : return underlying_eos_.rest_mass_density_upper_bound(); 133 : } 134 : 135 : /// The lower bound of the temperature that is valid for this EOS 136 1 : double temperature_lower_bound() const override { return 0.0; } 137 : 138 : /// The upper bound of the temperature that is valid for this EOS 139 1 : double temperature_upper_bound() const override { 140 : return std::numeric_limits<double>::max(); 141 : } 142 : 143 : /// The lower bound of the specific internal energy that is valid for this EOS 144 : /// at the given rest mass density \f$\rho\f$ and electron fraction \f$Y_e\f$ 145 1 : double specific_internal_energy_lower_bound( 146 : const double rest_mass_density, 147 : const double /*electron_fraction*/) const override { 148 : return underlying_eos_.specific_internal_energy_lower_bound( 149 : rest_mass_density); 150 : } 151 : 152 : /// The upper bound of the specific internal energy that is valid for this EOS 153 : /// at the given rest mass density \f$\rho\f$ 154 1 : double specific_internal_energy_upper_bound( 155 : const double rest_mass_density, 156 : const double /*electron_fraction*/) const override { 157 : return underlying_eos_.specific_internal_energy_upper_bound( 158 : rest_mass_density); 159 : } 160 : 161 : /// The lower bound of the specific enthalpy that is valid for this EOS 162 1 : double specific_enthalpy_lower_bound() const override { 163 : return underlying_eos_.specific_enthalpy_lower_bound(); 164 : } 165 : 166 : /// The baryon mass for this EoS 167 1 : double baryon_mass() const override { return underlying_eos_.baryon_mass(); } 168 : 169 : private: 170 : EQUATION_OF_STATE_FORWARD_DECLARE_MEMBER_IMPLS(3) 171 0 : ColdEquilEos underlying_eos_; 172 : }; 173 : /// \cond 174 : template <typename ColdEquilEos> 175 : PUP::able::PUP_ID EquationsOfState::Barotropic3D<ColdEquilEos>::my_PUP_ID = 0; 176 : /// \endcond 177 : } // namespace EquationsOfState