Commit 71b27da6 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Added a new time-step condition for cosmological runs based on the maximal RMS displacement.

parent 36e0939c
......@@ -5421,6 +5421,9 @@ void engine_init(struct engine *e, struct space *s,
e->snapshot_output_count = 0;
e->dt_min = parser_get_param_double(params, "TimeIntegration:dt_min");
e->dt_max = parser_get_param_double(params, "TimeIntegration:dt_max");
e->dt_max_RMS_displacement = FLT_MAX;
e->max_RMS_displacement_factor =
parser_get_param_double(params, "TimeIntegration:max_RMS_factor");
e->a_first_statistics =
parser_get_opt_param_double(params, "Statistics:scale_factor_first", 0.1);
e->time_first_statistics =
......
......@@ -125,6 +125,12 @@ struct engine {
/* The minimum and maximum allowed dt */
double dt_min, dt_max;
/* Maximum time-step allowed by the RMS condition in cosmology runs. */
double dt_max_RMS_displacement;
/* Dimensionless factor for the RMS time-step condition. */
double max_RMS_displacement_factor;
/* Time of the simulation beginning */
double time_begin;
......
......@@ -84,6 +84,9 @@ __attribute__((always_inline)) INLINE static integertime_t get_gpart_timestep(
/* Take the minimum of all */
float new_dt = min(new_dt_self, new_dt_ext);
/* Apply the maximal displacement constraint (FLT_MAX if non-cosmological)*/
new_dt = min(new_dt, e->dt_max_RMS_displacement);
/* Apply cosmology correction (This is 1 if non-cosmological) */
new_dt *= e->cosmology->time_step_factor;
......@@ -140,7 +143,7 @@ __attribute__((always_inline)) INLINE static integertime_t get_part_timestep(
/* Final time-step is minimum of hydro and gravity */
float new_dt = min3(new_dt_hydro, new_dt_cooling, new_dt_grav);
/* Limit change in h */
/* Limit change in smoothing length */
const float dt_h_change =
(p->force.h_dt != 0.0f)
? fabsf(e->hydro_properties->log_max_h_change * p->h / p->force.h_dt)
......@@ -148,6 +151,9 @@ __attribute__((always_inline)) INLINE static integertime_t get_part_timestep(
new_dt = min(new_dt, dt_h_change);
/* Apply the maximal displacement constraint (FLT_MAX if non-cosmological)*/
new_dt = min(new_dt, e->dt_max_RMS_displacement);
/* Apply cosmology correction (This is 1 if non-cosmological) */
new_dt *= e->cosmology->time_step_factor;
......@@ -191,6 +197,9 @@ __attribute__((always_inline)) INLINE static integertime_t get_spart_timestep(
/* Take the minimum of all */
float new_dt = min3(new_dt_star, new_dt_self, new_dt_ext);
/* Apply the maximal displacement constraint (FLT_MAX if non-cosmological)*/
new_dt = min(new_dt, e->dt_max_RMS_displacement);
/* Apply cosmology correction (This is 1 if non-cosmological) */
new_dt *= e->cosmology->time_step_factor;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment