From c3c9903a03b684a25d27cb5ea42f62f19ee6039e Mon Sep 17 00:00:00 2001 From: Loic Hausammann <loic.hausammann@protonmail.ch> Date: Thu, 14 Oct 2021 20:55:09 +0000 Subject: [PATCH] Use only min mass gas in time step --- .../ParameterFiles/parameter_description.rst | 19 ++++++++++++------- examples/GEAR/AgoraCosmo/agora_cosmo.yml | 1 + examples/GEAR/ZoomIn/zoom_in.yml | 3 ++- examples/parameter_example.yml | 13 +++++++------ src/engine.c | 11 ++++++++--- src/engine.h | 4 ++++ 6 files changed, 34 insertions(+), 17 deletions(-) diff --git a/doc/RTD/source/ParameterFiles/parameter_description.rst b/doc/RTD/source/ParameterFiles/parameter_description.rst index f29d5a6b47..45b68c9e9c 100644 --- a/doc/RTD/source/ParameterFiles/parameter_description.rst +++ b/doc/RTD/source/ParameterFiles/parameter_description.rst @@ -601,9 +601,13 @@ the start and end times or scale factors from the parameter file. * Dimensionless pre-factor of the maximal allowed displacement: ``max_dt_RMS_factor`` (default: ``0.25``) - -This value rarely needs altering. See the theory documents for its -precise meaning. +* Whether or not only the gas particle masses should be considered for + the baryon component of the calculation: ``dt_RMS_use_gas_only`` (default: ``0``) + +These values rarely need altering. The second parameter is only +meaningful if a subgrid model produces star (or other) particles with +masses substantially smaller than the gas masses. See the theory +documents for the precise meanings. A full time-step section for a non-cosmological run would be: @@ -620,10 +624,11 @@ Whilst for a cosmological run, one would need: .. code:: YAML TimeIntegration: - dt_max: 1e-4 - dt_min: 1e-10 - max_dt_RMS_factor: 0.25 # Default optional value - + dt_max: 1e-4 + dt_min: 1e-10 + max_dt_RMS_factor: 0.25 # Default optional value + dt_RMS_use_gas_only: 0 # Default optional value + .. _Parameters_ICs: Initial Conditions diff --git a/examples/GEAR/AgoraCosmo/agora_cosmo.yml b/examples/GEAR/AgoraCosmo/agora_cosmo.yml index 74b4d855b5..b4c4b6b9da 100644 --- a/examples/GEAR/AgoraCosmo/agora_cosmo.yml +++ b/examples/GEAR/AgoraCosmo/agora_cosmo.yml @@ -14,6 +14,7 @@ TimeIntegration: dt_min: 1e-16 # The minimal time-step size of the simulation (in internal units). dt_max: 0.1 # The maximal time-step size of the simulation (in internal units). max_dt_RMS_factor: 0.25 # (Optional) Dimensionless factor for the maximal displacement allowed based on the RMS velocities. + dt_RMS_use_gas_only: 1 # Cosmological parameters Cosmology: diff --git a/examples/GEAR/ZoomIn/zoom_in.yml b/examples/GEAR/ZoomIn/zoom_in.yml index feb87d67b6..9e9135d04d 100644 --- a/examples/GEAR/ZoomIn/zoom_in.yml +++ b/examples/GEAR/ZoomIn/zoom_in.yml @@ -19,7 +19,8 @@ TimeIntegration: dt_min: 1e-16 # The minimal time-step size of the simulation (in internal units). dt_max: 0.1 # The maximal time-step size of the simulation (in internal units). max_dt_RMS_factor: 0.25 # (Optional) Dimensionless factor for the maximal displacement allowed based on the RMS velocities. - + dt_RMS_use_gas_only: 1 + # Cosmological parameters Cosmology: h: 0.673 # Reduced Hubble constant diff --git a/examples/parameter_example.yml b/examples/parameter_example.yml index 8239c4c44b..bbc0807bbf 100644 --- a/examples/parameter_example.yml +++ b/examples/parameter_example.yml @@ -143,12 +143,13 @@ Scheduler: # Parameters governing the time integration (Set dt_min and dt_max to the same value for a fixed time-step run.) TimeIntegration: - time_begin: 0. # The starting time of the simulation (in internal units). - time_end: 1. # The end time of the simulation (in internal units). - dt_min: 1e-6 # The minimal time-step size of the simulation (in internal units). - dt_max: 1e-2 # The maximal time-step size of the simulation (in internal units). - max_dt_RMS_factor: 0.25 # (Optional) Dimensionless factor for the maximal displacement allowed based on the RMS velocities. - + time_begin: 0. # The starting time of the simulation (in internal units). + time_end: 1. # The end time of the simulation (in internal units). + dt_min: 1e-6 # The minimal time-step size of the simulation (in internal units). + dt_max: 1e-2 # The maximal time-step size of the simulation (in internal units). + max_dt_RMS_factor: 0.25 # (Optional) Dimensionless factor for the maximal displacement allowed based on the RMS velocities. + dt_RMS_use_gas_only: 0 # (Optional) When computing the max RMS dt, should only the gas particles be considered in the baryon component calculation? + # Parameters governing the snapshots Snapshots: basename: output # Common part of the name of output files. diff --git a/src/engine.c b/src/engine.c index ef2857c5d0..c09a55eb32 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2820,6 +2820,8 @@ void engine_init( e->dt_max_RMS_displacement = FLT_MAX; e->max_RMS_displacement_factor = parser_get_opt_param_double( params, "TimeIntegration:max_dt_RMS_factor", 0.25); + e->max_RMS_dt_use_only_gas = parser_get_opt_param_int( + params, "TimeIntegration:dt_RMS_use_gas_only", 0); e->dt_kick_grav_mesh_for_io = 0.f; e->a_first_statistics = parser_get_opt_param_double(params, "Statistics:scale_factor_first", 0.1); @@ -3115,9 +3117,12 @@ void engine_recompute_displacement_constraint(struct engine *e) { /* Baryon case */ if (N_b > 0.f) { - /* Minimal mass for the baryons */ - const float min_mass_b = - min4(min_mass[0], min_mass[3], min_mass[4], min_mass[5]); + /* Minimal mass for the bayons */ + float min_mass_b; + if (e->max_RMS_dt_use_only_gas) + min_mass_b = min_mass[0]; + else + min_mass_b = min4(min_mass[0], min_mass[3], min_mass[4], min_mass[5]); /* Inter-particle sepration for the baryons */ const float d_b = cbrtf(min_mass_b / (Ob * rho_crit0)); diff --git a/src/engine.h b/src/engine.h index 248df75026..e83c21f192 100644 --- a/src/engine.h +++ b/src/engine.h @@ -163,6 +163,10 @@ struct engine { /* Dimensionless factor for the RMS time-step condition. */ double max_RMS_displacement_factor; + /* When computing the max RMS dt, should only the gas particles + * be considered as the baryon component? */ + int max_RMS_dt_use_only_gas; + /* Time of the simulation beginning */ double time_begin; -- GitLab