From 10405012daf14b8a2d4a00e54b3d469e0b67143c Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Mon, 5 Sep 2016 19:13:39 +0100 Subject: [PATCH] Make the cooling compatible with GIZMO as well. Added Stefan and Massimiliano to the author list. --- AUTHORS | 2 ++ src/cooling/const_lambda/cooling.h | 2 +- src/hydro/Gizmo/hydro.h | 32 ++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 4d43745609..c822300c22 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 609d06a387..3fd583b55a 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 9dab5d7fd9..39ae8e0d88 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); +} -- GitLab