From 27e34653d25275eea1fad42f540e32ce14e55f93 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Tue, 5 Jun 2018 16:21:15 +0200
Subject: [PATCH] In the gravity checking script verbosely renormalize the
 potentials

---
 examples/plot_gravity_checks.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/examples/plot_gravity_checks.py b/examples/plot_gravity_checks.py
index ca4e17c7c8..1a3d1b014e 100644
--- a/examples/plot_gravity_checks.py
+++ b/examples/plot_gravity_checks.py
@@ -200,12 +200,18 @@ for i in range(num_order):
         print "Comparing different positions ! max difference:"
         index = np.argmax(exact_pos[:,0]**2 + exact_pos[:,1]**2 + exact_pos[:,2]**2 - pos[:,0]**2 - pos[:,1]**2 - pos[:,2]**2)
         print "SWIFT (id=%d):"%ids[index], pos[index,:], "exact (id=%d):"%exact_ids[index], exact_pos[index,:], "\n"
-
     
     # Compute the error norm
     diff = exact_a - a_grav
     diff_pot = exact_pot - pot
 
+    # Correct for different normalization of potential
+    print "Difference in normalization of potential:", np.mean(diff_pot),
+    print "std_dev=", np.std(diff_pot), "99-percentile:", np.percentile(diff_pot, 99)-np.median(diff_pot), "1-percentile:", np.median(diff_pot) - np.percentile(diff_pot, 1)
+
+    exact_pot -= np.mean(diff_pot)
+    diff_pot = exact_pot - pot
+
     norm_diff = np.sqrt(diff[:,0]**2 + diff[:,1]**2 + diff[:,2]**2)
 
     norm_error = norm_diff / exact_a_norm
-- 
GitLab