diff --git a/configure.ac b/configure.ac index 45c0ab52248f05f45115ddd12e9a4120bbd38fcd..6bbb800db73385cdbd6030e5ea38a548677318dc 100644 --- a/configure.ac +++ b/configure.ac @@ -2074,8 +2074,8 @@ AC_MSG_RESULT([ Make gravity glass : $gravity_glass_making External potential : $with_potential - Entropy floor : $with_entropy_floor Pressure floor : $with_pressure_floor + Entropy floor : $with_entropy_floor Cooling function : $with_cooling Chemistry : $with_chemistry Tracers : $with_tracers diff --git a/src/chemistry/EAGLE/chemistry.h b/src/chemistry/EAGLE/chemistry.h index c06b29f4417673bbdac79ab76226770c9c327406..a470eef3fafc32c99fe3a853dcf46051a3086441 100644 --- a/src/chemistry/EAGLE/chemistry.h +++ b/src/chemistry/EAGLE/chemistry.h @@ -243,8 +243,9 @@ static INLINE void chemistry_print_backend( } /** - * @brief Updates the metal mass fractions after diffusion at the end of the - * force loop. + * @brief Updates to the chemistry data after the hydro force loop. + * + * Nothing to do here in EAGLE. * * @param p The particle to act upon. * @param cosmo The current cosmological model. @@ -255,10 +256,13 @@ __attribute__((always_inline)) INLINE static void chemistry_end_force( /** * @brief Computes the chemistry-related time-step constraint. * + * No constraints in the EAGLE model (no diffusion etc.) --> FLT_MAX + * * @param phys_const The physical constants in internal units. * @param cosmo The current cosmological model. * @param us The internal system of units. * @param hydro_props The properties of the hydro scheme. + * @param cd The global properties of the chemistry scheme. * @param p Pointer to the particle data. */ __attribute__((always_inline)) INLINE static float chemistry_timestep( diff --git a/src/chemistry/GEAR/chemistry.h b/src/chemistry/GEAR/chemistry.h index 951d565337eae39bec05c0e142a020e6647811fe..34c4d10e5fb2f491b029c4c8d76cf04ca7a5429a 100644 --- a/src/chemistry/GEAR/chemistry.h +++ b/src/chemistry/GEAR/chemistry.h @@ -135,6 +135,15 @@ __attribute__((always_inline)) INLINE static void chemistry_end_density( } } +/** + * @brief Updates to the chemistry data after the hydro force loop. + * + * @param p The particle to act upon. + * @param cosmo The current cosmological model. + */ +__attribute__((always_inline)) INLINE static void chemistry_end_force( + struct part* restrict p, const struct cosmology* cosmo) {} + /** * @brief Sets all particle fields to sensible values when the #part has 0 ngbs. * @@ -151,6 +160,27 @@ chemistry_part_has_no_neighbours(struct part* restrict p, error("Needs implementing!"); } +/** + * @brief Computes the chemistry-related time-step constraint. + * + * No constraints in the GEAR model (no diffusion) --> FLT_MAX + * + * @param phys_const The physical constants in internal units. + * @param cosmo The current cosmological model. + * @param us The internal system of units. + * @param hydro_props The properties of the hydro scheme. + * @param cd The global properties of the chemistry scheme. + * @param p Pointer to the particle data. + */ +__attribute__((always_inline)) INLINE static float chemistry_timestep( + const struct phys_const* restrict phys_const, + const struct cosmology* restrict cosmo, + const struct unit_system* restrict us, + const struct hydro_props* hydro_props, + const struct chemistry_global_data* cd, const struct part* restrict p) { + return FLT_MAX; +} + /** * @brief Sets the chemistry properties of the (x-)particles to a valid start * state. diff --git a/src/chemistry/none/chemistry.h b/src/chemistry/none/chemistry.h index 543a5e77eea245da9ec18de210c781d5be07d7fb..bb35ea25355d3baf66e8d881de95faa40c688d79 100644 --- a/src/chemistry/none/chemistry.h +++ b/src/chemistry/none/chemistry.h @@ -87,6 +87,36 @@ __attribute__((always_inline)) INLINE static void chemistry_end_density( struct part* restrict p, const struct chemistry_global_data* cd, const struct cosmology* cosmo) {} +/** + * @brief Updates to the chemistry data after the hydro force loop. + * + * Nothing to do here in EAGLE. + * + * @param p The particle to act upon. + * @param cosmo The current cosmological model. + */ +__attribute__((always_inline)) INLINE static void chemistry_end_force( + struct part* restrict p, const struct cosmology* cosmo) {} + +/** + * @brief Computes the chemistry-related time-step constraint. + * + * @param phys_const The physical constants in internal units. + * @param cosmo The current cosmological model. + * @param us The internal system of units. + * @param hydro_props The properties of the hydro scheme. + * @param cd The global properties of the chemistry scheme. + * @param p Pointer to the particle data. + */ +__attribute__((always_inline)) INLINE static float chemistry_timestep( + const struct phys_const* restrict phys_const, + const struct cosmology* restrict cosmo, + const struct unit_system* restrict us, + const struct hydro_props* hydro_props, + const struct chemistry_global_data* cd, const struct part* restrict p) { + return FLT_MAX; +} + /** * @brief Sets all particle fields to sensible values when the #part has 0 ngbs. * diff --git a/src/runner.c b/src/runner.c index 05dc33e97e74901bd87d1fe4da4259b6d8aa29e0..ba11945f836f47030f092b66caa0610b541b825d 100644 --- a/src/runner.c +++ b/src/runner.c @@ -3618,6 +3618,7 @@ void runner_do_end_hydro_force(struct runner *r, struct cell *c, int timer) { /* Finish the force loop */ hydro_end_force(p, cosmo); + chemistry_end_force(p, cosmo); #ifdef SWIFT_BOUNDARY_PARTICLES diff --git a/src/timestep.h b/src/timestep.h index c2b1a10fcb3b0426e7c34625d65c1fd5353d25e9..cd9faaea612c8a666ae9077ccc5e3d85fd4677f9 100644 --- a/src/timestep.h +++ b/src/timestep.h @@ -146,8 +146,14 @@ __attribute__((always_inline)) INLINE static integertime_t get_part_timestep( new_dt_grav = min(new_dt_self_grav, new_dt_ext_grav); } - /* Final time-step is minimum of hydro and gravity */ - float new_dt = min3(new_dt_hydro, new_dt_cooling, new_dt_grav); + /* Compute the next timestep (chemistry condition, e.g. diffusion) */ + const float new_dt_chemistry = + chemistry_timestep(e->physical_constants, e->cosmology, e->internal_units, + e->hydro_properties, e->chemistry, p); + + /* Final time-step is minimum of hydro, gravity and subgrid */ + float new_dt = + min4(new_dt_hydro, new_dt_cooling, new_dt_grav, new_dt_chemistry); /* Limit change in smoothing length */ const float dt_h_change =