diff --git a/examples/main.c b/examples/main.c index 421903b8018ad06c84f9798182a92a5072df28cd..a8cbd8ca7fb0d0eb9ef8fa58d27ca997c4c4a8d4 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 cd2b61b0b79a1e79b9dfe2619ab155a5d0ddfb1b..9b2f5dbcbbed0197d0c1762889f0676d69b62c9b 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 e45845dbd8e1ce5d600ceb71607d3a36e7657670..49f7433f7a0c3ecbce26e9abf93365f6764d3317 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 3bcdd3ed297eb65b11eac5273cc78ea016869a40..2b1fb00a28e6917e6045ed8de42ab65cdc03689c 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);