1
0

Update display to 3D plots

This commit is contained in:
Thibault Barnouin
2021-11-05 10:57:32 +01:00
parent 925e5215be
commit 0d4cb52421
6 changed files with 10 additions and 7 deletions

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"git.ignoreLimitWarning": true
}

View File

@@ -39,7 +39,7 @@ class DynamicUpdate():
#We need to draw *and* flush #We need to draw *and* flush
self.fig.canvas.draw() self.fig.canvas.draw()
self.fig.canvas.flush_events() self.fig.canvas.flush_events()
if not step is None and step%50==0: if not step is None and step%10==0:
self.fig.savefig("tmp/{0:05d}.png".format(step),bbox_inches="tight") self.fig.savefig("tmp/{0:05d}.png".format(step),bbox_inches="tight")
#Example #Example

12
main.py
View File

@@ -12,12 +12,12 @@ def main():
x1 = np.array([-1, 0, 0]) x1 = np.array([-1, 0, 0])
x2 = np.array([1, 0, 0]) x2 = np.array([1, 0, 0])
x3 = np.array([100, 0, 0]) x3 = np.array([100, 0, 20])
q = np.array([x1, x2, x3]) q = np.array([x1, x2, x3])
v1 = np.array([0, -0.35, 0]) v1 = np.array([0, -0.35, 0])
v2 = np.array([0, 0.35, 0]) v2 = np.array([0, 0.35, 0])
v3 = np.array([0, 0, 0]) v3 = np.array([0, 20., 0])
v = np.array([v1, v2, v3]) v = np.array([v1, v2, v3])
bodylist = [] bodylist = []
@@ -26,14 +26,14 @@ def main():
dyn_syst = System(bodylist) dyn_syst = System(bodylist)
dyn_syst.COMShift() dyn_syst.COMShift()
duration, step = 50, 0.01 duration, step = 100, 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(figsize=(30,15))
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") fig1.savefig("plots/Em.png",bbox_inches="tight")
fig2 = plt.figure() fig2 = plt.figure(figsize=(30,15))
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()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 456 KiB

After

Width:  |  Height:  |  Size: 1.1 MiB