diff --git a/AUTHORS b/AUTHORS index 4d43745609fc9d0ac2f149256a76ed6c581c9144..c822300c22885a05b42d58a51cc86af9da410429 100644 --- a/AUTHORS +++ b/AUTHORS @@ -8,3 +8,5 @@ John A. Regan john.a.regan@durham.ac.uk Angus Lepper angus.lepper@ed.ac.uk Tom Theuns tom.theuns@durham.ac.uk Richard G. Bower r.g.bower@durham.ac.uk +Stefan Arridge stefan.arridge@durham.ac.uk +Massimiliano Culpo massimiliano.culpo@googlemail.com diff --git a/src/cooling/const_lambda/cooling.h b/src/cooling/const_lambda/cooling.h index 609d06a387d8bbd4321c19a2351f94bc953d0493..3fd583b55a31534996e23e4dce71bcae9394d7de 100644 --- a/src/cooling/const_lambda/cooling.h +++ b/src/cooling/const_lambda/cooling.h @@ -72,7 +72,7 @@ __attribute__((always_inline)) INLINE static float cooling_rate( /* Get particle properties */ /* Density */ - const float rho = p->rho; + const float rho = hydro_get_density(p); /* Get cooling function properties */ const float X_H = cooling->hydrogen_mass_abundance; /* lambda should always be set in cgs units */ diff --git a/src/hydro/Gizmo/hydro.h b/src/hydro/Gizmo/hydro.h index 9dab5d7fd96a833ba9ea56889139c04000634645..39ae8e0d885389fc52f96f60e13825f8d30142d0 100644 --- a/src/hydro/Gizmo/hydro.h +++ b/src/hydro/Gizmo/hydro.h @@ -20,6 +20,7 @@ #include <float.h> #include "adiabatic_index.h" #include "approx_math.h" +#include "equation_of_state.h" #include "hydro_gradients.h" #include "minmax.h" @@ -502,3 +503,34 @@ __attribute__((always_inline)) INLINE static float hydro_get_density( return p->primitives.rho; } + +/** + * @brief Modifies the thermal state of a particle to the imposed internal + * energy + * + * This overrides the current state of the particle but does *not* change its + * time-derivatives + * + * @param p The particle + * @param u The new internal energy + */ +__attribute__((always_inline)) INLINE static void hydro_set_internal_energy( + struct part* restrict p, float u) { + + p->conserved.energy = u; +} + +/** + * @brief Modifies the thermal state of a particle to the imposed entropy + * + * This overrides the current state of the particle but does *not* change its + * time-derivatives + * + * @param p The particle + * @param S The new entropy + */ +__attribute__((always_inline)) INLINE static void hydro_set_entropy( + struct part* restrict p, float S) { + + p->conserved.energy = gas_internal_energy_from_entropy(p->primitives.rho, S); +}