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 : 8 : #include "DataStructures/Tensor/TypeAliases.hpp" 9 : #include "Evolution/Systems/RelativisticEuler/Valencia/TagsDeclarations.hpp" 10 : #include "PointwiseFunctions/GeneralRelativity/TagsDeclarations.hpp" 11 : #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp" 12 : #include "PointwiseFunctions/Hydro/TagsDeclarations.hpp" 13 : #include "Utilities/TMPL.hpp" 14 : 15 : /// \cond 16 : class DataVector; 17 : 18 : namespace gsl { 19 : template <typename T> 20 : class not_null; 21 : } // namespace gsl 22 : /// \endcond 23 : 24 : // IWYU pragma: no_forward_declare EquationsOfState::EquationOfState 25 : 26 : namespace RelativisticEuler { 27 : namespace Valencia { 28 : 29 : /*! 30 : * \brief Compute the primitive variables from the conservative variables 31 : * 32 : * For the Valencia formulation of the Relativistic Euler system, the conversion 33 : * of the evolved conserved variables to the primitive variables cannot 34 : * be expressed in closed analytic form and requires a root find. We use 35 : * the method from [Appendix C of Galeazzi \em et \em al, PRD 88, 064009 (2013)] 36 : * (https://journals.aps.org/prd/abstract/10.1103/PhysRevD.88.064009). The 37 : * method finds the root of \f[ f(z) = z - \frac{r}{h(z)} \f] where 38 : * \f{align*} 39 : * r = & \frac{\sqrt{\gamma^{mn} {\tilde S}_m {\tilde S}_n}}{\tilde D} \\ 40 : * h(z) = & [1+ \epsilon(z)][1 + a(z)] \\ 41 : * \epsilon(z) = & W(z) q - z r + \frac{z^2}{1 + W(z)} \\ 42 : * W(z) = & \sqrt{1 + z^2} \\ 43 : * q = & \frac{\tilde \tau}{\tilde D} \\ 44 : * a(z) = & \frac{p}{\rho(z) [1 + \epsilon(z)]} \\ 45 : * \rho(z) = & \frac{\tilde D}{\sqrt{\gamma} W(z)} 46 : * \f} 47 : * and where the conserved variables \f${\tilde D}\f$, \f${\tilde S}_i\f$, and 48 : * \f${\tilde \tau}\f$ are a generalized mass-energy density, momentum density, 49 : * and specific internal energy density as measured by an Eulerian observer, 50 : * \f$\gamma\f$ and \f$\gamma^{mn}\f$ are the determinant and inverse of the 51 : * spatial metric \f$\gamma_{mn}\f$, \f$\rho\f$ is the rest mass density, \f$W = 52 : * 1/\sqrt{1 - \gamma_{mn} v^m v^n}\f$ is the Lorentz factor, \f$h = 1 + 53 : * \epsilon + \frac{p}{\rho}\f$ is the specific enthalpy, \f$v^i\f$ is the 54 : * spatial velocity, \f$\epsilon\f$ is the specific internal energy, and \f$p\f$ 55 : * is the pressure. The pressure is determined from the equation of state. 56 : * Finally, once \f$z\f$ is found, the spatial velocity is given by \f[ v^i = 57 : * \frac{{\tilde S}^i}{{\tilde D} W(z) h(z)} \f] 58 : * 59 : * \todo The method also will make corrections if physical bounds are violated, 60 : * see the paper for details. 61 : */ 62 : template <size_t Dim> 63 1 : struct PrimitiveFromConservative { 64 0 : using return_tags = 65 : tmpl::list<hydro::Tags::RestMassDensity<DataVector>, 66 : hydro::Tags::SpecificInternalEnergy<DataVector>, 67 : hydro::Tags::LorentzFactor<DataVector>, 68 : hydro::Tags::SpecificEnthalpy<DataVector>, 69 : hydro::Tags::Pressure<DataVector>, 70 : hydro::Tags::SpatialVelocity<DataVector, Dim>>; 71 : 72 0 : using argument_tags = 73 : tmpl::list<RelativisticEuler::Valencia::Tags::TildeD, 74 : RelativisticEuler::Valencia::Tags::TildeTau, 75 : RelativisticEuler::Valencia::Tags::TildeS<Dim>, 76 : gr::Tags::InverseSpatialMetric<DataVector, Dim>, 77 : gr::Tags::SqrtDetSpatialMetric<DataVector>, 78 : hydro::Tags::EquationOfStateBase>; 79 : 80 : template <size_t ThermodynamicDim> 81 0 : static void apply( 82 : gsl::not_null<Scalar<DataVector>*> rest_mass_density, 83 : gsl::not_null<Scalar<DataVector>*> specific_internal_energy, 84 : gsl::not_null<Scalar<DataVector>*> lorentz_factor, 85 : gsl::not_null<Scalar<DataVector>*> specific_enthalpy, 86 : gsl::not_null<Scalar<DataVector>*> pressure, 87 : gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*> 88 : spatial_velocity, 89 : const Scalar<DataVector>& tilde_d, const Scalar<DataVector>& tilde_tau, 90 : const tnsr::i<DataVector, Dim, Frame::Inertial>& tilde_s, 91 : const tnsr::II<DataVector, Dim, Frame::Inertial>& inv_spatial_metric, 92 : const Scalar<DataVector>& sqrt_det_spatial_metric, 93 : const EquationsOfState::EquationOfState<true, ThermodynamicDim>& 94 : equation_of_state); 95 : }; 96 : } // namespace Valencia 97 : } // namespace RelativisticEuler