|
SpECTRE
v2025.08.19
|
Compute the primitive variables from the conservative variables. More...
#include <PrimitiveFromConservative.hpp>
Static Public Member Functions | |
| template<bool EnforcePhysicality = true> | |
| static bool | apply (gsl::not_null< Scalar< DataVector > * > rest_mass_density, gsl::not_null< Scalar< DataVector > * > electron_fraction, gsl::not_null< Scalar< DataVector > * > specific_internal_energy, gsl::not_null< tnsr::I< DataVector, 3, Frame::Inertial > * > spatial_velocity, gsl::not_null< tnsr::I< DataVector, 3, Frame::Inertial > * > magnetic_field, gsl::not_null< Scalar< DataVector > * > divergence_cleaning_field, gsl::not_null< Scalar< DataVector > * > lorentz_factor, gsl::not_null< Scalar< DataVector > * > pressure, gsl::not_null< Scalar< DataVector > * > temperature, const Scalar< DataVector > &tilde_d, const Scalar< DataVector > &tilde_ye, const Scalar< DataVector > &tilde_tau, const tnsr::i< DataVector, 3, Frame::Inertial > &tilde_s, const tnsr::I< DataVector, 3, Frame::Inertial > &tilde_b, const Scalar< DataVector > &tilde_phi, const tnsr::ii< DataVector, 3, Frame::Inertial > &spatial_metric, const tnsr::II< DataVector, 3, Frame::Inertial > &inv_spatial_metric, const Scalar< DataVector > &sqrt_det_spatial_metric, const EquationsOfState::EquationOfState< true, 3 > &equation_of_state, const grmhd::ValenciaDivClean::PrimitiveFromConservativeOptions &primitive_from_conservative_options) |
Compute the primitive variables from the conservative variables.
For the Valencia formulation of the GRMHD system with divergence cleaning, the conversion of the evolved conserved variables to the primitive variables cannot be expressed in closed analytic form and requires a root find.
[Siegel {et al}, The Astrophysical Journal 859:71(2018)] (http://iopscience.iop.org/article/10.3847/1538-4357/aabcc5/meta) compares several inversion methods.
If ErrorOnFailure is false then the returned bool will be false if recovery failed and true if it succeeded.
If EnforcePhysicality is false then the hydrodynamic inversion will return with an error if the input conservatives are unphysical, i.e., if no solution exits. The exact behavior is governed by ErrorOnFailure.
We start from definition of the momentum density \( S_i \):
\[ \begin{aligned} S_i &= (\rho h)^* W^2 v_i - \alpha b^0 b_i \\ &= \left(\rho h + \frac{B^2}{W^2} + (v \cdot B)^2\right) W^2 v_i - \alpha \left(\frac{W}{\alpha}(v \cdot B)\right) \left(\frac{B_i}{W} + (v \cdot B) W v_i\right) \\ &= \left(\rho h + \frac{B^2}{W^2}\right) W^2 v_i - (v \cdot B) B_i \end{aligned} \]
From the above, we obtain:
\[ \begin{aligned} S^i &= \left(\rho h + \frac{B^2}{W^2}\right) W^2 v^i - (v \cdot B) B^i \\ S \cdot B &= \left(\rho h + \frac{B^2}{W^2}\right) W^2 (v \cdot B) - (v \cdot B) B^2 \\ &= \rho h W^2 (v \cdot B) \\ v^i &= \frac{1}{\sqrt{\gamma} (\rho h W^2 + B^2)} \tilde{S}^i + \frac{S \cdot B}{\rho h W^2 (\rho h W^2 + B^2)} B^i \end{aligned} \]