diff --git a/src/space.c b/src/space.c index 8e9b4543bd756b82f94479077e0f039fe061609d..575016fcdb11c85f1099aeeedbd4c13b6d408019 100644 --- a/src/space.c +++ b/src/space.c @@ -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); diff --git a/src/stars/Default/stars.h b/src/stars/Default/stars.h index 804fe6085d7b420955ab04c099c12e32f6a6929c..85e92c199b08f21d09b2713a3d09537812c510b0 100644 --- a/src/stars/Default/stars.h +++ b/src/stars/Default/stars.h @@ -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; } diff --git a/src/stars/EAGLE/stars.h b/src/stars/EAGLE/stars.h index e9ea6ed0b8d2398f2a75b37430a295f62b3b22e8..644acfcbf7161cb00667cbe401277699f6c66123 100644 --- a/src/stars/EAGLE/stars.h +++ b/src/stars/EAGLE/stars.h @@ -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); } diff --git a/src/stars/GEAR/stars.h b/src/stars/GEAR/stars.h index 467aaa164ba9762d85f8dfae85db86ff76ae779e..2fe4428b811af64e63bdde3bb3a3bb7f030f4d82 100644 --- a/src/stars/GEAR/stars.h +++ b/src/stars/GEAR/stars.h @@ -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; }