From 0a234e1b9ae8a08f55d21b186733c9fe12dcb232 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Thu, 8 Aug 2019 19:16:13 +0200 Subject: [PATCH] Update the gravity_props_init() function. --- examples/main.c | 3 ++- examples/main_fof.c | 3 ++- src/gravity_properties.c | 32 +++++++++++++++++--------------- src/gravity_properties.h | 5 ++--- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/examples/main.c b/examples/main.c index 421903b801..a8cbd8ca7f 100644 --- a/examples/main.c +++ b/examples/main.c @@ -971,7 +971,8 @@ int main(int argc, char *argv[]) { bzero(&gravity_properties, sizeof(struct gravity_props)); if (with_self_gravity) gravity_props_init(&gravity_properties, params, &prog_const, &cosmo, - high_res_DM_mass, with_cosmology, periodic); + with_cosmology, with_DM_background_particles, + periodic); /* Initialise the external potential properties */ bzero(&potential, sizeof(struct external_potential)); diff --git a/examples/main_fof.c b/examples/main_fof.c index cd2b61b0b7..9b2f5dbcbb 100644 --- a/examples/main_fof.c +++ b/examples/main_fof.c @@ -519,7 +519,8 @@ int main(int argc, char *argv[]) { /* Initialise the gravity scheme */ bzero(&gravity_properties, sizeof(struct gravity_props)); gravity_props_init(&gravity_properties, params, &prog_const, &cosmo, - high_res_DM_mass, /*with_cosmology=*/1, periodic); + /*with_cosmology=*/1, with_DM_background_particles, + periodic); /* Initialise the long-range gravity mesh */ if (periodic) { diff --git a/src/gravity_properties.c b/src/gravity_properties.c index e45845dbd8..49f7433f7a 100644 --- a/src/gravity_properties.c +++ b/src/gravity_properties.c @@ -40,9 +40,8 @@ void gravity_props_init(struct gravity_props *p, struct swift_params *params, const struct phys_const *phys_const, - const struct cosmology *cosmo, - const double high_res_DM_mass, const int with_cosmology, - const int periodic) { + const struct cosmology *cosmo, const int with_cosmology, + const int is_zoom_simulation, const int periodic) { /* Tree updates */ p->rebuild_frequency = @@ -103,20 +102,23 @@ void gravity_props_init(struct gravity_props *p, struct swift_params *params, p->epsilon_baryon_comoving = parser_get_param_double(params, "Gravity:comoving_baryon_softening"); - /* Compute the comoving softening length for background particles as - * a fraction of the mean inter-particle density of the background DM - * particles Since they have variable masses the mass factor will be - * multiplied in later on. Note that we already multiply in the conversion - * from Plummer -> real softening length */ - const double ratio_background = - parser_get_param_double(params, "Gravity:softening_ratio_background"); + if (is_zoom_simulation) { - const double mean_matter_density = - cosmo->Omega_m * cosmo->critical_density_0; + /* Compute the comoving softening length for background particles as + * a fraction of the mean inter-particle density of the background DM + * particles Since they have variable masses the mass factor will be + * multiplied in later on. Note that we already multiply in the conversion + * from Plummer -> real softening length */ + const double ratio_background = + parser_get_param_double(params, "Gravity:softening_ratio_background"); - p->epsilon_background_fac = kernel_gravity_softening_plummer_equivalent * - ratio_background * - cbrt(1. / mean_matter_density); + const double mean_matter_density = + cosmo->Omega_m * cosmo->critical_density_0; + + p->epsilon_background_fac = kernel_gravity_softening_plummer_equivalent * + ratio_background * + cbrt(1. / mean_matter_density); + } } else { diff --git a/src/gravity_properties.h b/src/gravity_properties.h index 3bcdd3ed29..2b1fb00a28 100644 --- a/src/gravity_properties.h +++ b/src/gravity_properties.h @@ -119,9 +119,8 @@ 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 phys_const *phys_const, - const struct cosmology *cosmo, - const double high_res_DM_mass, const int with_cosmology, - const int periodic); + const struct cosmology *cosmo, const int with_cosmology, + const int is_zoom_simulation, const int periodic); void gravity_props_update(struct gravity_props *p, const struct cosmology *cosmo); -- GitLab