Commit 4d62e1b1 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Only read the DM softenings if we have DM particles. Same fr baryons.

parent 559623a8
......@@ -951,6 +951,11 @@ int main(int argc, char *argv[]) {
N_total[swift_type_black_hole], N_total[swift_type_dark_matter],
N_total[swift_type_dark_matter_background]);
const int with_DM_particles = N_total[swift_type_dark_matter] > 0;
const int with_baryon_particles =
(N_total[swift_type_gas] + N_total[swift_type_stars] +
N_total[swift_type_black_hole]) > 0;
/* Do we have background DM particles? */
const int with_DM_background_particles =
N_total[swift_type_dark_matter_background] > 0;
......@@ -976,7 +981,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,
with_cosmology, with_DM_background_particles,
with_cosmology, with_baryon_particles,
with_DM_particles, with_DM_background_particles,
periodic);
/* Initialise the external potential properties */
......
......@@ -497,6 +497,11 @@ int main(int argc, char *argv[]) {
N_total[swift_type_black_hole], N_total[swift_type_dark_matter],
N_total[swift_type_dark_matter_background]);
const int with_DM_particles = N_total[swift_type_dark_matter] > 0;
const int with_baryon_particles =
(N_total[swift_type_gas] + N_total[swift_type_stars] +
N_total[swift_type_black_hole]) > 0;
/* Do we have background DM particles? */
const int with_DM_background_particles =
N_total[swift_type_dark_matter_background] > 0;
......@@ -519,8 +524,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,
/*with_cosmology=*/1, with_DM_background_particles,
periodic);
/*with_cosmology=*/1, with_baryon_particles,
with_DM_particles, with_DM_background_particles, periodic);
/* Initialise the long-range gravity mesh */
if (periodic) {
......
......@@ -41,6 +41,7 @@
void gravity_props_init(struct gravity_props *p, struct swift_params *params,
const struct phys_const *phys_const,
const struct cosmology *cosmo, const int with_cosmology,
const int has_baryons, const int has_DM,
const int is_zoom_simulation, const int periodic) {
/* Tree updates */
......@@ -90,17 +91,25 @@ void gravity_props_init(struct gravity_props *p, struct swift_params *params,
/* Softening parameters */
if (with_cosmology) {
/* Maximal physical softening taken straight from the parameter file */
p->epsilon_DM_max_physical =
parser_get_param_double(params, "Gravity:max_physical_DM_softening");
p->epsilon_baryon_max_physical = parser_get_param_double(
params, "Gravity:max_physical_baryon_softening");
if (has_DM) {
/* Maximal physical softening taken straight from the parameter file */
p->epsilon_DM_max_physical =
parser_get_param_double(params, "Gravity:max_physical_DM_softening");
/* Co-moving softenings taken straight from the parameter file */
p->epsilon_DM_comoving =
parser_get_param_double(params, "Gravity:comoving_DM_softening");
p->epsilon_baryon_comoving =
parser_get_param_double(params, "Gravity:comoving_baryon_softening");
/* Co-moving softenings taken straight from the parameter file */
p->epsilon_DM_comoving =
parser_get_param_double(params, "Gravity:comoving_DM_softening");
}
if (has_baryons) {
/* Maximal physical softening taken straight from the parameter file */
p->epsilon_baryon_max_physical = parser_get_param_double(
params, "Gravity:max_physical_baryon_softening");
/* Co-moving softenings taken straight from the parameter file */
p->epsilon_baryon_comoving =
parser_get_param_double(params, "Gravity:comoving_baryon_softening");
}
if (is_zoom_simulation) {
......@@ -122,10 +131,14 @@ void gravity_props_init(struct gravity_props *p, struct swift_params *params,
} else {
p->epsilon_DM_max_physical =
parser_get_param_double(params, "Gravity:max_physical_DM_softening");
p->epsilon_baryon_max_physical = parser_get_param_double(
params, "Gravity:max_physical_baryon_softening");
if (has_DM) {
p->epsilon_DM_max_physical =
parser_get_param_double(params, "Gravity:max_physical_DM_softening");
}
if (has_baryons) {
p->epsilon_baryon_max_physical = parser_get_param_double(
params, "Gravity:max_physical_baryon_softening");
}
p->epsilon_DM_comoving = p->epsilon_DM_max_physical;
p->epsilon_baryon_comoving = p->epsilon_baryon_max_physical;
......
......@@ -120,6 +120,7 @@ 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 int with_cosmology,
const int has_baryons, const int has_DM,
const int is_zoom_simulation, const int periodic);
void gravity_props_update(struct gravity_props *p,
const struct cosmology *cosmo);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment