Skip to content
Snippets Groups Projects
Commit 1fec6d18 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Apply the entropy floor after the kick operation.

parent 839eaf56
Branches
Tags
2 merge requests!720Implement EAGLE-like entropy floor,!705Star formation following Schaye08
......@@ -306,10 +306,11 @@ hydro_get_physical_internal_energy_dt(const struct part *restrict p,
* We assume a constant density for the conversion to entropy.
*
* @param p The particle of interest.
* @param du_dt The new time derivative of the internal energy.
* @param du_dt The new time derivative of the comoving internal energy.
*/
__attribute__((always_inline)) INLINE static void
hydro_set_comoving_internal_energy_dt(struct part *restrict p, float du_dt) {
hydro_set_comoving_internal_energy_dt(struct part *restrict p,
const float du_dt) {
p->entropy_dt = gas_entropy_from_internal_energy(p->rho, du_dt);
}
......@@ -321,15 +322,29 @@ hydro_set_comoving_internal_energy_dt(struct part *restrict p, float du_dt) {
*
* @param p The particle of interest.
* @param cosmo Cosmology data structure
* @param du_dt The time derivative of the internal energy.
* @param du_dt The time derivative of the physical internal energy.
*/
__attribute__((always_inline)) INLINE static void
hydro_set_physical_internal_energy_dt(struct part *restrict p,
const struct cosmology *restrict cosmo,
float du_dt) {
const float du_dt) {
p->entropy_dt =
gas_entropy_from_internal_energy(p->rho * cosmo->a3_inv, du_dt);
}
/**
* @brief Sets the physical entropy of a particle
*
* @param p The particle of interest.
* @param cosmo Cosmology data structure
* @param s 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
......
......@@ -79,6 +79,7 @@ __attribute__((always_inline)) INLINE static void kick_part(
struct part *restrict p, struct xpart *restrict xp, double dt_kick_hydro,
double dt_kick_grav, double dt_kick_therm, double dt_kick_corr,
const struct cosmology *cosmo, const struct hydro_props *hydro_props,
const struct entropy_floor_properties *entropy_floor_props,
integertime_t ti_start, integertime_t ti_end) {
#ifdef SWIFT_DEBUG_CHECKS
......@@ -114,6 +115,13 @@ __attribute__((always_inline)) INLINE static void kick_part(
hydro_kick_extra(p, xp, dt_kick_therm, dt_kick_grav, dt_kick_hydro,
dt_kick_corr, cosmo, hydro_props);
if (p->gpart != NULL) gravity_kick_extra(p->gpart, dt_kick_grav);
/* Verify that the particle is not below the entropy floor */
const float floor = entropy_floor(p, cosmo, entropy_floor_props);
if (hydro_get_physical_entropy(p, xp, cosmo) < floor) {
hydro_set_physical_entropy(p, xp, cosmo, floor);
hydro_set_physical_internal_energy_dt(p, cosmo, 0.f);
}
}
/**
......
......@@ -1679,6 +1679,7 @@ void runner_do_kick1(struct runner *r, struct cell *c, int timer) {
const struct engine *e = r->e;
const struct cosmology *cosmo = e->cosmology;
const struct hydro_props *hydro_props = e->hydro_properties;
const struct entropy_floor_properties *entropy_floor = e->entropy_floor;
const int with_cosmology = (e->policy & engine_policy_cosmology);
struct part *restrict parts = c->hydro.parts;
struct xpart *restrict xparts = c->hydro.xparts;
......@@ -1746,7 +1747,7 @@ void runner_do_kick1(struct runner *r, struct cell *c, int timer) {
/* do the kick */
kick_part(p, xp, dt_kick_hydro, dt_kick_grav, dt_kick_therm,
dt_kick_corr, cosmo, hydro_props, ti_begin,
dt_kick_corr, cosmo, hydro_props, entropy_floor, ti_begin,
ti_begin + ti_step / 2);
/* Update the accelerations to be used in the drift for hydro */
......@@ -1853,6 +1854,7 @@ void runner_do_kick2(struct runner *r, struct cell *c, int timer) {
const struct engine *e = r->e;
const struct cosmology *cosmo = e->cosmology;
const struct hydro_props *hydro_props = e->hydro_properties;
const struct entropy_floor_properties *entropy_floor = e->entropy_floor;
const int with_cosmology = (e->policy & engine_policy_cosmology);
const int count = c->hydro.count;
const int gcount = c->grav.count;
......@@ -1916,8 +1918,8 @@ void runner_do_kick2(struct runner *r, struct cell *c, int timer) {
/* Finish the time-step with a second half-kick */
kick_part(p, xp, dt_kick_hydro, dt_kick_grav, dt_kick_therm,
dt_kick_corr, cosmo, hydro_props, ti_begin + ti_step / 2,
ti_begin + ti_step);
dt_kick_corr, cosmo, hydro_props, entropy_floor,
ti_begin + ti_step / 2, ti_begin + ti_step);
#ifdef SWIFT_DEBUG_CHECKS
/* Check that kick and the drift are synchronized */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment