From 9f080da53021a1008596cb27ad895ee97d4cf867 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Tue, 17 Sep 2019 11:30:08 +0200 Subject: [PATCH] Change the behaviour of the initial stellar birth time overwrite parameter. --- .../stellar_evolution.yml | 3 ++- .../StellarEvolution/stellar_evolution.yml | 3 ++- examples/parameter_example.yml | 3 ++- src/stars/EAGLE/stars.h | 2 +- src/stars/EAGLE/stars_io.h | 11 +++++++++-- src/stars/EAGLE/stars_part.h | 7 +++++-- 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/examples/SubgridTests/CosmologicalStellarEvolution/stellar_evolution.yml b/examples/SubgridTests/CosmologicalStellarEvolution/stellar_evolution.yml index 9b8c3e34da..b3d318d68b 100644 --- a/examples/SubgridTests/CosmologicalStellarEvolution/stellar_evolution.yml +++ b/examples/SubgridTests/CosmologicalStellarEvolution/stellar_evolution.yml @@ -40,7 +40,8 @@ SPH: # Properties of the stars Stars: - birth_time: 0.00991 # Give the star in the ICs a decent birth time + overwrite_birth_time: 1 + birth_time: 0.00991 # Give the star in the ICs a decent birth time # Parameters related to the initial conditions InitialConditions: diff --git a/examples/SubgridTests/StellarEvolution/stellar_evolution.yml b/examples/SubgridTests/StellarEvolution/stellar_evolution.yml index 230ce6c8b8..63c7a4d262 100644 --- a/examples/SubgridTests/StellarEvolution/stellar_evolution.yml +++ b/examples/SubgridTests/StellarEvolution/stellar_evolution.yml @@ -34,7 +34,8 @@ SPH: # Properties of the stars Stars: - birth_time: 0. # Give the star in the ICs a decent birth time + overwrite_birth_time: 1 + birth_time: 0. # Give the star in the ICs a decent birth time # Parameters related to the initial conditions InitialConditions: diff --git a/examples/parameter_example.yml b/examples/parameter_example.yml index db7b8fddc4..1d09719e01 100644 --- a/examples/parameter_example.yml +++ b/examples/parameter_example.yml @@ -54,7 +54,8 @@ Stars: h_tolerance: 1e-4 # (Optional) Relative accuracy of the Netwon-Raphson scheme for the smoothing lengths. Defaults to the SPH value. max_ghost_iterations: 30 # (Optional) Maximal number of iterations allowed to converge towards the smoothing length. Defaults to the SPH value. max_volume_change: 1.4 # (Optional) Maximal allowed change of kernel volume over one time-step. Defaults to the SPH value. - birth_time: -1 # (Optional) Initial birth time of *all* the stars. If not -1, this value will overwrite all the values read from the ICs. + overwrite_birth_time: 0 # (Optional) Do we want to overwrite the birth time of the stars read from the ICs? (default: 0). + birth_time: -1 # (Optional) Initial birth times of *all* the stars to be used if we are overwriting them. (-1 means the stars remain inactive feedback-wise througout the run). # Parameters for the self-gravity scheme Gravity: diff --git a/src/stars/EAGLE/stars.h b/src/stars/EAGLE/stars.h index f102ddb22c..82ad2e25f4 100644 --- a/src/stars/EAGLE/stars.h +++ b/src/stars/EAGLE/stars.h @@ -65,7 +65,7 @@ __attribute__((always_inline)) INLINE static void stars_first_init_spart( sp->time_bin = 0; sp->birth_density = 0.f; sp->f_E = -1.f; - if (stars_properties->spart_first_init_birth_time != -1.f) + if (stars_properties->overwrite_birth_time) sp->birth_time = stars_properties->spart_first_init_birth_time; stars_init_spart(sp); diff --git a/src/stars/EAGLE/stars_io.h b/src/stars/EAGLE/stars_io.h index b91b5cf945..fc898c5587 100644 --- a/src/stars/EAGLE/stars_io.h +++ b/src/stars/EAGLE/stars_io.h @@ -217,8 +217,11 @@ INLINE static void stars_props_init(struct stars_props *sp, else sp->log_max_h_change = logf(powf(max_volume_change, hydro_dimension_inv)); - /* Read birth time to set all stars in ICs to (defaults to -1 to indicate star - * present in ICs) */ + /* Do we want to overwrite the stars' birth time? */ + sp->overwrite_birth_time = + parser_get_opt_param_int(params, "Stars:overwrite_birth_time", 0); + + /* Read birth time to set all stars in ICs */ sp->spart_first_init_birth_time = parser_get_opt_param_float(params, "Stars:birth_time", -1.f); } @@ -244,6 +247,10 @@ INLINE static void stars_props_print(const struct stars_props *sp) { message("Maximal iterations in ghost task set to %d", sp->max_smoothing_iterations); + + if (sp->overwrite_birth_time) + message("Stars' birth time read from the ICs will be overwritten to %f", + sp->spart_first_init_birth_time); } #if defined(HAVE_HDF5) diff --git a/src/stars/EAGLE/stars_part.h b/src/stars/EAGLE/stars_part.h index 4502b10edb..9114cb9107 100644 --- a/src/stars/EAGLE/stars_part.h +++ b/src/stars/EAGLE/stars_part.h @@ -144,7 +144,7 @@ struct stars_props { /*! Smoothing length tolerance */ float h_tolerance; - /*! Tolerance on neighbour number (for info only)*/ + /*! Tolerance on neighbour number (for info only) */ float delta_neighbours; /*! Maximal number of iterations to converge h */ @@ -153,7 +153,10 @@ struct stars_props { /*! Maximal change of h over one time-step */ float log_max_h_change; - /*! Value to set birth time of stars read from ICs if not set to -1 */ + /*! Are we overwriting the stars' birth time read from the ICs? */ + int overwrite_birth_time; + + /*! Value to set birth time of stars read from ICs */ float spart_first_init_birth_time; }; -- GitLab