SpECTRE Documentation Coverage Report
Current view: top level - PointwiseFunctions/Hydro/EquationsOfState - HybridEos.hpp Hit Total Coverage
Commit: 564b2bd90a7e43d32cb2e38987bb2b60e7971b1c Lines: 6 31 19.4 %
Date: 2022-10-05 15:45:23
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 <pup.h>
      16             : 
      17             : #include "DataStructures/Tensor/TypeAliases.hpp"
      18             : #include "Options/Options.hpp"
      19             : #include "Parallel/CharmPupable.hpp"
      20             : #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp"
      21             : #include "Utilities/TMPL.hpp"
      22             : 
      23             : /// \cond
      24             : class DataVector;
      25             : /// \endcond
      26             : 
      27             : namespace EquationsOfState {
      28             : /*!
      29             :  * \ingroup EquationsOfStateGroup
      30             :  *
      31             :  * \brief Hybrid equation of state combining a barotropic EOS for cold
      32             :  * (zero-temperature) part with a simple thermal part
      33             :  *
      34             :  * The hybrid equation of state:
      35             :  *
      36             :  * \f[
      37             :  * p = p_{cold}(\rho) + \rho (\Gamma_{th}-1) (\epsilon - \epsilon_{cold}(\rho))
      38             :  * \f]
      39             :  *
      40             :  * where \f$p\f$ is the pressure, \f$\rho\f$ is the rest mass density,
      41             :  * \f$\epsilon\f$ is the specific internal energy, \f$p_{cold}\f$ and
      42             :  * \f$\epsilon_{cold}\f$ are the pressure and specific internal energy evaluated
      43             :  * using the cold EOS, and \f$\Gamma_{th}\f$ is the adiabatic index for the
      44             :  * thermal part.
      45             :  *
      46             :  * The temperature \f$T\f$ is defined as
      47             :  *
      48             :  * \f[
      49             :  * T = (\Gamma_{th} - 1) (\epsilon - \epsilon_{cold})
      50             :  * \f]
      51             :  */
      52             : template <typename ColdEquationOfState>
      53           1 : class HybridEos
      54             :     : public EquationOfState<ColdEquationOfState::is_relativistic, 2> {
      55             :  public:
      56           0 :   static constexpr size_t thermodynamic_dim = 2;
      57           0 :   static constexpr bool is_relativistic = ColdEquationOfState::is_relativistic;
      58             : 
      59           0 :   struct ColdEos {
      60           0 :     using type = ColdEquationOfState;
      61           0 :     static constexpr Options::String help = {"Cold equation of state"};
      62             :   };
      63             : 
      64           0 :   struct ThermalAdiabaticIndex {
      65           0 :     using type = double;
      66           0 :     static constexpr Options::String help = {"Adiabatic index Gamma_th"};
      67             :   };
      68             : 
      69           0 :   static constexpr Options::String help = {
      70             :       "A hybrid equation of state combining a cold EOS with a simple thermal "
      71             :       "part.  The pressure is related to the rest mass density by "
      72             :       " p = p_cold(rho) + rho * (Gamma_th - 1) * (epsilon - "
      73             :       "epsilon_cold(rho)), where p is the pressure, rho is the rest mass "
      74             :       "density, epsilon is the specific internal energy, p_cold and "
      75             :       "epsilon_cold are the pressure and specific internal energy evaluated "
      76             :       "using the cold EOS and Gamma_th is the adiabatic index for the thermal "
      77             :       "part."};
      78             : 
      79           0 :   using options = tmpl::list<ColdEos, ThermalAdiabaticIndex>;
      80             : 
      81           0 :   HybridEos() = default;
      82           0 :   HybridEos(const HybridEos&) = default;
      83           0 :   HybridEos& operator=(const HybridEos&) = default;
      84           0 :   HybridEos(HybridEos&&) = default;
      85           0 :   HybridEos& operator=(HybridEos&&) = default;
      86           0 :   ~HybridEos() override = default;
      87             : 
      88           0 :   HybridEos(ColdEquationOfState cold_eos, double thermal_adiabatic_index);
      89             : 
      90             :   EQUATION_OF_STATE_FORWARD_DECLARE_MEMBERS(HybridEos, 2)
      91             : 
      92           0 :   WRAPPED_PUPable_decl_base_template(  // NOLINT
      93             :       SINGLE_ARG(EquationOfState<is_relativistic, 2>), HybridEos);
      94             : 
      95           0 :   std::unique_ptr<EquationOfState<is_relativistic, 2>> get_clone()
      96             :       const override;
      97             : 
      98           0 :   bool operator==(const HybridEos<ColdEquationOfState>& rhs) const;
      99             : 
     100           0 :   bool operator!=(const HybridEos<ColdEquationOfState>& rhs) const;
     101             : 
     102           0 :   bool is_equal(const EquationOfState<is_relativistic, 2>& rhs) const override;
     103             : 
     104             :   /// The lower bound of the rest mass density that is valid for this EOS
     105           1 :   double rest_mass_density_lower_bound() const override {
     106             :     return cold_eos_.rest_mass_density_lower_bound();
     107             :   }
     108             : 
     109             :   /// The upper bound of the rest mass density that is valid for this EOS
     110           1 :   double rest_mass_density_upper_bound() const override {
     111             :     return cold_eos_.rest_mass_density_upper_bound();
     112             :   }
     113             : 
     114             :   /// The lower bound of the specific internal energy that is valid for this EOS
     115             :   /// at the given rest mass density \f$\rho\f$
     116           1 :   double specific_internal_energy_lower_bound(
     117             :       const double rest_mass_density) const override {
     118             :     return cold_eos_.specific_internal_energy_lower_bound(rest_mass_density);
     119             :   }
     120             : 
     121             :   /// The upper bound of the specific internal energy that is valid for this EOS
     122             :   /// at the given rest mass density \f$\rho\f$
     123           1 :   double specific_internal_energy_upper_bound(
     124             :       const double /*rest_mass_density*/) const override {
     125             :     return std::numeric_limits<double>::max();
     126             :   }
     127             : 
     128             :   /// The lower bound of the specific enthalpy that is valid for this EOS
     129           1 :   double specific_enthalpy_lower_bound() const override {
     130             :     return cold_eos_.specific_enthalpy_lower_bound();
     131             :   }
     132             : 
     133             :  private:
     134             :   EQUATION_OF_STATE_FORWARD_DECLARE_MEMBER_IMPLS(2)
     135             : 
     136           0 :   ColdEquationOfState cold_eos_;
     137           0 :   double thermal_adiabatic_index_ =
     138             :       std::numeric_limits<double>::signaling_NaN();
     139             : };
     140             : 
     141             : /// \cond
     142             : template <typename ColdEquationOfState>
     143             : PUP::able::PUP_ID EquationsOfState::HybridEos<ColdEquationOfState>::my_PUP_ID =
     144             :     0;
     145             : /// \endcond
     146             : }  // namespace EquationsOfState

Generated by: LCOV version 1.14