aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRahiel Kasim <rahielkasim@gmail.com>2016-02-21 21:57:40 +0100
committerRahiel Kasim <rahielkasim@gmail.com>2016-02-21 21:57:40 +0100
commitca517c670e3b606366b265173e34a1efeaa9cede (patch)
treedc0bcddcc72ca948a53d2b2dd9b88ad8e7e754b0
parenta01512804dbf6f7f0bc7f8f8372b51eab87f2ed1 (diff)
plot efficiency data
-rw-r--r--Run/plots.py71
-rwxr-xr-xRun/run_energy_drift2
2 files changed, 71 insertions, 2 deletions
diff --git a/Run/plots.py b/Run/plots.py
index de86e6a..2d135b2 100644
--- a/Run/plots.py
+++ b/Run/plots.py
@@ -1,3 +1,7 @@
+#!/usr/bin/env python
+from __future__ import division
+from io import StringIO
+
import numpy as np
import matplotlib.pyplot as plt
@@ -9,6 +13,71 @@ def plot_verlet_times():
plt.title("Verlet list radius vs. total CPU time")
plt.xlabel(r"Verlet Radius ($\sigma$)")
plt.ylabel("CPU time (s)")
- plt.plot(rv, real + sys)
+ plt.plot(rv, user + sys)
plt.grid()
plt.savefig("verlet_times", dpi=600)
+
+
+def plot_efficiency_multi():
+ """Plot efficiency data generated by run_deltat_efficiency like the right
+ plot in figure 15.3, page 429 of the book.
+ """
+ tmax = 5
+ with open("n_efficiency.txt") as f:
+ data = f.read()
+ timesteps = data.strip().split("\n\n")
+ fig = plt.figure(figsize=(8, 8))
+ for delt_data in timesteps:
+ delt, d = delt_data.split('\n', 1)
+ delt = float(delt.split()[-1])
+ n, real, user, sys = np.genfromtxt(StringIO(unicode(d))).T
+ simulation_time = np.array([tmax] * len(user))
+ cpu_time = user + sys
+ efficiency = simulation_time / cpu_time
+ plt.semilogy(n, efficiency, label="%.1e" % delt)
+ plt.title("MTS efficiency vs number of small steps")
+ plt.xlabel("n")
+ plt.ylabel(r"Efficiency ($\eta$)")
+ plt.legend(ncol=3)
+ plt.grid()
+ plt.savefig("efficiency_multi", dpi=600)
+
+
+def plot_efficiency():
+ """Plot efficiency data for leapfrog and MTS (like figure 15.3 left)."""
+ tmax = 5
+ fig = plt.figure(figsize=(10, 8))
+
+ # Leapfrog
+ delt, real, user, sys = np.genfromtxt("deltat_efficiency_leapfrog.txt").T
+ cpu_time = user + sys
+ simulation_time = np.array([tmax] * len(user))
+ efficiency = simulation_time / cpu_time
+ plt.loglog(delt, efficiency, label="Leapfrog")
+
+ # Multiple Time Step
+ with open("n_efficiency.txt") as f:
+ data = f.read()
+ timesteps = data.strip().split("\n\n")
+ dt = []
+ mts = np.zeros([10, len(timesteps)])
+ for (i, delt_data) in enumerate(timesteps):
+ delt, d = delt_data.split('\n', 1)
+ delt = float(delt.split()[-1])
+ dt.append(delt)
+ n, real, user, sys = np.genfromtxt(StringIO(unicode(d))).T
+ simulation_time = np.array([tmax] * len(user))
+ cpu_time = user + sys
+ efficiency = simulation_time / cpu_time
+ for (n, e) in enumerate(efficiency):
+ mts[n, i] = e
+
+ for (n, s) in enumerate(mts):
+ plt.loglog(dt, s, label="MTS n = %d" % (n + 1))
+ plt.title("Efficiency vs Time Step")
+ plt.xlabel(r"$\Delta t$")
+ plt.ylabel(r"$\eta$")
+ plt.legend(ncol=3, loc="upper left")
+ plt.grid()
+ # plt.show()
+ plt.savefig("efficiency", dpi=600)
diff --git a/Run/run_energy_drift b/Run/run_energy_drift
index 6fd6deb..3f29028 100755
--- a/Run/run_energy_drift
+++ b/Run/run_energy_drift
@@ -25,7 +25,7 @@ samp1 samp2 tdifmax
rcp rv rc2 rv2
2.5 2.625 ${rmin} ${rv2}
multi n drift
-.false. 3 .true.
+.true. 3 .true.
endofdata
cp lj.res fort.11