Commit c4444803 authored by Olaf's avatar Olaf

make energy plots

parent c0de2e20
......@@ -96,8 +96,9 @@ def trajectory(bodies, settings, inds='all'):
pass
pass
def plot_eccentricity(semi_major_axis,e):
def plot_eccentricity(semi_major_axis, e, settings):
# plot eccentricty to semi_major_axis
plt.figure()
plt.plot(semi_major_axis,e,'b.')
plt.title('Astroid distribution', fontsize = settings.plot.fontsize_title)
plt.xlabel('Semi-major Axis [AU]', fontsize = settings.plot.fontsize_axislabel)
......@@ -105,5 +106,44 @@ def plot_eccentricity(semi_major_axis,e):
plt.tick_params(labelsize = settings.plot.fontsize_axisticks)
plt.show()
def plot_energy(bodies, settings):
"""
Plot energy of the bodies.
Parameters
----------
bodies: list of objects.Body class objects
Contains objects.Body class objects with initialization parameters
settings: objects.Settings class object
Settings for the interacting system
"""
t = bodies[0].times
E_kin = np.zeros((len(t)))
E_pot = np.zeros((len(t)))
for i in range(len(bodies)):
if isinstance(bodies[i], Asteroids):
if bodies[i].N >1:
E_kin += np.sum(np.asarray(bodies[i].E_kin), axis = 0)
E_pot += np.sum(np.asarray(bodies[i].E_pot), axis = 0)
elif bodies[i].N == 1:
E_kin += np.asarray(bodies[i].E_kin)
E_pot += np.asarray(bodies[i].E_pot)
else:
E_kin += np.asarray(bodies[i].E_kin)
E_pot += np.asarray(bodies[i].E_pot)
fig = plt.figure()
plt.plot(t, E_kin, color = 'yellow', label = 'Kinetic energy')
plt.plot(t, E_pot, color = 'blue', label = 'Potential energy')
plt.plot(t, E_kin + E_pot, color = 'green', label = 'Total energy')
plt.xlabel('time $[y_J]$', fontsize = settings.plot.fontsize_title)
plt.ylabel('Energy', fontsize = settings.plot.fontsize_title)
plt.title('Energy')
plt.show()
def save_figure(figure, name):
pass
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment