Coryab/implement rk4 #5
@ -7,11 +7,11 @@ def get_data(files):
|
|||||||
res = []
|
res = []
|
||||||
for file in files:
|
for file in files:
|
||||||
arr = [[], [], []]
|
arr = [[], [], []]
|
||||||
with open(file) as f:
|
with open(file, encoding="utf8") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
xi,yi,zi = map(lambda x: float(x), line.strip().split(","))
|
xi,yi,zi = map(float, line.strip().split(","))
|
||||||
arr[0].append(xi)
|
arr[0].append(xi)
|
||||||
arr[1].append(yi)
|
arr[1].append(yi)
|
||||||
arr[2].append(zi)
|
arr[2].append(zi)
|
||||||
@ -27,11 +27,12 @@ def update(num, lines, arr):
|
|||||||
|
|
||||||
|
|
||||||
def animate():
|
def animate():
|
||||||
|
plt.style.use("dark_background")
|
||||||
fig = plt.figure()
|
fig = plt.figure()
|
||||||
ax = fig.add_subplot(projection="3d")
|
ax = fig.add_subplot(projection="3d")
|
||||||
|
|
||||||
|
|
||||||
arr = get_data([f"output/p{i}.txt" for i in range(100)])
|
arr = get_data([f"output/p{i}_RK4.txt" for i in range(100)])
|
||||||
|
|
||||||
arr = arr[:,:,::10]
|
arr = arr[:,:,::10]
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ def animate():
|
|||||||
blit=False)
|
blit=False)
|
||||||
|
|
||||||
|
|
||||||
# ani.save("100_particles.gif", writer=animation.FFMpegFileWriter(fps=30))
|
ani.save("100_particles.gif", writer=animation.FFMpegFileWriter(fps=30))
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user