diff --git a/src/runner.c b/src/runner.c index c444fe9e1796f8a03fc44e2be155a6dcb364e63d..9a5a461237984ff413c2eba2e2c796299ef6e8be 100644 --- a/src/runner.c +++ b/src/runner.c @@ -1664,13 +1664,18 @@ void runner_do_end_force(struct runner *r, struct cell *c, int timer) { struct spart *restrict sparts = c->sparts; const int periodic = s->periodic; const float G_newton = e->physical_constants->const_newton_G; - const double r_s = e->mesh->r_s; - const double volume = s->dim[0] * s->dim[1] * s->dim[2]; - const float potential_normalisation = - 4. * M_PI * e->total_mass * r_s * r_s / volume; TIMER_TIC; + /* Potential normalisation in the case of periodic gravity */ + float potential_normalisation = 0.; + if (periodic && (e->policy & engine_policy_self_gravity)) { + const double volume = s->dim[0] * s->dim[1] * s->dim[2]; + const double r_s = e->mesh->r_s; + potential_normalisation = + 4. * M_PI * e->total_mass * r_s * r_s / volume; + } + /* Anything to do here? */ if (!cell_is_active_hydro(c, e) && !cell_is_active_gravity(c, e)) return;