Commit 4cc70e4c authored by Matthieu Schaller's avatar Matthieu Schaller

Correctly set the last enrichment time of particles when starting a run.

parent 29114982
......@@ -4383,6 +4383,7 @@ void space_first_init_sparts_mapper(void *restrict map_data, int count,
const float initial_h = s->initial_spart_h;
const int with_feedback = (e->policy & engine_policy_feedback);
const int with_cosmology = (e->policy & engine_policy_cosmology);
const struct cosmology *cosmo = e->cosmology;
const struct stars_props *stars_properties = e->stars_properties;
......@@ -4421,7 +4422,8 @@ void space_first_init_sparts_mapper(void *restrict map_data, int count,
/* Initialise the rest */
for (int k = 0; k < count; k++) {
stars_first_init_spart(&sp[k], stars_properties);
stars_first_init_spart(&sp[k], stars_properties, with_cosmology, cosmo->a,
e->time);
#ifdef WITH_LOGGER
logger_part_data_init(&sp[k].logger_data);
......
......@@ -41,9 +41,14 @@ __attribute__((always_inline)) INLINE static float stars_compute_timestep(
*
* @param sp The particle to act upon
* @param stars_properties The properties of the stellar model.
* @param with_cosmology Are we running with cosmological time integration.
* @param scale_factor The current scale-factor (used if running with
* cosmology).
* @param time The current time (used if running without cosmology).
*/
__attribute__((always_inline)) INLINE static void stars_first_init_spart(
struct spart* sp, const struct stars_props* stars_properties) {
struct spart* sp, const struct stars_props* stars_properties,
const int with_cosmology, const double scale_factor, const double time) {
sp->time_bin = 0;
}
......
......@@ -58,18 +58,27 @@ __attribute__((always_inline)) INLINE static void stars_init_spart(
*
* @param sp The particle to act upon.
* @param stars_properties Properties of the stars model.
* @param with_cosmology Are we running with cosmological time integration.
* @param scale_factor The current scale-factor (used if running with
* cosmology).
* @param time The current time (used if running without cosmology).
*/
__attribute__((always_inline)) INLINE static void stars_first_init_spart(
struct spart* sp, const struct stars_props* stars_properties) {
struct spart* sp, const struct stars_props* stars_properties,
const int with_cosmology, const double scale_factor, const double time) {
sp->time_bin = 0;
sp->birth_density = 0.f;
sp->f_E = -1.f;
sp->count_since_last_enrichment = -1;
if (stars_properties->overwrite_birth_time)
sp->birth_time = stars_properties->spart_first_init_birth_time;
sp->last_enrichment_time = sp->birth_time;
sp->count_since_last_enrichment = -1;
if (with_cosmology)
sp->last_enrichment_time = scale_factor;
else
sp->last_enrichment_time = time;
stars_init_spart(sp);
}
......
......@@ -41,9 +41,14 @@ __attribute__((always_inline)) INLINE static float stars_compute_timestep(
*
* @param sp The particle to act upon
* @param stars_properties The properties of the stellar model.
* @param with_cosmology Are we running with cosmological time integration.
* @param scale_factor The current scale-factor (used if running with
* cosmology).
* @param time The current time (used if running without cosmology).
*/
__attribute__((always_inline)) INLINE static void stars_first_init_spart(
struct spart* sp, const struct stars_props* stars_properties) {
struct spart* sp, const struct stars_props* stars_properties,
const int with_cosmology, const double scale_factor, const double time) {
sp->time_bin = 0;
}
......
Markdown is supported
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