diff --git a/src/EOS.hpp b/src/EOS.hpp index e7f43d8d7..c2e6a012b 100644 --- a/src/EOS.hpp +++ b/src/EOS.hpp @@ -241,8 +241,11 @@ AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto EOS::ComputeOtherDeriva amrex::Real deint_dP = NAN; // compute derivative of density w/r/t pressure, given density and pressure amrex::Real dRho_dP = NAN; - // compute derivative of pressure w/r/t density, given density and pressure (needed for the fundamental derivative G) + // compute derivative of pressure w/r/t density at constant entropy, given density and pressure (needed for the fundamental derivative G) + amrex:: Real dP_dRho_s = NAN; amrex::Real G_gamma = NAN; + // compute second derivative of pressure w/r/t density at constant entropy, given density and pressure (needed for the fundamental derivative G) + amrex::Real d2P_dRho2_s = NAN; #ifdef PRIMORDIAL_CHEM eos_t chemstate; @@ -264,7 +267,9 @@ AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto EOS::ComputeOtherDeriva deint_dRho = chemstate.dedr; deint_dP = 1.0 / chemstate.dpde; dRho_dP = 1.0 / (chemstate.dpdr * C::k_B / boltzmann_constant_); - G_gamma = (chemstate.cs * chemstate.cs) * rho / P; + dP_dRho_s = chemstate.cs * chemstate.cs; + G_gamma = dP_dRho_s * rho / P; + d2P_dRho2_s = chemstate.d2pdr2_s; #else if constexpr (gamma_ != 1.0) { @@ -276,10 +281,12 @@ AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto EOS::ComputeOtherDeriva deint_dRho = estate.dedr; deint_dP = 1.0 / estate.dpde; dRho_dP = 1.0 / (estate.dpdr * C::k_B / boltzmann_constant_); - G_gamma = (estate.cs * estate.cs) * rho / P; + dP_dRho_s = estate.cs * estate.cs; + G_gamma = dP_dRho_s * rho / P; + d2P_dRho2_s = estate.d2pdr2_s; } #endif - return std::make_tuple(deint_dRho, deint_dP, dRho_dP, G_gamma); + return std::make_tuple(deint_dRho, deint_dP, dRho_dP, dP_dRho_s, G_gamma, d2P_dRho2_s); } template diff --git a/src/HLLC.hpp b/src/HLLC.hpp index 72eba4e4b..cbe5830c7 100644 --- a/src/HLLC.hpp +++ b/src/HLLC.hpp @@ -44,8 +44,8 @@ AMREX_FORCE_INLINE AMREX_GPU_DEVICE auto HLLC(quokka::HydroState::ComputeOtherDerivatives(sL.rho, sL.P, sL.massScalar); - auto [dedr_R, dedp_R, drdp_R, G_gamma_R] = quokka::EOS::ComputeOtherDerivatives(sR.rho, sR.P, sR.massScalar); + auto [dedr_L, dedp_L, drdp_L, dpdr_s_L, G_gamma_L, d2pdr2_s_L] = quokka::EOS::ComputeOtherDerivatives(sL.rho, sL.P, sL.massScalar); + auto [dedr_R, dedp_R, drdp_R, dpdr_s_R, G_gamma_R, d2pdr2_s_R] = quokka::EOS::ComputeOtherDerivatives(sR.rho, sR.P, sR.massScalar); // equation A.5a of Kershaw+1998 // need specific internal energy here @@ -57,8 +57,8 @@ AMREX_FORCE_INLINE AMREX_GPU_DEVICE auto HLLC(quokka::HydroState