From 4efc01bccbfaf97e13519e61f0b6d4241fdc18bd Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Thu, 16 Mar 2017 09:34:03 +0800 Subject: [PATCH] Added pressure to entropy and pressure to internal energy functions to the equation of state definition. --- src/dimension.h | 2 +- src/equation_of_state.h | 59 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/dimension.h b/src/dimension.h index 9169a0796e..7c58b5b846 100644 --- a/src/dimension.h +++ b/src/dimension.h @@ -229,7 +229,7 @@ __attribute__((always_inline)) INLINE static float get_radius_dimension_sphere( error("The dimension is not defined !"); return 0.f; - + #endif } diff --git a/src/equation_of_state.h b/src/equation_of_state.h index 5e570fc634..28c97c7b96 100644 --- a/src/equation_of_state.h +++ b/src/equation_of_state.h @@ -69,6 +69,21 @@ __attribute__((always_inline)) INLINE static float gas_pressure_from_entropy( return entropy * pow_gamma(density); } +/** + * @brief Returns the entropy given density and pressure. + * + * Computes \f$A = \frac{P}{\rho^\gamma}\f$. + * + * @param density The density \f$\rho\f$. + * @param pressure The pressure \f$P\f$. + * @return The entropy \f$A\f$. + */ +__attribute__((always_inline)) INLINE static float gas_entropy_from_pressure( + float density, float pressure) { + + return pressure * pow_minus_gamma(density); +} + /** * @brief Returns the sound speed given density and entropy * @@ -111,6 +126,20 @@ gas_pressure_from_internal_energy(float density, float u) { return hydro_gamma_minus_one * u * density; } +/** + * @brief Returns the internal energy given density and pressure. + * + * Computes \f$u = \frac{1}{\gamma - 1}\frac{P}{\rho}\f$. + * + * @param density The density \f$\rho\f$. + * @param pressure The pressure \f$P\f$. + * @return The internal energy \f$u\f$. + */ +__attribute__((always_inline)) INLINE static float +gas_internal_energy_from_pressure(float density, float pressure) { + return hydro_one_over_gamma_minus_one * pressure / density; +} + /** * @brief Returns the sound speed given density and internal energy * @@ -172,6 +201,22 @@ __attribute__((always_inline)) INLINE static float gas_pressure_from_entropy( return hydro_gamma_minus_one * const_isothermal_internal_energy * density; } +/** + * @brief Returns the entropy given density and pressure. + * + * Computes \f$A = \frac{P}{\rho^\gamma}\f$. + * + * @param density The density \f$\rho\f$. + * @param pressure The pressure \f$P\f$ (ignored). + * @return The entropy \f$A\f$. + */ +__attribute__((always_inline)) INLINE static float gas_entropy_from_pressure( + float density, float pressure) { + + return hydro_gamma_minus_one * const_isothermal_internal_energy * + pow_minus_gamma_minus_one(density); +} + /** * @brief Returns the sound speed given density and entropy * @@ -219,6 +264,20 @@ gas_pressure_from_internal_energy(float density, float u) { return hydro_gamma_minus_one * const_isothermal_internal_energy * density; } +/** + * @brief Returns the internal energy given density and pressure. + * + * Just returns the constant internal energy. + * + * @param density The density \f$\rho\f$ (ignored). + * @param pressure The pressure \f$P\f$ (ignored). + * @return The internal energy \f$u\f$ (which is constant). + */ +__attribute__((always_inline)) INLINE static float +gas_internal_energy_from_pressure(float density, float pressure) { + return const_isothermal_energy; +} + /** * @brief Returns the sound speed given density and internal energy * -- GitLab