diff --git a/doc/RTD/source/SubgridModels/EAGLE/index.rst b/doc/RTD/source/SubgridModels/EAGLE/index.rst index e2489452ef6ce73d9ca98e63f660fc65e0113f38..cc353469bd642b40b9b2f76a50d7f09f66a4bf7d 100644 --- a/doc/RTD/source/SubgridModels/EAGLE/index.rst +++ b/doc/RTD/source/SubgridModels/EAGLE/index.rst @@ -9,6 +9,13 @@ This section of the documentation gives a brief description of the different components of the EAGLE sub-grid model. We mostly focus on the parameters and values output in the snapshots. +.. _EAGLE_entropy_floors: + +Entropy floors +~~~~~~~~~~~~~~ + + + .. _EAGLE_chemical_tracers: Chemical tracers diff --git a/src/hydro/Gadget2/hydro_part.h b/src/hydro/Gadget2/hydro_part.h index f817d2cf9bf23aea9f3a436feec1a471e15b5340..6b028b0497584ca65bd236c4a507b55356e7c260 100644 --- a/src/hydro/Gadget2/hydro_part.h +++ b/src/hydro/Gadget2/hydro_part.h @@ -61,7 +61,7 @@ struct xpart { /* Additional data used by the tracers */ struct tracers_xpart_data tracers_data; - /* Additional data used by the tracers */ + /* Additional data used by the star formation */ struct star_formation_xpart_data sf_data; #ifdef WITH_LOGGER diff --git a/src/hydro/GizmoMFM/hydro_part.h b/src/hydro/GizmoMFM/hydro_part.h index a05cae18aaf18feb80f7a4ec383434eadece8a41..c4884ebc40a18de765aed193a028c92465ad63ad 100644 --- a/src/hydro/GizmoMFM/hydro_part.h +++ b/src/hydro/GizmoMFM/hydro_part.h @@ -21,6 +21,7 @@ #include "chemistry_struct.h" #include "cooling_struct.h" +#include "star_formation_struct.h" #include "tracers_struct.h" /* Extra particle data not needed during the computation. */ @@ -44,6 +45,9 @@ struct xpart { /* Additional data used by the tracers */ struct tracers_xpart_data tracers_data; + /* Additional data used by the star formation */ + struct star_formation_xpart_data sf_data; + } SWIFT_STRUCT_ALIGN; /* Data of a single particle. */ diff --git a/src/hydro/GizmoMFV/hydro_part.h b/src/hydro/GizmoMFV/hydro_part.h index 8794b597712963e962cc23c796e9769efd4ea620..c6bbaeb1c8e256081f7300c041dfa3cd996fbf18 100644 --- a/src/hydro/GizmoMFV/hydro_part.h +++ b/src/hydro/GizmoMFV/hydro_part.h @@ -21,6 +21,7 @@ #include "chemistry_struct.h" #include "cooling_struct.h" +#include "star_formation_struct.h" #include "tracers_struct.h" /* Extra particle data not needed during the computation. */ @@ -44,6 +45,9 @@ struct xpart { /* Additional data used by the tracers */ struct tracers_xpart_data tracers_data; + /* Additional data used by the star formation */ + struct star_formation_xpart_data sf_data; + } SWIFT_STRUCT_ALIGN; /* Data of a single particle. */ diff --git a/src/hydro/Minimal/hydro.h b/src/hydro/Minimal/hydro.h index 2af6eb47e8de091f391dc758e7842cc5cada702a..a5808468300da234a91a86feb897a9398e14db90 100644 --- a/src/hydro/Minimal/hydro.h +++ b/src/hydro/Minimal/hydro.h @@ -337,6 +337,23 @@ hydro_set_physical_internal_energy_dt(struct part *restrict p, p->u_dt = du_dt / cosmo->a_factor_internal_energy; } +/** + * @brief Sets the physical entropy of a particle + * + * @param p The particle of interest. + * @param xp The extended particle data. + * @param cosmo Cosmology data structure + * @param entropy The physical entropy + */ +__attribute__((always_inline)) INLINE static void hydro_set_physical_entropy( + struct part *p, struct xpart *xp, const struct cosmology *cosmo, + const float entropy) { + + /* Note there is no conversion from physical to comoving entropy */ + const float comoving_entropy = entropy; + xp->u_full = gas_internal_energy_from_entropy(p->rho, comoving_entropy); +} + /** * @brief Computes the hydro time-step of a given particle * diff --git a/src/hydro/Minimal/hydro_part.h b/src/hydro/Minimal/hydro_part.h index 80e472194e6a008859fa7e7fde9c79df6611142b..2068c08b01fcbe57f6a2439770ca85e6e0e06b3a 100644 --- a/src/hydro/Minimal/hydro_part.h +++ b/src/hydro/Minimal/hydro_part.h @@ -34,6 +34,7 @@ #include "chemistry_struct.h" #include "cooling_struct.h" +#include "star_formation_struct.h" #include "tracers_struct.h" /** @@ -66,6 +67,9 @@ struct xpart { /* Additional data used by the tracers */ struct tracers_xpart_data tracers_data; + /* Additional data used by the tracers */ + struct star_formation_xpart_data sf_data; + } SWIFT_STRUCT_ALIGN; /** diff --git a/src/hydro/Planetary/hydro.h b/src/hydro/Planetary/hydro.h index 68dfa3eb825b7dd984eb6fd52336ee97b0c4f93e..fbe0b6c8b9a8844cab3e38e485923fc7543ec528 100644 --- a/src/hydro/Planetary/hydro.h +++ b/src/hydro/Planetary/hydro.h @@ -360,6 +360,24 @@ hydro_set_physical_internal_energy_dt(struct part *restrict p, p->u_dt = du_dt / cosmo->a_factor_internal_energy; } +/** + * @brief Sets the physical entropy of a particle + * + * @param p The particle of interest. + * @param xp The extended particle data. + * @param cosmo Cosmology data structure + * @param entropy The physical entropy + */ +__attribute__((always_inline)) INLINE static void hydro_set_physical_entropy( + struct part *p, struct xpart *xp, const struct cosmology *cosmo, + const float entropy) { + + /* Note there is no conversion from physical to comoving entropy */ + const float comoving_entropy = entropy; + xp->u_full = + gas_internal_energy_from_entropy(p->rho, comoving_entropy, p->mat_id); +} + /** * @brief Computes the hydro time-step of a given particle * diff --git a/src/hydro/Planetary/hydro_part.h b/src/hydro/Planetary/hydro_part.h index 1955366da7265c4c40922d1e7290bc9128641600..383d803fd9baebbaba702d788239cc8d684254bc 100644 --- a/src/hydro/Planetary/hydro_part.h +++ b/src/hydro/Planetary/hydro_part.h @@ -36,6 +36,7 @@ #include "chemistry_struct.h" #include "cooling_struct.h" #include "equation_of_state.h" // For enum material_id +#include "star_formation_struct.h" #include "tracers_struct.h" /** @@ -65,9 +66,12 @@ struct xpart { /*! Additional data used to record cooling information */ struct cooling_xpart_data cooling_data; - /* Additional data used by the tracers */ + /*! Additional data used by the tracers */ struct tracers_xpart_data tracers_data; + /* Additional data used by the star formation */ + struct star_formation_xpart_data sf_data; + } SWIFT_STRUCT_ALIGN; /** diff --git a/src/hydro/PressureEnergy/hydro.h b/src/hydro/PressureEnergy/hydro.h index 7b6c302fb7f8001cb96d595eb35fb6ef08222bec..4af00f7a657d61871dc0a82affb04d411e13e047 100644 --- a/src/hydro/PressureEnergy/hydro.h +++ b/src/hydro/PressureEnergy/hydro.h @@ -362,6 +362,23 @@ hydro_set_physical_internal_energy_dt(struct part *restrict p, p->u_dt = du_dt / cosmo->a_factor_internal_energy; } +/** + * @brief Sets the physical entropy of a particle + * + * @param p The particle of interest. + * @param xp The extended particle data. + * @param cosmo Cosmology data structure + * @param entropy The physical entropy + */ +__attribute__((always_inline)) INLINE static void hydro_set_physical_entropy( + struct part *p, struct xpart *xp, const struct cosmology *cosmo, + const float entropy) { + + /* Note there is no conversion from physical to comoving entropy */ + const float comoving_entropy = entropy; + xp->u_full = gas_internal_energy_from_entropy(p->rho, comoving_entropy); +} + /** * @brief Computes the hydro time-step of a given particle * diff --git a/src/hydro/PressureEnergy/hydro_part.h b/src/hydro/PressureEnergy/hydro_part.h index 218fbf5dc17559b07974b68e42f69f4e7a0e8e3b..6a2d890049bef5fe7040e7908a48df304beddb64 100644 --- a/src/hydro/PressureEnergy/hydro_part.h +++ b/src/hydro/PressureEnergy/hydro_part.h @@ -33,6 +33,7 @@ #include "chemistry_struct.h" #include "cooling_struct.h" +#include "star_formation_struct.h" #include "tracers_struct.h" /** @@ -62,9 +63,12 @@ struct xpart { /*! Additional data used to record cooling information */ struct cooling_xpart_data cooling_data; - /* Additional data used by the tracers */ + /*! Additional data used by the tracers */ struct tracers_xpart_data tracers_data; + /*! Additional data used by the star formation */ + struct star_formation_xpart_data sf_data; + } SWIFT_STRUCT_ALIGN; /** diff --git a/src/hydro/PressureEnergyMorrisMonaghanAV/hydro.h b/src/hydro/PressureEnergyMorrisMonaghanAV/hydro.h index 9767a165d3f9243c9dd9b72bdc9131fe338e52b4..b50ca4e2543af94573ff34954c26a23200b78a1d 100644 --- a/src/hydro/PressureEnergyMorrisMonaghanAV/hydro.h +++ b/src/hydro/PressureEnergyMorrisMonaghanAV/hydro.h @@ -143,11 +143,12 @@ __attribute__((always_inline)) INLINE static float hydro_get_comoving_entropy( * @param cosmo The cosmological model. */ __attribute__((always_inline)) INLINE static float hydro_get_physical_entropy( - const struct part *restrict p, const struct cosmology *cosmo) { + const struct part *restrict p, const struct xpart *restrict xp, + const struct cosmology *cosmo) { /* Note: no cosmological conversion required here with our choice of * coordinates. */ - return gas_entropy_from_internal_energy(p->rho, p->u); + return gas_entropy_from_internal_energy(p->rho, xp->u_full); } /** @@ -306,12 +307,27 @@ __attribute__((always_inline)) INLINE static void hydro_get_drifted_velocities( * * @param p The particle of interest */ -__attribute__((always_inline)) INLINE static float hydro_get_internal_energy_dt( - const struct part *restrict p) { +__attribute__((always_inline)) INLINE static float +hydro_get_comoving_internal_energy_dt(const struct part *restrict p) { return p->u_dt; } +/** + * @brief Returns the time derivative of internal energy of a particle + * + * We assume a constant density. + * + * @param p The particle of interest + * @param cosmo Cosmology data structure + */ +__attribute__((always_inline)) INLINE static float +hydro_get_physical_internal_energy_dt(const struct part *restrict p, + const struct cosmology *cosmo) { + + return p->u_dt * cosmo->a_factor_internal_energy; +} + /** * @brief Sets the time derivative of internal energy of a particle * @@ -320,12 +336,46 @@ __attribute__((always_inline)) INLINE static float hydro_get_internal_energy_dt( * @param p The particle of interest. * @param du_dt The new time derivative of the internal energy. */ -__attribute__((always_inline)) INLINE static void hydro_set_internal_energy_dt( - struct part *restrict p, float du_dt) { +__attribute__((always_inline)) INLINE static void +hydro_set_comoving_internal_energy_dt(struct part *restrict p, float du_dt) { p->u_dt = du_dt; } +/** + * @brief Returns the time derivative of internal energy of a particle + * + * We assume a constant density. + * + * @param p The particle of interest. + * @param cosmo Cosmology data structure + * @param du_dt The new time derivative of the internal energy. + */ +__attribute__((always_inline)) INLINE static void +hydro_set_physical_internal_energy_dt(struct part *restrict p, + const struct cosmology *cosmo, + float du_dt) { + + p->u_dt = du_dt / cosmo->a_factor_internal_energy; +} + +/** + * @brief Sets the physical entropy of a particle + * + * @param p The particle of interest. + * @param xp The extended particle data. + * @param cosmo Cosmology data structure + * @param entropy The physical entropy + */ +__attribute__((always_inline)) INLINE static void hydro_set_physical_entropy( + struct part *p, struct xpart *xp, const struct cosmology *cosmo, + const float entropy) { + + /* Note there is no conversion from physical to comoving entropy */ + const float comoving_entropy = entropy; + xp->u_full = gas_internal_energy_from_entropy(p->rho, comoving_entropy); +} + /** * @brief Computes the hydro time-step of a given particle * diff --git a/src/hydro/PressureEnergyMorrisMonaghanAV/hydro_part.h b/src/hydro/PressureEnergyMorrisMonaghanAV/hydro_part.h index d66249ea179a830cedbd3c3f165ca5012fd18862..b75313b58e01260fa267d4b5bab29815a7329ce7 100644 --- a/src/hydro/PressureEnergyMorrisMonaghanAV/hydro_part.h +++ b/src/hydro/PressureEnergyMorrisMonaghanAV/hydro_part.h @@ -34,6 +34,7 @@ #include "chemistry_struct.h" #include "cooling_struct.h" +#include "star_formation_struct.h" #include "tracers_struct.h" /** @@ -63,9 +64,12 @@ struct xpart { /*! Additional data used to record cooling information */ struct cooling_xpart_data cooling_data; - /* Additional data used by the tracers */ + /*! Additional data used by the tracers */ struct tracers_xpart_data tracers_data; + /*! Additional data used by the star formation */ + struct star_formation_xpart_data sf_data; + } SWIFT_STRUCT_ALIGN; /** diff --git a/src/hydro/PressureEntropy/hydro.h b/src/hydro/PressureEntropy/hydro.h index 2e8d2d5db615f239bf5c3567e7beb155eab5cb38..40b3f42eaed7cbff3c6503caa0fc8801d65ac8e3 100644 --- a/src/hydro/PressureEntropy/hydro.h +++ b/src/hydro/PressureEntropy/hydro.h @@ -327,6 +327,21 @@ hydro_set_physical_internal_energy_dt(struct part *restrict p, p->entropy_dt = gas_entropy_from_internal_energy(p->rho_bar * cosmo->a3_inv, du_dt); } +/** + * @brief Sets the physical entropy of a particle + * + * @param p The particle of interest. + * @param xp The extended particle data. + * @param cosmo Cosmology data structure + * @param entropy The physical entropy + */ +__attribute__((always_inline)) INLINE static void hydro_set_physical_entropy( + struct part *p, struct xpart *xp, const struct cosmology *cosmo, + const float entropy) { + + /* Note there is no conversion from physical to comoving entropy */ + xp->entropy_full = entropy; +} /** * @brief Computes the hydro time-step of a given particle diff --git a/src/hydro/PressureEntropy/hydro_part.h b/src/hydro/PressureEntropy/hydro_part.h index a404a897b06ddc0777a493e2ecfd28b68e15defe..992ed4654e63fe42e1f45c04ed8bfe876cb89e45 100644 --- a/src/hydro/PressureEntropy/hydro_part.h +++ b/src/hydro/PressureEntropy/hydro_part.h @@ -32,6 +32,7 @@ #include "chemistry_struct.h" #include "cooling_struct.h" +#include "star_formation_struct.h" #include "tracers_struct.h" /* Extra particle data not needed during the SPH loops over neighbours. */ @@ -55,9 +56,12 @@ struct xpart { /*! Additional data used to record cooling information */ struct cooling_xpart_data cooling_data; - /* Additional data used by the tracers */ + /*! Additional data used by the tracers */ struct tracers_xpart_data tracers_data; + /*! Additional data used by the star formation */ + struct star_formation_xpart_data sf_data; + } SWIFT_STRUCT_ALIGN; /* Data of a single particle. */