diff --git a/src/cooling/EAGLE/cooling.c b/src/cooling/EAGLE/cooling.c index c5f24a4760efae065ba27850e002e1d1e762fe3e..6f33049637508642bc055de1461b404cdc7bbf49 100644 --- a/src/cooling/EAGLE/cooling.c +++ b/src/cooling/EAGLE/cooling.c @@ -777,6 +777,14 @@ __attribute__((always_inline)) INLINE float cooling_get_radiated_energy( return xp->cooling_data.radiated_energy; } +/** + * @brief Inject a fixed amount of energy to each particle in the simulation + * to mimic Hydrogen reionization. + * + * @param cooling The properties of the cooling model. + * @param cosmo The cosmological model. + * @param s The #space containing the particles. + */ void cooling_Hydrogen_reionization(const struct cooling_function_data *cooling, const struct cosmology *cosmo, struct space *s) { diff --git a/src/hydro/AnarchyPU/hydro.h b/src/hydro/AnarchyPU/hydro.h index 9bb53f290acb16b4f9efc44e430a78a6d1f5c5ff..99b3a9ca9bc8f387104ae9ee3a337bd3e1d6734d 100644 --- a/src/hydro/AnarchyPU/hydro.h +++ b/src/hydro/AnarchyPU/hydro.h @@ -379,6 +379,45 @@ __attribute__((always_inline)) INLINE static void hydro_set_physical_entropy( xp->u_full = gas_internal_energy_from_entropy(p->rho, comoving_entropy); } +/** + * @brief Sets the physical internal energy of a particle + * + * @param p The particle of interest. + * @param xp The extended particle data. + * @param cosmo Cosmology data structure + * @param u The physical internal energy + */ +__attribute__((always_inline)) INLINE static void +hydro_set_physical_internal_energy(struct part *p, struct xpart *xp, + const struct cosmology *cosmo, + const float u) { + + xp->u_full = u / cosmo->a_factor_internal_energy; +} + +/** + * @brief Sets the drifted physical internal energy of a particle + * + * @param p The particle of interest. + * @param cosmo Cosmology data structure + * @param u The physical internal energy + */ +__attribute__((always_inline)) INLINE static void +hydro_set_drifted_physical_internal_energy(struct part *p, + const struct cosmology *cosmo, + const float u) { + + p->u = u / cosmo->a_factor_internal_energy; + + /* Now recompute the extra quantities */ + + /* Compute the sound speed */ + const float soundspeed = hydro_get_comoving_soundspeed(p); + + /* Update variables. */ + p->force.soundspeed = soundspeed; +} + /** * @brief Computes the hydro time-step of a given particle * diff --git a/src/hydro/Default/hydro.h b/src/hydro/Default/hydro.h index 2b1d19bc916889a5cfdc40b1357f1e3dfe9388af..175265dd4707be19e995e2ca6912629876ca2ca2 100644 --- a/src/hydro/Default/hydro.h +++ b/src/hydro/Default/hydro.h @@ -318,6 +318,62 @@ hydro_set_physical_internal_energy_dt(struct part *restrict p, p->force.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 Sets the physical internal energy of a particle + * + * @param p The particle of interest. + * @param xp The extended particle data. + * @param cosmo Cosmology data structure + * @param u The physical internal energy + */ +__attribute__((always_inline)) INLINE static void +hydro_set_physical_internal_energy(struct part *p, struct xpart *xp, + const struct cosmology *cosmo, + const float u) { + + xp->u_full = u / cosmo->a_factor_internal_energy; +} + +/** + * @brief Sets the drifted physical internal energy of a particle + * + * @param p The particle of interest. + * @param cosmo Cosmology data structure + * @param u The physical internal energy + */ +__attribute__((always_inline)) INLINE static void +hydro_set_drifted_physical_internal_energy(struct part *p, + const struct cosmology *cosmo, + const float u) { + + p->u = u / cosmo->a_factor_internal_energy; + + /* Now recompute the extra quantities */ + + /* Compute the sound speed */ + const float soundspeed = hydro_get_comoving_soundspeed(p); + + /* Update variables. */ + p->force.soundspeed = soundspeed; +} + /** * @brief Computes the hydro time-step of a given particle * diff --git a/src/hydro/Default/hydro_part.h b/src/hydro/Default/hydro_part.h index 21c0269f78c85b7d11ab5e838d45614161aee013..2ff41da0a7825d2ddba276c3d20a9d2d4aad3224 100644 --- a/src/hydro/Default/hydro_part.h +++ b/src/hydro/Default/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 SPH loops over neighbours. */ @@ -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; + float u_full; /* Old density. */ diff --git a/src/hydro/Gadget2/hydro.h b/src/hydro/Gadget2/hydro.h index bc505392e96c48d282b3543c8d47a87202d182d9..8da8a4d50d29186981b5724e866e3aaf35546bac 100644 --- a/src/hydro/Gadget2/hydro.h +++ b/src/hydro/Gadget2/hydro.h @@ -331,6 +331,7 @@ hydro_set_physical_internal_energy_dt(struct part *restrict p, p->entropy_dt = gas_entropy_from_internal_energy(p->rho * cosmo->a3_inv, du_dt); } + /** * @brief Sets the physical entropy of a particle * diff --git a/src/hydro/GizmoMFM/hydro.h b/src/hydro/GizmoMFM/hydro.h index a4a54e7b551cc643bffedb8661f4fe269d348dc4..3456e6f9e0a4c1715951030a8b0a10c081d746bf 100644 --- a/src/hydro/GizmoMFM/hydro.h +++ b/src/hydro/GizmoMFM/hydro.h @@ -987,6 +987,35 @@ __attribute__((always_inline)) INLINE static void hydro_set_physical_entropy( error("Needs implementing"); } +/** + * @brief Sets the physical internal energy of a particle + * + * @param p The particle of interest. + * @param xp The extended particle data. + * @param cosmo Cosmology data structure + * @param u The physical internal energy + */ +__attribute__((always_inline)) INLINE static void +hydro_set_physical_internal_energy(struct part* p, struct xpart* xp, + const struct cosmology* cosmo, + const float u) { + error("Need implementing"); +} + +/** + * @brief Sets the drifted physical internal energy of a particle + * + * @param p The particle of interest. + * @param cosmo Cosmology data structure + * @param u The physical internal energy + */ +__attribute__((always_inline)) INLINE static void +hydro_set_drifted_physical_internal_energy(struct part* p, + const struct cosmology* cosmo, + const float u) { + error("Need implementing"); +} + /** * @brief Returns the comoving density of a particle * diff --git a/src/hydro/GizmoMFV/hydro.h b/src/hydro/GizmoMFV/hydro.h index 974f57ed68bbc409697111c52c40f36d4a5cb9b1..526d84289554f7e2f4cd183bbf82484f0804be28 100644 --- a/src/hydro/GizmoMFV/hydro.h +++ b/src/hydro/GizmoMFV/hydro.h @@ -1061,6 +1061,35 @@ __attribute__((always_inline)) INLINE static void hydro_set_physical_entropy( error("Needs implementing"); } +/** + * @brief Sets the physical internal energy of a particle + * + * @param p The particle of interest. + * @param xp The extended particle data. + * @param cosmo Cosmology data structure + * @param u The physical internal energy + */ +__attribute__((always_inline)) INLINE static void +hydro_set_physical_internal_energy(struct part* p, struct xpart* xp, + const struct cosmology* cosmo, + const float u) { + error("Need implementing"); +} + +/** + * @brief Sets the drifted physical internal energy of a particle + * + * @param p The particle of interest. + * @param cosmo Cosmology data structure + * @param u The physical internal energy + */ +__attribute__((always_inline)) INLINE static void +hydro_set_drifted_physical_internal_energy(struct part* p, + const struct cosmology* cosmo, + const float u) { + error("Need implementing"); +} + /** * @brief Returns the comoving density of a particle * diff --git a/src/hydro/Minimal/hydro.h b/src/hydro/Minimal/hydro.h index a5808468300da234a91a86feb897a9398e14db90..1d5d25f734acae72490ae42552abf65983463c07 100644 --- a/src/hydro/Minimal/hydro.h +++ b/src/hydro/Minimal/hydro.h @@ -354,6 +354,45 @@ __attribute__((always_inline)) INLINE static void hydro_set_physical_entropy( xp->u_full = gas_internal_energy_from_entropy(p->rho, comoving_entropy); } +/** + * @brief Sets the physical internal energy of a particle + * + * @param p The particle of interest. + * @param xp The extended particle data. + * @param cosmo Cosmology data structure + * @param u The physical internal energy + */ +__attribute__((always_inline)) INLINE static void +hydro_set_physical_internal_energy(struct part *p, struct xpart *xp, + const struct cosmology *cosmo, + const float u) { + + xp->u_full = u / cosmo->a_factor_internal_energy; +} + +/** + * @brief Sets the drifted physical internal energy of a particle + * + * @param p The particle of interest. + * @param cosmo Cosmology data structure + * @param u The physical internal energy + */ +__attribute__((always_inline)) INLINE static void +hydro_set_drifted_physical_internal_energy(struct part *p, + const struct cosmology *cosmo, + const float u) { + + p->u = u / cosmo->a_factor_internal_energy; + + /* Now recompute the extra quantities */ + + /* Compute the sound speed */ + const float soundspeed = hydro_get_comoving_soundspeed(p); + + /* Update variables. */ + p->force.soundspeed = soundspeed; +} + /** * @brief Computes the hydro time-step of a given particle * diff --git a/src/hydro/Planetary/hydro.h b/src/hydro/Planetary/hydro.h index fbe0b6c8b9a8844cab3e38e485923fc7543ec528..e03b307bca754eb3a809613b20ebf3b1aae67a9f 100644 --- a/src/hydro/Planetary/hydro.h +++ b/src/hydro/Planetary/hydro.h @@ -378,6 +378,45 @@ __attribute__((always_inline)) INLINE static void hydro_set_physical_entropy( gas_internal_energy_from_entropy(p->rho, comoving_entropy, p->mat_id); } +/** + * @brief Sets the physical internal energy of a particle + * + * @param p The particle of interest. + * @param xp The extended particle data. + * @param cosmo Cosmology data structure + * @param u The physical internal energy + */ +__attribute__((always_inline)) INLINE static void +hydro_set_physical_internal_energy(struct part *p, struct xpart *xp, + const struct cosmology *cosmo, + const float u) { + + xp->u_full = u / cosmo->a_factor_internal_energy; +} + +/** + * @brief Sets the drifted physical internal energy of a particle + * + * @param p The particle of interest. + * @param cosmo Cosmology data structure + * @param u The physical internal energy + */ +__attribute__((always_inline)) INLINE static void +hydro_set_drifted_physical_internal_energy(struct part *p, + const struct cosmology *cosmo, + const float u) { + + p->u = u / cosmo->a_factor_internal_energy; + + /* Now recompute the extra quantities */ + + /* Compute the sound speed */ + const float soundspeed = hydro_get_comoving_soundspeed(p); + + /* Update variables. */ + p->force.soundspeed = soundspeed; +} + /** * @brief Computes the hydro time-step of a given particle * diff --git a/src/hydro/PressureEnergy/hydro.h b/src/hydro/PressureEnergy/hydro.h index 4255327ec307755a8b88121f74bc2ec7ede45200..0e53b5f2ea12462fb1a618cda44934d113f655dd 100644 --- a/src/hydro/PressureEnergy/hydro.h +++ b/src/hydro/PressureEnergy/hydro.h @@ -379,6 +379,45 @@ __attribute__((always_inline)) INLINE static void hydro_set_physical_entropy( xp->u_full = gas_internal_energy_from_entropy(p->rho, comoving_entropy); } +/** + * @brief Sets the physical internal energy of a particle + * + * @param p The particle of interest. + * @param xp The extended particle data. + * @param cosmo Cosmology data structure + * @param u The physical internal energy + */ +__attribute__((always_inline)) INLINE static void +hydro_set_physical_internal_energy(struct part *p, struct xpart *xp, + const struct cosmology *cosmo, + const float u) { + + xp->u_full = u / cosmo->a_factor_internal_energy; +} + +/** + * @brief Sets the drifted physical internal energy of a particle + * + * @param p The particle of interest. + * @param cosmo Cosmology data structure + * @param u The physical internal energy + */ +__attribute__((always_inline)) INLINE static void +hydro_set_drifted_physical_internal_energy(struct part *p, + const struct cosmology *cosmo, + const float u) { + + p->u = u / cosmo->a_factor_internal_energy; + + /* Now recompute the extra quantities */ + + /* Compute the sound speed */ + const float soundspeed = hydro_get_comoving_soundspeed(p); + + /* Update variables. */ + p->force.soundspeed = soundspeed; +} + /** * @brief Computes the hydro time-step of a given particle * diff --git a/src/hydro/PressureEnergyMorrisMonaghanAV/hydro.h b/src/hydro/PressureEnergyMorrisMonaghanAV/hydro.h index b50ca4e2543af94573ff34954c26a23200b78a1d..9f981569e80021774cebaf11066ebdac2afc6f94 100644 --- a/src/hydro/PressureEnergyMorrisMonaghanAV/hydro.h +++ b/src/hydro/PressureEnergyMorrisMonaghanAV/hydro.h @@ -376,6 +376,45 @@ __attribute__((always_inline)) INLINE static void hydro_set_physical_entropy( xp->u_full = gas_internal_energy_from_entropy(p->rho, comoving_entropy); } +/** + * @brief Sets the physical internal energy of a particle + * + * @param p The particle of interest. + * @param xp The extended particle data. + * @param cosmo Cosmology data structure + * @param u The physical internal energy + */ +__attribute__((always_inline)) INLINE static void +hydro_set_physical_internal_energy(struct part *p, struct xpart *xp, + const struct cosmology *cosmo, + const float u) { + + xp->u_full = u / cosmo->a_factor_internal_energy; +} + +/** + * @brief Sets the drifted physical internal energy of a particle + * + * @param p The particle of interest. + * @param cosmo Cosmology data structure + * @param u The physical internal energy + */ +__attribute__((always_inline)) INLINE static void +hydro_set_drifted_physical_internal_energy(struct part *p, + const struct cosmology *cosmo, + const float u) { + + p->u = u / cosmo->a_factor_internal_energy; + + /* Now recompute the extra quantities */ + + /* Compute the sound speed */ + const float soundspeed = hydro_get_comoving_soundspeed(p); + + /* Update variables. */ + p->force.soundspeed = soundspeed; +} + /** * @brief Computes the hydro time-step of a given particle * diff --git a/src/hydro/PressureEntropy/hydro.h b/src/hydro/PressureEntropy/hydro.h index 40b3f42eaed7cbff3c6503caa0fc8801d65ac8e3..578bebf635149fe29299800c2a4854c0158d3de9 100644 --- a/src/hydro/PressureEntropy/hydro.h +++ b/src/hydro/PressureEntropy/hydro.h @@ -150,6 +150,36 @@ __attribute__((always_inline)) INLINE static float hydro_get_physical_entropy( return xp->entropy_full; } +/** + * @brief Sets the physical internal energy of a particle + * + * @param p The particle of interest. + * @param xp The extended particle data. + * @param cosmo Cosmology data structure + * @param u The physical entropy + */ +__attribute__((always_inline)) INLINE static void +hydro_set_physical_internal_energy(struct part *p, struct xpart *xp, + const struct cosmology *cosmo, + const float u) { + error("To be implemented"); +} + +/** + * @brief Sets the drifted physical internal energy of a particle + * + * @param p The particle of interest. + * @param xp The extended particle data. + * @param cosmo Cosmology data structure + * @param u The physical entropy + */ +__attribute__((always_inline)) INLINE static void +hydro_set_drifted_physical_internal_energy(struct part *p, + const struct cosmology *cosmo, + const float u) { + error("To be implemented"); +} + /** * @brief Returns the comoving entropy of a particle drifted to the * current time. diff --git a/src/hydro/Shadowswift/hydro.h b/src/hydro/Shadowswift/hydro.h index b0f3207dfce69ca79899b1134740d035d47251d1..9ac89fa02a3663e521f54b4df0f15884b041fad6 100644 --- a/src/hydro/Shadowswift/hydro.h +++ b/src/hydro/Shadowswift/hydro.h @@ -826,6 +826,50 @@ hydro_get_physical_soundspeed(const struct part* restrict p, return cosmo->a_factor_sound_speed * hydro_get_comoving_soundspeed(p); } +/** + * @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) { + + error("Needs implementing"); +} + +/** + * @brief Sets the physical internal energy of a particle + * + * @param p The particle of interest. + * @param xp The extended particle data. + * @param cosmo Cosmology data structure + * @param u The physical internal energy + */ +__attribute__((always_inline)) INLINE static void +hydro_set_physical_internal_energy(struct part* p, struct xpart* xp, + const struct cosmology* cosmo, + const float u) { + error("Need implementing"); +} + +/** + * @brief Sets the drifted physical internal energy of a particle + * + * @param p The particle of interest. + * @param cosmo Cosmology data structure + * @param u The physical internal energy + */ +__attribute__((always_inline)) INLINE static void +hydro_set_drifted_physical_internal_energy(struct part* p, + const struct cosmology* cosmo, + const float u) { + error("Need implementing"); +} + /** * @brief Returns the comoving pressure of a particle *