SpECTRE Documentation Coverage Report
Current view: top level - PointwiseFunctions/AnalyticData/GrMhd - MagnetizedTovStar.hpp Hit Total Coverage
Commit: 1f2210958b4f38fdc0400907ee7c6d5af5111418 Lines: 2 25 8.0 %
Date: 2025-12-05 05:03:31
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 <cstddef>
       7             : #include <limits>
       8             : 
       9             : #include "DataStructures/Tensor/TypeAliases.hpp"
      10             : #include "Options/String.hpp"
      11             : #include "PointwiseFunctions/AnalyticData/AnalyticData.hpp"
      12             : #include "PointwiseFunctions/AnalyticData/GrMhd/AnalyticData.hpp"
      13             : #include "PointwiseFunctions/AnalyticData/GrMhd/InitialMagneticFields/Factory.hpp"
      14             : #include "PointwiseFunctions/AnalyticData/GrMhd/InitialMagneticFields/InitialMagneticField.hpp"
      15             : #include "PointwiseFunctions/AnalyticSolutions/RelativisticEuler/TovStar.hpp"
      16             : #include "PointwiseFunctions/Hydro/EquationsOfState/Factory.hpp"
      17             : #include "PointwiseFunctions/Hydro/TagsDeclarations.hpp"
      18             : #include "PointwiseFunctions/InitialDataUtilities/InitialData.hpp"
      19             : #include "Utilities/Serialization/CharmPupable.hpp"
      20             : #include "Utilities/TMPL.hpp"
      21             : #include "Utilities/TaggedTuple.hpp"
      22             : 
      23             : /// \cond
      24             : namespace PUP {
      25             : class er;
      26             : }  // namespace PUP
      27             : /// \endcond
      28             : 
      29             : namespace grmhd::AnalyticData {
      30             : namespace magnetized_tov_detail {
      31             : 
      32             : using StarRegion = RelativisticEuler::Solutions::tov_detail::StarRegion;
      33             : 
      34             : template <typename DataType, StarRegion Region>
      35             : struct MagnetizedTovVariables
      36             :     : RelativisticEuler::Solutions::tov_detail::TovVariables<DataType, Region> {
      37             :   static constexpr size_t Dim = 3;
      38             :   using Base =
      39             :       RelativisticEuler::Solutions::tov_detail::TovVariables<DataType, Region>;
      40             :   using Cache = typename Base::Cache;
      41             :   using Base::operator();
      42             :   using Base::coords;
      43             :   using Base::eos;
      44             :   using Base::radial_solution;
      45             :   using Base::radius;
      46             : 
      47             :   const std::vector<std::unique_ptr<
      48             :       grmhd::AnalyticData::InitialMagneticFields::InitialMagneticField>>&
      49             :       magnetic_fields;
      50             : 
      51             :   MagnetizedTovVariables(
      52             :       const tnsr::I<DataType, 3>& local_x, const DataType& local_radius,
      53             :       const RelativisticEuler::Solutions::TovSolution& local_radial_solution,
      54             :       const EquationsOfState::EquationOfState<true, 1>& local_eos,
      55             :       const std::vector<std::unique_ptr<
      56             :           grmhd::AnalyticData::InitialMagneticFields::InitialMagneticField>>&
      57             :           mag_fields)
      58             :       : Base(local_x, local_radius, local_radial_solution, local_eos),
      59             :         magnetic_fields(mag_fields) {}
      60             : 
      61             :   void operator()(
      62             :       gsl::not_null<tnsr::I<DataType, 3>*> magnetic_field,
      63             :       gsl::not_null<Cache*> cache,
      64             :       hydro::Tags::MagneticField<DataType, 3> /*meta*/) const override;
      65             : };
      66             : 
      67             : }  // namespace magnetized_tov_detail
      68             : 
      69             : /*!
      70             :  * \brief Magnetized TOV star initial data, where metric terms only account for
      71             :  * the hydrodynamics not the magnetic fields.
      72             :  *
      73             :  * Superposes magnetic fields on top of a TOV solution. These can be any of
      74             :  * the classes derived from
      75             :  * grmhd::AnalyticData::InitialMagneticFields::InitialMagneticField
      76             :  *
      77             :  * ### Conversion to CGS units and values for poloidal magnetic field
      78             :  *
      79             :  * While the amplitude \f$A_b\f$ is specified in the code, it is more natural
      80             :  * to work with the magnetic field strength, which is given by \f$\sqrt{b^2}\f$
      81             :  * (where \f$b^a\f$ is the comoving magnetic field), and in CGS units is
      82             :  *
      83             :  * \f{align*}{
      84             :  *  |B_{\mathrm{CGS}}|&= \sqrt{4 \pi b^2}
      85             :  *   \left(\frac{c^2}{G M_\odot}\right) \left(\frac{c}{\sqrt{4 \pi \epsilon_0
      86             :  *    G}}\right) \\
      87             :  *   &= \sqrt{b^2} \times 8.352\times10^{19}\mathrm{G} \,.
      88             :  * \f}
      89             :  *
      90             :  * We now give values used for standard tests of magnetized stars with a
      91             :  * poloidal magnetic field.
      92             :  * - \f$\rho_c(0)=1.28\times10^{-3}\f$
      93             :  * - \f$K=100\f$
      94             :  * - \f$\Gamma=2\f$
      95             :  * - %Domain \f$[-20,20]^3\f$
      96             :  * - Units \f$M=M_\odot\f$
      97             :  * - A target final time 20ms means \f$20\times10^{-3}/(5\times10^{-6})=4000M\f$
      98             :  * - The mass of the star is \f$1.4M_{\odot}\f$
      99             :  *
     100             :  * Parameters for desired magnetic field strength:
     101             :  * - For \f$n_s=0\f$ and \f$p_{\mathrm{cut}}=0.04p_{\max}\f$ setting
     102             :  *   \f$A_b=6\times10^{-5}\f$ yields a maximum mganetic field strength of
     103             :  *   \f$1.002\times10^{16}G\f$.
     104             :  * - For \f$n_s=1\f$ and \f$p_{\mathrm{cut}}=0.04p_{\max}\f$ setting
     105             :  *   \f$A_b=0.4\f$ yields a maximum mganetic field strength of
     106             :  *   \f$1.05\times10^{16}G\f$.
     107             :  * - For \f$n_s=2\f$ and \f$p_{\mathrm{cut}}=0.04p_{\max}\f$ setting
     108             :  *   \f$A_b=2500\f$ yields a maximum mganetic field strength of
     109             :  *   \f$1.03\times10^{16}G\f$.
     110             :  * - For \f$n_s=3\f$ and \f$p_{\mathrm{cut}}=0.04p_{\max}\f$ setting
     111             :  *   \f$A_b=1.65\times10^{7}\f$ yields a maximum mganetic field strength of
     112             :  *   \f$1.07\times10^{16}G\f$.
     113             :  *
     114             :  * Note that the magnetic field strength goes as \f$A_b\f$ so any desired value
     115             :  * can be achieved by a linear scaling.
     116             :  */
     117           1 : class MagnetizedTovStar : public virtual evolution::initial_data::InitialData,
     118             :                           public MarkAsAnalyticData,
     119             :                           private RelativisticEuler::Solutions::TovStar {
     120             :  private:
     121           0 :   using tov_star = RelativisticEuler::Solutions::TovStar;
     122             : 
     123             :  public:
     124           0 :   struct MagneticFields {
     125           0 :     using type = std::vector<std::unique_ptr<
     126             :         grmhd::AnalyticData::InitialMagneticFields::InitialMagneticField>>;
     127           0 :     static constexpr Options::String help = {
     128             :         "Magnetic fields to superpose on the TOV solution."};
     129             :   };
     130             : 
     131           0 :   using options = tmpl::push_back<tov_star::options, MagneticFields>;
     132             : 
     133           0 :   static constexpr Options::String help = {"Magnetized TOV star."};
     134             : 
     135           0 :   static constexpr size_t volume_dim = 3_st;
     136             : 
     137             :   template <typename DataType>
     138           0 :   using tags = typename tov_star::template tags<DataType>;
     139             : 
     140           0 :   MagnetizedTovStar();
     141           0 :   MagnetizedTovStar(const MagnetizedTovStar& rhs);
     142           0 :   MagnetizedTovStar& operator=(const MagnetizedTovStar& rhs);
     143           0 :   MagnetizedTovStar(MagnetizedTovStar&& /*rhs*/);
     144           0 :   MagnetizedTovStar& operator=(MagnetizedTovStar&& /*rhs*/);
     145           0 :   ~MagnetizedTovStar() override;
     146             : 
     147           0 :   MagnetizedTovStar(
     148             :       double central_rest_mass_density,
     149             :       std::unique_ptr<EquationsOfState::EquationOfState<true, 1>>
     150             :           equation_of_state,
     151             :       RelativisticEuler::Solutions::TovCoordinates coordinate_system,
     152             :       std::vector<std::unique_ptr<
     153             :           grmhd::AnalyticData::InitialMagneticFields::InitialMagneticField>>
     154             :           magnetic_fields);
     155             : 
     156           0 :   auto get_clone() const
     157             :       -> std::unique_ptr<evolution::initial_data::InitialData> override;
     158             : 
     159             :   /// \cond
     160             :   explicit MagnetizedTovStar(CkMigrateMessage* msg);
     161             :   using PUP::able::register_constructor;
     162             :   WRAPPED_PUPable_decl_template(MagnetizedTovStar);
     163             :   /// \endcond
     164             : 
     165           0 :   using tov_star::equation_of_state;
     166           0 :   using tov_star::equation_of_state_type;
     167             : 
     168             :   /// Retrieve a collection of variables at `(x)`
     169             :   template <typename DataType, typename... Tags>
     170           1 :   tuples::TaggedTuple<Tags...> variables(const tnsr::I<DataType, 3>& x,
     171             :                                          tmpl::list<Tags...> /*meta*/) const {
     172             :     return variables_impl<magnetized_tov_detail::MagnetizedTovVariables>(
     173             :         x, tmpl::list<Tags...>{}, magnetic_fields_);
     174             :   }
     175             : 
     176             :   // NOLINTNEXTLINE(google-runtime-references)
     177           0 :   void pup(PUP::er& p) override;
     178             : 
     179             :  private:
     180           0 :   friend bool operator==(const MagnetizedTovStar& lhs,
     181             :                          const MagnetizedTovStar& rhs);
     182             : 
     183             :  protected:
     184             :   std::vector<std::unique_ptr<
     185             :       grmhd::AnalyticData::InitialMagneticFields::InitialMagneticField>>
     186           0 :       magnetic_fields_{};
     187             : };
     188             : 
     189           0 : bool operator!=(const MagnetizedTovStar& lhs, const MagnetizedTovStar& rhs);
     190             : }  // namespace grmhd::AnalyticData

Generated by: LCOV version 1.14