In [1]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc
rc('text', usetex=True)
plt.rc('font', family='serif')
from __future__ import print_function
from IPython.html.widgets import interact
In [2]:
%%bash
make
./pythagorean_3body
In [3]:
body_1_filename = 'body_001.dat'
body_2_filename = 'body_002.dat'
body_3_filename = 'body_003.dat'
t_1, x_1, y_1, z_1 = np.loadtxt(body_1_filename, unpack=True, skiprows=1)
t_2, x_2, y_2, z_2 = np.loadtxt(body_2_filename, unpack=True, skiprows=1)
t_3, x_3, y_3, z_3 = np.loadtxt(body_3_filename, unpack=True, skiprows=1)
plot_step_size = 10
def plot_solution(plot_start=40):
print("plot range: t= ",plot_start, " - ", plot_start + plot_step_size)
indices = np.where( ((t_1 > plot_start) & (t_1 < plot_start + plot_step_size)))
plt.plot(x_1[indices], y_1[indices], linestyle='-')
plt.plot(x_2[indices], y_2[indices], linestyle='dotted')
plt.plot(x_3[indices], y_3[indices], linestyle='--')
plt.xlabel(r"x")
plt.ylabel(r"y")
plt.legend((r"Body 1", r"Body 2", r"Body 3"))
return
interact(plot_solution, plot_start=(0,60,plot_step_size));