switch back to unit time in seconds, prepare for parallel computing
This commit is contained in:
@@ -58,9 +58,9 @@ def leapfrog(dyn_syst, bin_syst, duration, dt, recover_param=False, display=Fals
|
||||
if display and j % 10 == 0:
|
||||
# display progression
|
||||
if len(dyn_syst.bodylist) == 1:
|
||||
d.on_running(dyn_syst, step=j, label="{0:.2f} years".format(j*dt))
|
||||
d.on_running(dyn_syst, step=j, label="{0:.2f} years".format(j*dt/yr))
|
||||
else:
|
||||
d.on_running(dyn_syst, step=j, label="{0:.2f} years".format(j*dt))
|
||||
d.on_running(dyn_syst, step=j, label="{0:.2f} years".format(j*dt/yr))
|
||||
if display:
|
||||
d.close()
|
||||
if not savename is None:
|
||||
|
||||
11
lib/plots.py
11
lib/plots.py
@@ -110,12 +110,12 @@ def display_parameters(E,L,sma,ecc,parameters,savename=""):
|
||||
bodies = ""
|
||||
for body in dyn_syst.bodylist:
|
||||
bodies += str(body)+" ; "
|
||||
title1, title2 = "Relative difference of the {0:s} ","for a system composed of {0:s}\n integrated with {1:s} for a duration of {2:.2f} years ".format(bodies, integrator, duration)
|
||||
title1, title2 = "Relative difference of the {0:s} ","for a system composed of {0:s}\n integrated with {1:s} for a duration of {2:.2f} years ".format(bodies, integrator, duration/yr)
|
||||
|
||||
fig1 = plt.figure(figsize=(15,7))
|
||||
ax1 = fig1.add_subplot(111)
|
||||
for i in range(len(E)):
|
||||
ax1.plot(np.arange(E[i].shape[0]-1)*step[i], np.abs((E[i][1:]-E[i][0])/E[i][0]), label="step of {0:.2e}yr".format(step[i]))
|
||||
ax1.plot(np.arange(E[i].shape[0]-1)*step[i]/yr, np.abs((E[i][1:]-E[i][0])/E[i][0]), label="step of {0:.2e}s".format(step[i]))
|
||||
ax1.set(xlabel=r"$t \, [yr]$", ylabel=r"$\left|\frac{\delta E_m}{E_m(t=0)}\right|$", yscale='log')
|
||||
ax1.legend()
|
||||
fig1.suptitle(title1.format("mechanical energy")+title2)
|
||||
@@ -126,7 +126,7 @@ def display_parameters(E,L,sma,ecc,parameters,savename=""):
|
||||
for i in range(len(L)):
|
||||
dL = ((L[i]-L[i][0])/L[i][0])
|
||||
dL[np.isnan(dL)] = 0.
|
||||
ax2.plot(np.arange(L[i].shape[0]-1)*step[i], np.abs(np.sum(dL[1:],axis=1)), label="step of {0:.2e}yr".format(step[i]))
|
||||
ax2.plot(np.arange(L[i].shape[0]-1)*step[i]/yr, np.abs(np.sum(dL[1:],axis=1)), label="step of {0:.2e}s".format(step[i]))
|
||||
ax2.set(xlabel=r"$t \, [yr]$", ylabel=r"$\left|\frac{\delta \vec{L}}{\vec{L}(t=0)}\right|$",yscale='log')
|
||||
ax2.legend()
|
||||
fig2.suptitle(title1.format("kinetic moment")+title2)
|
||||
@@ -134,8 +134,9 @@ def display_parameters(E,L,sma,ecc,parameters,savename=""):
|
||||
|
||||
fig3 = plt.figure(figsize=(15,7))
|
||||
ax3 = fig3.add_subplot(111)
|
||||
ax3.plot(np.arange(sma.shape[0])*step[i], sma, label="a (semi major axis)")
|
||||
ax3.plot(np.arange(ecc.shape[0])*step[i], ecc, label="e (eccentricity)")
|
||||
for i in range(len(L)):
|
||||
ax3.plot(np.arange(sma[i].shape[0])*step[i]/yr, sma[i], label="a (step of {0:.2e}s)".format(step[i]))
|
||||
ax3.plot(np.arange(ecc[i].shape[0])*step[i]/yr, ecc[i], label="e (step of {0:.2e}s)".format(step[i]))
|
||||
ax3.set(xlabel=r"$t \, [yr]$", ylabel=r"$a \, [au] \, or \, e$")
|
||||
ax3.legend()
|
||||
fig3.suptitle("Semi major axis and eccentricity "+title2)
|
||||
|
||||
@@ -8,4 +8,4 @@ globals()['G'] = 6.67e-11 #Gravitational constant in SI units
|
||||
globals()['Ms'] = 2e30 #Solar mass in kg
|
||||
globals()['au'] = 1.5e11 #Astronomical unit in m
|
||||
globals()['yr'] = 3.15576e7 #year in seconds
|
||||
globals()['Ga'] = G*Ms*yr**2/au**3 #Gravitational constant dimensionless
|
||||
globals()['Ga'] = G*Ms/au**3 #Gravitational constant dimensionless
|
||||
Reference in New Issue
Block a user