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 fluid in compositional 29 : * equalibrium. 30 : * 31 : * 32 : * The equation of state takes the form 33 : * 34 : * \f[ 35 : * p = p (T, rho, Y_e) = p(T, rho, Y_e= Y_{e, \beta}) 36 : * \f] 37 : * 38 : * where \f$\rho\f$ is the rest mass density and \f$T\f$ is the 39 : * temperaturee; \f$Y_e\f$ the electron fraction, is not 40 : * used, and therefore this evaluating this EoS at any arbtirary 41 : * electron fraction is equivalent to evaluating it in beta equalibrium 42 : * 43 : */ 44 : template <typename EquilEos> 45 1 : class Equilibrium3D : public EquationOfState<EquilEos::is_relativistic, 3> { 46 : public: 47 0 : static constexpr size_t thermodynamic_dim = 3; 48 0 : static constexpr bool is_relativistic = EquilEos::is_relativistic; 49 0 : static std::string name() { 50 : return "Equilibrium3D(" + pretty_type::name<EquilEos>() + ")"; 51 : } 52 0 : static constexpr Options::String help = { 53 : "An 3D EoS which is independent of electron fraction. " 54 : "Contains an underlying 2D EoS which is dependent only " 55 : "on rest mass density and temperature/internal energy."}; 56 : 57 0 : struct UnderlyingEos { 58 0 : using type = EquilEos; 59 0 : static std::string name() { return pretty_type::short_name<EquilEos>(); } 60 0 : static constexpr Options::String help{ 61 : "The underlying Eos which is being represented as a " 62 : "3D Eos. Must be a 2D EoS"}; 63 : }; 64 : 65 0 : using options = tmpl::list<UnderlyingEos>; 66 : 67 0 : Equilibrium3D() = default; 68 0 : Equilibrium3D(const Equilibrium3D&) = default; 69 0 : Equilibrium3D& operator=(const Equilibrium3D&) = default; 70 0 : Equilibrium3D(Equilibrium3D&&) = default; 71 0 : Equilibrium3D& operator=(Equilibrium3D&&) = default; 72 0 : ~Equilibrium3D() override = default; 73 : 74 0 : explicit Equilibrium3D(const EquilEos& underlying_eos) 75 : : underlying_eos_(underlying_eos){}; 76 : 77 : EQUATION_OF_STATE_FORWARD_DECLARE_MEMBERS(Equilibrium3D, 3) 78 : 79 0 : std::unique_ptr<EquationOfState<EquilEos::is_relativistic, 3>> get_clone() 80 : const override; 81 : 82 0 : bool is_equal( 83 : const EquationOfState<EquilEos::is_relativistic, 3>& rhs) const override; 84 : 85 : /// \brief Returns `true` if the EOS is barotropic 86 1 : bool is_barotropic() const override { return false; } 87 : 88 0 : bool operator==(const Equilibrium3D<EquilEos>& rhs) const; 89 : 90 0 : bool operator!=(const Equilibrium3D<EquilEos>& rhs) const; 91 : /// @{ 92 : /*! 93 : * Computes the electron fraction in beta-equilibrium \f$Y_e^{\rm eq}\f$ from 94 : * the rest mass density \f$\rho\f$ and the temperature \f$T\f$. 95 : */ 96 1 : Scalar<double> equilibrium_electron_fraction_from_density_temperature( 97 : const Scalar<double>& rest_mass_density, 98 : const Scalar<double>& temperature) const { 99 : return underlying_eos_ 100 : .equilibrium_electron_fraction_from_density_temperature( 101 : rest_mass_density, temperature); 102 : } 103 : 104 1 : Scalar<DataVector> equilibrium_electron_fraction_from_density_temperature( 105 : const Scalar<DataVector>& rest_mass_density, 106 : const Scalar<DataVector>& temperature) const { 107 : return underlying_eos_ 108 : .equilibrium_electron_fraction_from_density_temperature( 109 : rest_mass_density, temperature); 110 : } 111 : /// @} 112 : // 113 : 114 0 : WRAPPED_PUPable_decl_base_template( // NOLINT 115 : SINGLE_ARG(EquationOfState<EquilEos::is_relativistic, 3>), Equilibrium3D); 116 : 117 : /// The lower bound of the electron fraction that is valid for this EOS 118 1 : double electron_fraction_lower_bound() const override { return 0.0; } 119 : 120 : /// The upper bound of the electron fraction that is valid for this EOS 121 1 : double electron_fraction_upper_bound() const override { return 1.0; } 122 : 123 : /// The lower bound of the rest mass density that is valid for this EOS 124 1 : double rest_mass_density_lower_bound() const override { 125 : return underlying_eos_.rest_mass_density_lower_bound(); 126 : } 127 : 128 : /// The upper bound of the rest mass density that is valid for this EOS 129 1 : double rest_mass_density_upper_bound() const override { 130 : return underlying_eos_.rest_mass_density_upper_bound(); 131 : } 132 : 133 : /// The lower bound of the temperature that is valid for this EOS 134 1 : double temperature_lower_bound() const override { 135 : return underlying_eos_.temperature_lower_bound(); 136 : } 137 : 138 : /// The upper bound of the temperature that is valid for this EOS 139 1 : double temperature_upper_bound() const override { 140 : return underlying_eos_.temperature_upper_bound(); 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 : EquilEos underlying_eos_; 172 : }; 173 : /// \cond 174 : template <typename EquilEos> 175 : PUP::able::PUP_ID EquationsOfState::Equilibrium3D<EquilEos>::my_PUP_ID = 0; 176 : /// \endcond 177 : } // namespace EquationsOfState