SpECTRE Documentation Coverage Report
Current view: top level - PointwiseFunctions/Hydro/EquationsOfState - Barotropic3D.hpp Hit Total Coverage
Commit: 3528f39684ab2ee5d689cee48331779e729b0a07 Lines: 14 37 37.8 %
Date: 2024-02-27 07:22:14
Legend: Lines: hit not hit

          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           1 : 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 (T, rho, Y_e) = p(0, rho, Y_e= Y_{e, \beta})
      35             :  * \f]
      36             :  *
      37             :  * where \f$\rho\f$ is the rest mass density, \f$T\f$  the
      38             :  * temperatur , and \f$Y_e\f$ is the electron fraction are not
      39             :  * used, and therefore this evaluating this EoS at any arbtirary
      40             :  * temeperature or electron fraction is equivalent to evaluating it at
      41             :  * temperature 0 and in beta equalibrium
      42             :  *
      43             :  */
      44             : template <typename ColdEquilEos>
      45           1 : class Barotropic3D : public EquationOfState<ColdEquilEos::is_relativistic, 3> {
      46             :  public:
      47           0 :   static constexpr size_t thermodynamic_dim = 3;
      48           0 :   static constexpr bool is_relativistic = ColdEquilEos::is_relativistic;
      49             : 
      50           0 :   static std::string name() {
      51             :     return "Barotropic3D(" + pretty_type::name<ColdEquilEos>() + ")";
      52             :   }
      53           0 :   static constexpr Options::String help = {
      54             :       "An 3D EoS which is independent of electron fraction and temperature. "
      55             :       "Contains an underlying 1D EoS which is dependent only "
      56             :       "on rest mass density."};
      57           0 :   struct UnderlyingEos {
      58           0 :     using type = ColdEquilEos;
      59           0 :     static std::string name() {
      60             :       return pretty_type::short_name<ColdEquilEos>();
      61             :     }
      62           0 :     static constexpr Options::String help{
      63             :         "The underlying Eos which is being represented as a "
      64             :         "3D Eos.  Must be a 1D EoS"};
      65             :   };
      66             : 
      67           0 :   using options = tmpl::list<UnderlyingEos>;
      68             : 
      69           0 :   Barotropic3D() = default;
      70           0 :   Barotropic3D(const Barotropic3D&) = default;
      71           0 :   Barotropic3D& operator=(const Barotropic3D&) = default;
      72           0 :   Barotropic3D(Barotropic3D&&) = default;
      73           0 :   Barotropic3D& operator=(Barotropic3D&&) = default;
      74           0 :   ~Barotropic3D() override = default;
      75             : 
      76           0 :   explicit Barotropic3D(const ColdEquilEos& underlying_eos)
      77             :       : underlying_eos_(underlying_eos){};
      78             : 
      79             :   EQUATION_OF_STATE_FORWARD_DECLARE_MEMBERS(Barotropic3D, 3)
      80             : 
      81           0 :   std::unique_ptr<EquationOfState<ColdEquilEos::is_relativistic, 3>> get_clone()
      82             :       const override;
      83             : 
      84           0 :   bool is_equal(const EquationOfState<ColdEquilEos::is_relativistic, 3>& rhs)
      85             :       const override;
      86             : 
      87           0 :   bool operator==(const Barotropic3D<ColdEquilEos>& rhs) const;
      88             : 
      89           0 :   bool operator!=(const Barotropic3D<ColdEquilEos>& rhs) const;
      90             :   /// @{
      91             :   /*!
      92             :    * Computes the electron fraction in beta-equilibrium \f$Y_e^{\rm eq}\f$ from
      93             :    * the rest mass density \f$\rho\f$ and the temperature \f$T\f$.
      94             :    */
      95           1 :   Scalar<double> equilibrium_electron_fraction_from_density_temperature(
      96             :       const Scalar<double>& rest_mass_density,
      97             :       const Scalar<double>& temperature) const {
      98             :     return underlying_eos_
      99             :         .equilibrium_electron_fraction_from_density_temperature(
     100             :             rest_mass_density, temperature);
     101             :   }
     102             : 
     103           1 :   Scalar<DataVector> equilibrium_electron_fraction_from_density_temperature(
     104             :       const Scalar<DataVector>& rest_mass_density,
     105             :       const Scalar<DataVector>& temperature) const {
     106             :     return underlying_eos_
     107             :         .equilibrium_electron_fraction_from_density_temperature(
     108             :             rest_mass_density, temperature);
     109             :   }
     110             :   /// @}
     111             :   //
     112             : 
     113           0 :   WRAPPED_PUPable_decl_base_template(  // NOLINT
     114             :       SINGLE_ARG(EquationOfState<ColdEquilEos::is_relativistic, 3>),
     115             :       Barotropic3D);
     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 { return 0.0; }
     135             : 
     136             :   /// The upper bound of the temperature that is valid for this EOS
     137           1 :   double temperature_upper_bound() const override {
     138             :     return std::numeric_limits<double>::max();
     139             :   }
     140             : 
     141             :   /// The lower bound of the specific internal energy that is valid for this EOS
     142             :   /// at the given rest mass density \f$\rho\f$ and electron fraction \f$Y_e\f$
     143           1 :   double specific_internal_energy_lower_bound(
     144             :       const double rest_mass_density,
     145             :       const double /*electron_fraction*/) const override {
     146             :     return underlying_eos_.specific_internal_energy_lower_bound(
     147             :         rest_mass_density);
     148             :   }
     149             : 
     150             :   /// The upper bound of the specific internal energy that is valid for this EOS
     151             :   /// at the given rest mass density \f$\rho\f$
     152           1 :   double specific_internal_energy_upper_bound(
     153             :       const double rest_mass_density,
     154             :       const double /*electron_fraction*/) const override {
     155             :     return underlying_eos_.specific_internal_energy_upper_bound(
     156             :         rest_mass_density);
     157             :   }
     158             : 
     159             :   /// The lower bound of the specific enthalpy that is valid for this EOS
     160           1 :   double specific_enthalpy_lower_bound() const override {
     161             :     return underlying_eos_.specific_enthalpy_lower_bound();
     162             :   }
     163             : 
     164             :   /// The baryon mass for this EoS
     165           1 :   double baryon_mass() const override { return underlying_eos_.baryon_mass(); }
     166             : 
     167             :  private:
     168             :   EQUATION_OF_STATE_FORWARD_DECLARE_MEMBER_IMPLS(3)
     169           0 :   ColdEquilEos underlying_eos_;
     170             : };
     171             : /// \cond
     172             : template <typename ColdEquilEos>
     173             : PUP::able::PUP_ID EquationsOfState::Barotropic3D<ColdEquilEos>::my_PUP_ID = 0;
     174             : /// \endcond
     175             : }  // namespace EquationsOfState

Generated by: LCOV version 1.14