diff --git a/examples/EAGLE_6/eagle_6.yml b/examples/EAGLE_6/eagle_6.yml index a8d43bf4df18d2106150925f33546af806231e3b..0a2a6437e1d762f926f16694140f4514f1b90739 100644 --- a/examples/EAGLE_6/eagle_6.yml +++ b/examples/EAGLE_6/eagle_6.yml @@ -10,9 +10,9 @@ InternalUnitSystem: StructureFinding: config_file_name: stf_input.cfg # Name of the STF config file. basename: ./halo/stf # Common part of the name of output files. - output_time_format: 1 # Specifies format of delta_time. 0 for simulation steps and 1 for simulation time intervals. + output_time_format: 0 # Specifies format of delta_time. 0 for simulation steps and 1 for simulation time intervals. time_first: 0. # Time of the first structure finding output (in internal units). - delta_time: 1e-5 # Time difference between consecutive structure finding outputs (in internal units). Can either be given in simulation steps or simulation time intervals. + delta_time: 5 # Time difference between consecutive structure finding outputs (in internal units). Can either be given in simulation steps or simulation time intervals. # Define the system of units to use int VELOCIraptor. VelociraptorUnitSystem: @@ -44,7 +44,7 @@ TimeIntegration: # Parameters governing the snapshots Snapshots: basename: eagle # Common part of the name of output files - time_first: 0. # Time of the first output (in internal units) + time_first: 1. # Time of the first output (in internal units) delta_time: 1e-3 # Time difference between consecutive outputs (in internal units) compression: 4 diff --git a/src/engine.c b/src/engine.c index 842832a9e0bcf61810dba034ecfe55847b9040c2..c43565581f1a59de155d23c320c03bd4811cb6c1 100644 --- a/src/engine.c +++ b/src/engine.c @@ -4491,7 +4491,7 @@ void engine_step(struct engine *e) { /* Do we want to perform structure finding? */ if ((e->policy & engine_policy_structure_finding)) { - if(e->stf_output_freq_format == IO_STF_OUTPUT_FREQ_FORMAT_STEPS && e->step%(int)e->delta_time_stf_freq == 0) + if(e->stf_output_freq_format == IO_STF_OUTPUT_FREQ_FORMAT_STEPS && e->step%(int)e->deltaTimeSTF == 0) e->run_stf = 1; else if(e->stf_output_freq_format == IO_STF_OUTPUT_FREQ_FORMAT_TIME && e->ti_end_min >= e->ti_nextSTF && e->ti_nextSTF > 0) e->run_stf = 1; @@ -5356,7 +5356,7 @@ void engine_config(int restart, struct engine *e, e->restart_file = restart_file; e->restart_next = 0; e->restart_dt = 0; - e->delta_time_stf_freq = 0; + e->deltaTimeSTF = 0; e->stf_output_freq_format = 0; e->ti_nextSTF = 0; e->run_stf = 0; @@ -5365,13 +5365,14 @@ void engine_config(int restart, struct engine *e, /* Initialise VELOCIraptor. */ if (e->policy & engine_policy_structure_finding) { parser_get_param_string(params, "StructureFinding:basename", e->stfBaseName); + e->timeFirstSTFOutput = parser_get_param_double(params, "StructureFinding:time_first"); velociraptor_init(e); e->stf_output_freq_format = parser_get_param_int(params, "StructureFinding:output_time_format"); if(e->stf_output_freq_format == IO_STF_OUTPUT_FREQ_FORMAT_STEPS) { - e->delta_time_stf_freq = (double)parser_get_param_int(params, "StructureFinding:delta_time"); + e->deltaTimeSTF = (double)parser_get_param_int(params, "StructureFinding:delta_time"); } else if(e->stf_output_freq_format == IO_STF_OUTPUT_FREQ_FORMAT_TIME) { - e->delta_time_stf_freq = parser_get_param_double(params, "StructureFinding:delta_time"); + e->deltaTimeSTF = parser_get_param_double(params, "StructureFinding:delta_time"); } else error("Invalid flag (%d) set for output time format of structure finding.", e->stf_output_freq_format); } @@ -5642,6 +5643,15 @@ void engine_config(int restart, struct engine *e, "Time of first snapshot (%e) must be after the simulation start t=%e.", e->timeFirstSnapshot, e->time_begin); + if (e->deltaTimeSTF < 0.) + error("Time between STF (%e) must be positive.", + e->deltaTimeSTF); + + if (e->timeFirstSTFOutput < e->time_begin) + error( + "Time of first STF (%e) must be after the simulation start t=%e.", + e->timeFirstSTFOutput, e->time_begin); + /* Find the time of the first stf output */ if(e->stf_output_freq_format == IO_STF_OUTPUT_FREQ_FORMAT_TIME) { engine_compute_next_stf_time(e); @@ -5841,7 +5851,7 @@ void engine_compute_next_snapshot_time(struct engine *e) { time_end = e->time_end + e->deltaTimeSnapshot; /* Find next snasphot above current time */ - double time = e->timeFirstSnapshot; + double time = e->timeFirstSTFOutput; while (time < time_end) { /* Output time on the integer timeline */ @@ -5887,19 +5897,15 @@ void engine_compute_next_snapshot_time(struct engine *e) { */ void engine_compute_next_stf_time(struct engine *e) { - message("dt: %lf", e->delta_time_stf_freq); /* Find upper-bound on last output */ double time_end; if (e->policy & engine_policy_cosmology) - time_end = e->cosmology->a_end * e->delta_time_stf_freq; + time_end = e->cosmology->a_end * e->deltaTimeSTF; else - time_end = e->time_end + e->delta_time_stf_freq; + time_end = e->time_end + e->deltaTimeSTF; /* Find next snasphot above current time */ - double time = e->timeFirstSnapshot; - - message("time: %lf, time_end: %lf", time, e->time_end); - message("dt: %lf", e->delta_time_stf_freq); + double time = e->timeFirstSTFOutput; while (time < time_end) { @@ -5913,9 +5919,9 @@ void engine_compute_next_stf_time(struct engine *e) { if (e->ti_nextSTF > e->ti_current) break; if (e->policy & engine_policy_cosmology) - time *= e->delta_time_stf_freq; + time *= e->deltaTimeSTF; else - time += e->delta_time_stf_freq; + time += e->deltaTimeSTF; } /* Deal with last snapshot */ diff --git a/src/engine.h b/src/engine.h index 2a9c275f01349ad854761959b7e672505dbb362d..6f94b514114d539b9c72935c47b2764f036dddee 100644 --- a/src/engine.h +++ b/src/engine.h @@ -204,7 +204,8 @@ struct engine { /* Structure finding information */ int run_stf; int stf_output_freq_format; - double delta_time_stf_freq; + double timeFirstSTFOutput; + double deltaTimeSTF; integertime_t ti_nextSTF; char stfBaseName[PARSER_MAX_LINE_SIZE];