Tov.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <limits>
7 #include <memory>
8 
10 #include "NumericalAlgorithms/Interpolation/BarycentricRational.hpp"
11 #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp" // IWYU pragma: keep
12 
13 /// \cond
14 namespace PUP {
15 class er;
16 } // namespace PUP
17 /// \endcond
18 
19 /// \cond
20 class DataVector;
21 /// \endcond
22 
23 // IWYU pragma: no_forward_declare EquationsOfState::EquationOfState
24 // IWYU pragma: no_forward_declare Tensor
25 
26 namespace gr {
27 namespace Solutions {
28 
29 /*!
30  * \brief TOV solver based on Lindblom's method
31  *
32  * Uses Lindblom's method of integrating the TOV equations from
33  * \cite Lindblom1998dp
34  *
35  * Instead of integrating \f$m(r)\f$ and \f$p(r)\f$
36  * (\f$r\f$=radius, \f$m\f$=mass, \f$p\f$=pressure)
37  * Lindblom introduces the variables \f$u\f$ and \f$v\f$, with \f$u=r^{2}\f$ and
38  * \f$v=m/r\f$.
39  * The integration is then done with the log of the specific enthalpy
40  * (\f$\mathrm{log}(h)\f$) as the independent variable.
41  *
42  * Lindblom's paper simply labels the independent variable as \f$h\f$.
43  * The \f$h\f$ in Lindblom's paper is NOT the specific enthalpy.
44  * Rather, Lindblom's \f$h\f$ is in fact \f$\mathrm{log}(h)\f$.
45  */
46 class TovSolution {
47  public:
49  equation_of_state,
50  double central_mass_density, double final_log_enthalpy,
51  double absolute_tolerance = 1.0e-14,
52  double relative_tolerance = 1.0e-14);
53 
54  TovSolution() = default;
55  TovSolution(const TovSolution& /*rhs*/) = delete;
56  TovSolution& operator=(const TovSolution& /*rhs*/) = delete;
57  TovSolution(TovSolution&& /*rhs*/) noexcept = default;
58  TovSolution& operator=(TovSolution&& /*rhs*/) noexcept = default;
59  ~TovSolution() = default;
60 
61  double outer_radius() const noexcept;
62  double mass(double r) const noexcept;
63  double specific_enthalpy(double r) const noexcept;
64  double log_specific_enthalpy(double r) const noexcept;
65 
66  Scalar<DataVector> mass(const Scalar<DataVector>& radius) const noexcept;
68  noexcept;
69  Scalar<DataVector> log_specific_enthalpy(
70  const Scalar<DataVector>& radius) const noexcept;
71 
72  // NOLINTNEXTLINE(google-runtime-references)
73  void pup(PUP::er& p) noexcept;
74 
75  private:
76  double outer_radius_{std::numeric_limits<double>::signaling_NaN()};
77  intrp::BarycentricRational mass_interpolant_;
78  intrp::BarycentricRational log_enthalpy_interpolant_;
79 };
80 
81 } // namespace Solutions
82 } // namespace gr
Definition: Strahlkorper.hpp:14
Base class for equations of state depending on whether or not the system is relativistic, and the number of independent thermodynamic variables (ThermodynamicDim) needed to determine the pressure.
Definition: EquationOfState.hpp:63
T signaling_NaN(T... args)
A barycentric rational interpolation class.
Definition: BarycentricRational.hpp:44
Scalar< DataType > specific_enthalpy(const Scalar< DataType > &rest_mass_density, const Scalar< DataType > &specific_internal_energy, const Scalar< DataType > &pressure) noexcept
Computes the relativistic specific enthalpy as: where is the specific internal energy...
TOV solver based on Lindblom&#39;s method.
Definition: Tov.hpp:46
Holds functions related to general relativity.
Definition: KerrHorizon.cpp:14
Defines classes for Tensor.
Stores a collection of function values.
Definition: DataVector.hpp:46
Tensor< T, Symmetry<>, index_list<> > Scalar
Scalar type.
Definition: TypeAliases.hpp:21