From d7ad8d65f8b93471f38c62c75baaf7f74a15e2a7 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Tue, 25 Jul 2017 09:12:34 +0100
Subject: [PATCH] Use the top-level cell size and not the super-cell size to
 compute the MM cut-off distance.

---
 examples/EAGLE_100/eagle_100.yml     | 8 ++++++++
 examples/EAGLE_12/eagle_12.yml       | 4 +++-
 examples/EAGLE_25/eagle_25.yml       | 5 +++--
 examples/UniformDMBox/uniformBox.yml | 3 ++-
 src/runner_doiact_grav.h             | 6 ++++--
 5 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/examples/EAGLE_100/eagle_100.yml b/examples/EAGLE_100/eagle_100.yml
index a9b83b81f0..54e56794c8 100644
--- a/examples/EAGLE_100/eagle_100.yml
+++ b/examples/EAGLE_100/eagle_100.yml
@@ -23,6 +23,14 @@ Snapshots:
 Statistics:
   delta_time:          1e-2 # Time between statistics output
 
+# Parameters for the self-gravity scheme
+Gravity:
+  eta:                   0.025    # Constant dimensionless multiplier for time integration. 
+  epsilon:               0.0001   # Softening length (in internal units).
+  theta:                 0.7      # Opening angle (Multipole acceptance criterion)
+  a_smooth:              1.25     # PM smoothing scale in top-level cell-size units
+  r_cut:                 4.5      # Distance beyong wwhich FMM forces are zero in top-level cell-size units
+  
 # Parameters for the hydrodynamics scheme
 SPH:
   resolution_eta:        1.2348   # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
diff --git a/examples/EAGLE_12/eagle_12.yml b/examples/EAGLE_12/eagle_12.yml
index b4697f96d4..4bb04e757f 100644
--- a/examples/EAGLE_12/eagle_12.yml
+++ b/examples/EAGLE_12/eagle_12.yml
@@ -26,8 +26,10 @@ Statistics:
 # Parameters for the self-gravity scheme
 Gravity:
   eta:                   0.025    # Constant dimensionless multiplier for time integration.
-  theta:                 0.7      # Opening angle (Multipole acceptance criterion)
   epsilon:               0.0001   # Softening length (in internal units).
+  theta:                 0.7      # Opening angle (Multipole acceptance criterion)
+  a_smooth:              1.25     # PM smoothing scale in top-level cell-size units
+  r_cut:                 4.5      # Distance beyong wwhich FMM forces are zero in top-level cell-size un
   
 # Parameters for the hydrodynamics scheme
 SPH:
diff --git a/examples/EAGLE_25/eagle_25.yml b/examples/EAGLE_25/eagle_25.yml
index c755768bcf..8920fb89a9 100644
--- a/examples/EAGLE_25/eagle_25.yml
+++ b/examples/EAGLE_25/eagle_25.yml
@@ -27,8 +27,9 @@ Statistics:
 Gravity:
   eta:                   0.025    # Constant dimensionless multiplier for time integration. 
   epsilon:               0.0001   # Softening length (in internal units).
-  a_smooth:              1000.
-  r_cut:                 4.
+  theta:                 0.7      # Opening angle (Multipole acceptance criterion)
+  a_smooth:              1.25     # PM smoothing scale in top-level cell-size units
+  r_cut:                 4.5      # Distance beyong wwhich FMM forces are zero in top-level cell-size units
   
 # Parameters for the hydrodynamics scheme
 SPH:
diff --git a/examples/UniformDMBox/uniformBox.yml b/examples/UniformDMBox/uniformBox.yml
index cffd442a9a..dd8ea53a20 100644
--- a/examples/UniformDMBox/uniformBox.yml
+++ b/examples/UniformDMBox/uniformBox.yml
@@ -28,7 +28,8 @@ Gravity:
   eta:                   0.025    # Constant dimensionless multiplier for time integration. 
   theta:                 0.7      # Opening angle (Multipole acceptance criterion)
   epsilon:               0.00001  # Softening length (in internal units).
-  
+  a_smooth:              1.25     # PM smoothing scale in top-level cell-size units
+  r_cut:                 4.5      # Distance beyong wwhich FMM forces are zero in top-level cell-size un  
 # Parameters governing the conserved quantities statistics
 Statistics:
   delta_time:          1e-2 # Time between statistics output
diff --git a/src/runner_doiact_grav.h b/src/runner_doiact_grav.h
index d8e82c313e..f4ee414cae 100644
--- a/src/runner_doiact_grav.h
+++ b/src/runner_doiact_grav.h
@@ -180,9 +180,10 @@ void runner_dopair_grav_pp(struct runner *r, struct cell *ci, struct cell *cj) {
   const struct engine *e = r->e;
   const struct space *s = e->s;
   const int periodic = s->periodic;
+  const double cell_width = s->width[0];
   const double dim[3] = {s->dim[0], s->dim[1], s->dim[2]};
   const float a_smooth = e->gravity_properties->a_smooth;
-  const float rlr_inv = 1. / (a_smooth * ci->super->width[0]);
+  const float rlr_inv = 1. / (a_smooth * cell_width);
 
   /* Cell properties */
   const int gcount_i = ci->gcount;
@@ -336,8 +337,9 @@ void runner_doself_grav_pp(struct runner *r, struct cell *c) {
   const struct engine *e = r->e;
   const struct space *s = e->s;
   const int periodic = s->periodic;
+  const double cell_width = s->width[0];
   const float a_smooth = e->gravity_properties->a_smooth;
-  const float rlr_inv = 1. / (a_smooth * c->super->width[0]);
+  const float rlr_inv = 1. / (a_smooth * cell_width);
 
   /* Cell properties */
   const int gcount = c->gcount;
-- 
GitLab