From 1c205702006d49b9d28a14df2e93b52220838700 Mon Sep 17 00:00:00 2001 From: Thibault Barnouin Date: Fri, 19 Nov 2021 16:28:41 +0100 Subject: [PATCH] display sma and ecc for 2 bodies --- lib/plots.py | 8 ++++---- main.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/plots.py b/lib/plots.py index ec924dc..62b8ee6 100755 --- a/lib/plots.py +++ b/lib/plots.py @@ -116,7 +116,7 @@ def display_parameters(E,L,sma,ecc,parameters,savename=""): ax1 = fig1.add_subplot(111) for i in range(len(E)): ax1.plot(np.arange(E[i].shape[0])*step[i]/yr, np.abs((E[i]-E[i][0])/E[i][0]), label="step of {0:.2e}yr".format(step[i]/yr)) - ax1.set(xlabel=r"$t [yr]$", ylabel=r"$\left|\frac{\delta E_m}{E_m(t=0)}\right|$", yscale='log') + 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) fig1.savefig("plots/{0:s}dEm.png".format(savename),bbox_inches="tight") @@ -127,16 +127,16 @@ def display_parameters(E,L,sma,ecc,parameters,savename=""): dL = ((L[i]-L[i][0])/L[i][0]) dL[np.isnan(dL)] = 0. ax2.plot(np.arange(L[i].shape[0])*step[i]/yr, np.abs(np.sum(dL,axis=1)), label="step of {0:.2e}yr".format(step[i]/yr)) - ax2.set(xlabel=r"$t [yr]$", ylabel=r"$\left|\frac{\delta \vec{L}}{\vec{L}(t=0)}\right|$",yscale='log') + 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) fig2.savefig("plots/{0:s}dL2.png".format(savename),bbox_inches="tight") fig3 = plt.figure(figsize=(15,7)) ax3 = fig3.add_subplot(111) - ax3.plot(np.arange(sma.shape[0])*step[i]/yr, sma, label="a (semi major axis)") + ax3.plot(np.arange(sma.shape[0])*step[i]/yr, sma/au, label="a (semi major axis)") ax3.plot(np.arange(ecc.shape[0])*step[i]/yr, ecc, label="e (eccentricity)") - ax3.set(xlabel=r"$t [yr]$", ylabel=r"$a [au] or e$") + ax3.set(xlabel=r"$t \, [yr]$", ylabel=r"$a \, [au] \, or \, e$") ax3.legend() fig3.suptitle("Semi major axis and eccentricity "+title2) fig3.savefig("plots/{0:s}a_e.png".format(savename),bbox_inches="tight") diff --git a/main.py b/main.py index b491699..548003f 100755 --- a/main.py +++ b/main.py @@ -27,8 +27,8 @@ def main(): v = np.array([v1, v2, v3]) #integration parameters - duration, step = 100*yr, np.array([1./(365.25*2.), 1./(365.25*2.), 1./365.25])*yr #integration time and step in years - + duration, step = 100*yr, np.array([1./(365.25*2.), 1./(365.25*1.), 5./(365.25*1.)])*yr #integration time and step in years + step = np.sort(step)[::-1] integrator = "leapfrog" n_bodies = 2 display = False @@ -52,7 +52,7 @@ def main(): parameters = [duration, step, dyn_syst, integrator] display_parameters(E, L, sma, ecc, parameters=parameters, savename=savename) - + print(sma/au) return 0 if __name__ == '__main__':