1
0

debugg gif conversion, and add saved plots

This commit is contained in:
Thibault Barnouin
2021-10-30 17:03:38 +02:00
parent d538dfe7a4
commit 09fbdf0024
5 changed files with 8 additions and 4 deletions

View File

@@ -70,8 +70,10 @@ def frogleap(duration, step, dyn_syst, recover_param=False, display=False):
d.on_running(q_array[:,0]-q_cm[0], q_array[:,1]-q_cm[1], step=j, label="step {0:d}/{1:d}".format(j,N)) d.on_running(q_array[:,0]-q_cm[0], q_array[:,1]-q_cm[1], step=j, label="step {0:d}/{1:d}".format(j,N))
time.sleep(1e-4) time.sleep(1e-4)
if display: if display:
system("convert -delay 5 -loop 0 tmp/????.png tmp/temp.gif && rm tmp/?????.png") try:
system("convert tmp/temp.gif -fuzz 10% -layers Optimize dynsyst.gif && rm tmp/temp.gif") system("mkdir tmp")
system("convert -delay 5 -loop 0 tmp/?????.png tmp/temp.gif && rm tmp/?????.png")
system("convert tmp/temp.gif -fuzz 30% -layers Optimize plots/dynsyst.gif && rm tmp/temp.gif")
if recover_param: if recover_param:
return E, L return E, L

View File

@@ -21,21 +21,23 @@ def main():
v = np.array([v1, v2, v3]) v = np.array([v1, v2, v3])
bodylist = [] bodylist = []
for i in range(2): for i in range(2): # For a system of 2 objects
bodylist.append(Body(m[i], q[i], v[i])) bodylist.append(Body(m[i], q[i], v[i]))
dyn_syst = System(bodylist) dyn_syst = System(bodylist)
dyn_syst.COMShift() dyn_syst.COMShift()
duration, step = 100, 0.01 duration, step = 50, 0.01
E, L = frogleap(duration, step, dyn_syst, recover_param=True, display=True) E, L = frogleap(duration, step, dyn_syst, recover_param=True, display=True)
fig1 = plt.figure() fig1 = plt.figure()
ax1 = fig1.add_subplot(111) ax1 = fig1.add_subplot(111)
ax1.plot(np.arange(E.shape[0])/duration, E, label=r"$E_m$") ax1.plot(np.arange(E.shape[0])/duration, E, label=r"$E_m$")
ax1.legend() ax1.legend()
fig1.savefig("plots/Em.png",bbox_inches="tight")
fig2 = plt.figure() fig2 = plt.figure()
ax2 = fig2.add_subplot(111) ax2 = fig2.add_subplot(111)
ax2.plot(np.arange(L.shape[0])/duration, np.sum(L**2,axis=1), label=r"$L^2$") ax2.plot(np.arange(L.shape[0])/duration, np.sum(L**2,axis=1), label=r"$L^2$")
ax2.legend() ax2.legend()
fig2.savefig("plots/L2.png",bbox_inches="tight")
plt.show(block=True) plt.show(block=True)
return 0 return 0

BIN
plots/Em.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

BIN
plots/L2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
plots/dynsyst.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 KiB