PalenzuelaEtAl.hpp
2 // See LICENSE.txt for details.
3
4 #pragma once
5
6 #include <boost/optional.hpp>
7 #include <cstddef>
8 #include <limits>
9 #include <string>
10
11 #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp"
12
13 // IWYU pragma: no_forward_declare EquationsOfState::EquationOfState
14
15 namespace grmhd {
17 namespace PrimitiveRecoverySchemes {
18
19 /// \cond
20 struct PrimitiveRecoveryData;
21 /// \endcond
22
23 /*!
24  * \brief Compute the primitive variables from the conservative variables using
25  * the scheme of [Palenzuela et al, Phys. Rev. D 92, 044045
26  * (2015)](https://doi.org/10.1103/PhysRevD.92.044045).
27  *
28  * In the notation of the Palenzuela paper, total_energy_density is \f$D 29 * (1+q)\f$, momentum_density_squared is \f$r^2 D^2\f$,
30  * momentum_density_dot_magnetic_field is \f$t D^{\frac{3}{2}}\f$,
31  * magnetic_field_squared is \f$s D\f$, and
32  * rest_mass_density_times_lorentz_factor is \f$D\f$.
33  * Furthermore, the returned PrimitiveRecoveryData.rho_h_w_squared is \f$x 34 * D\f$. Note also that \f$h\f$ in the Palenzuela paper is the specific
35  * enthalpy times the rest mass density.
36  *
37  * In terms of the conservative variables (in our notation):
38  * \f{align*}
39  * q = & \frac{{\tilde \tau}}{{\tilde D}} \\
40  * r = & \frac{\gamma^{mn} {\tilde S}_m {\tilde S}_n}{{\tilde D}^2} \\
41  * t^2 = & \frac{({\tilde B}^m {\tilde S}_m)^2}{{\tilde D}^3 \sqrt{\gamma}} \\
42  * s = & \frac{\gamma_{mn} {\tilde B}^m {\tilde B}^n}{{\tilde D}\sqrt{\gamma}}
43  * \f}
44  *
45  * where the conserved variables \f${\tilde D}\f$, \f${\tilde S}_i\f$,
46  * \f${\tilde \tau}\f$, and \f${\tilde B}^i\f$ are a generalized mass-energy
47  * density, momentum density, specific internal energy density, and magnetic
48  * field, and \f$\gamma\f$ and \f$\gamma^{mn}\f$ are the determinant and inverse
49  * of the spatial metric \f$\gamma_{mn}\f$.
50  */
52  public:
53  template <size_t ThermodynamicDim>
54  static boost::optional<PrimitiveRecoveryData> apply(
55  double /*initial_guess_pressure*/, double total_energy_density,
56  double momentum_density_squared,
57  double momentum_density_dot_magnetic_field, double magnetic_field_squared,
58  double rest_mass_density_times_lorentz_factor,
60  equation_of_state) noexcept;
61
62  static const std::string name() noexcept { return "PalenzuelaEtAl"; }
63
64  private:
65  static constexpr size_t max_iterations_ = 100;
66  static constexpr double absolute_tolerance_ =
68  static constexpr double relative_tolerance_ =
70 };
71 } // namespace PrimitiveRecoverySchemes