Skip to content
Snippets Groups Projects
Commit fef5fa6d authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

add another centered difference approximation

parent c2aa27b0
No related branches found
No related tags found
No related merge requests found
......@@ -137,19 +137,21 @@ def acceleration_test(c):
acc = d['particles/tracers4/acceleration'].value
num_acc1 = (- vel[ :-2] + vel[2:])/(2*d['parameters/dt'].value*d['parameters/niter_part'].value)
num_vel = (- pos[ :-2] + pos[2:])/(2*d['parameters/dt'].value*d['parameters/niter_part'].value)
num_acc2 = (pos[ :-2] - 2*pos[1:-1] + pos[2:])/((d['parameters/dt'].value*d['parameters/niter_part'].value)**2)
num_acc3 = (-vel[4:] + 8*vel[3:-1] - 8*vel[1:-3] + vel[:-4])/(12*d['parameters/dt'].value*d['parameters/niter_part'].value)
num_acc4 = (-pos[4:] + 16*pos[3:-1] - 30*pos[2:-2] + 16*pos[1:-3] - pos[:-4])/(12*(d['parameters/dt'].value*d['parameters/niter_part'].value)**2)
num_vel = (- pos[ :-2] + pos[2:])/(2*d['parameters/dt'].value*d['parameters/niter_part'].value)
pid = np.unravel_index(np.argmax(np.abs(num_acc3 - acc[2:-2])), dims = num_acc3.shape)[1]
fig = plt.figure()
a = fig.add_subplot(111)
col = ['red', 'green', 'blue']
for cc in range(3):
a.plot(num_acc1[1:, pid, cc], color = col[cc])
a.plot(num_acc2[1:, pid, cc], color = col[cc], dashes = (2, 2))
a.plot(num_acc3[1:, pid, cc], color = col[cc], dashes = (3, 4))
a.plot(acc[2:, pid, cc], color = col[cc], dashes = (1, 1))
a.plot(num_acc1[2:, pid, cc], color = col[cc], dashes = (3, 4))
a.plot(num_acc2[2:, pid, cc], color = col[cc], dashes = (2, 2))
a.plot(num_acc3[1:, pid, cc], color = col[cc])
a.plot(num_acc4[1:, pid, cc], color = col[cc], dashes = (3, 5))
a.plot(acc[3:, pid, cc], color = col[cc], dashes = (1, 1))
fig.savefig(os.path.join(c.work_dir, 'acc_test_{0}.pdf'.format(c.simname)))
return None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment