From f6c33e0a2ef35b38116a3b340e258bb947852c21 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Sat, 30 Jun 2018 17:39:41 +0200 Subject: [PATCH] Do not read the comoving softening from the yaml file if not running with cosmology switched on. --- examples/main.c | 2 +- src/gravity_properties.c | 16 +++++++++++----- src/gravity_properties.h | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/examples/main.c b/examples/main.c index d7e187857a..d1a82bbdc3 100644 --- a/examples/main.c +++ b/examples/main.c @@ -633,7 +633,7 @@ int main(int argc, char *argv[]) { /* Initialise the gravity properties */ if (with_self_gravity) - gravity_props_init(&gravity_properties, params, &cosmo); + gravity_props_init(&gravity_properties, params, &cosmo, with_cosmology); /* Read particles and space information from (GADGET) ICs */ char ICfileName[200] = ""; diff --git a/src/gravity_properties.c b/src/gravity_properties.c index 84ce90f727..22856c25fb 100644 --- a/src/gravity_properties.c +++ b/src/gravity_properties.c @@ -39,7 +39,7 @@ #define gravity_props_default_rebuild_frequency 0.01f void gravity_props_init(struct gravity_props *p, struct swift_params *params, - const struct cosmology *cosmo) { + const struct cosmology *cosmo, int with_cosmology) { /* Tree updates */ p->rebuild_frequency = @@ -74,10 +74,16 @@ void gravity_props_init(struct gravity_props *p, struct swift_params *params, p->theta_crit_inv = 1. / p->theta_crit; /* Softening parameters */ - p->epsilon_comoving = - parser_get_param_double(params, "Gravity:comoving_softening"); - p->epsilon_max_physical = - parser_get_param_double(params, "Gravity:max_physical_softening"); + if (with_cosmology) { + p->epsilon_comoving = + parser_get_param_double(params, "Gravity:comoving_softening"); + p->epsilon_max_physical = + parser_get_param_double(params, "Gravity:max_physical_softening"); + } else { + p->epsilon_max_physical = + parser_get_param_double(params, "Gravity:max_physical_softening"); + p->epsilon_comoving = p->epsilon_max_physical; + } /* Set the softening to the current time */ gravity_update(p, cosmo); diff --git a/src/gravity_properties.h b/src/gravity_properties.h index 1d230b8c37..62dbab3605 100644 --- a/src/gravity_properties.h +++ b/src/gravity_properties.h @@ -88,7 +88,7 @@ struct gravity_props { void gravity_props_print(const struct gravity_props *p); void gravity_props_init(struct gravity_props *p, struct swift_params *params, - const struct cosmology *cosmo); + const struct cosmology *cosmo, int with_cosmology); void gravity_update(struct gravity_props *p, const struct cosmology *cosmo); #if defined(HAVE_HDF5) -- GitLab