|
12 | 12 |
|
13 | 13 | nvars = 512 |
14 | 14 | cs = 1.0 |
15 | | -cadv = 0.0 |
| 15 | +cadv = 0.05 |
16 | 16 | order = 4 |
17 | 17 |
|
18 | 18 | def u(x,t, multiscale): |
19 | | - u0 = np.exp(-np.square( np.mod( mesh- cs*t, 1.0 ) -x_0 )/(sigma_0*sigma_0)) + multiscale*np.exp(-np.square( np.mod( mesh -cs*t, 1.0 ) -x_1 )/(sigma_0*sigma_0))*np.cos(k*( np.mod( mesh-cs*t, 1.0 ))/sigma_0) |
| 19 | + u0 = np.exp(-np.square( np.mod( mesh - (cs+cadv)*t, 1.0 ) -x_0 )/(sigma_0*sigma_0)) + multiscale*np.exp(-np.square( np.mod( mesh -(cs+cadv)*t, 1.0 ) -x_1 )/(sigma_0*sigma_0))*np.cos(k*( np.mod( mesh - (cs+cadv)*t, 1.0 ))/sigma_0) |
20 | 20 | p0 = u0 |
21 | 21 | return u0, p0 |
22 | 22 |
|
@@ -67,28 +67,29 @@ def u(x,t, multiscale): |
67 | 67 | unew_bdf, pnew_bdf = np.split(ynew_bdf, 2) |
68 | 68 | uex, pex = u(mesh, float(i+1)*dt, 0.0) |
69 | 69 |
|
70 | | - fig.gca().clear() |
71 | | - #plt.plot(mesh, pnew_bdf, 'b', label='BDF-2') |
72 | | - plt.plot(mesh, pnew_tp, 'r', label='Trapezoidal') |
73 | | - plt.plot(mesh, pex, 'k', label='Slow Mode') |
74 | | - fig.gca().set_xlim([0, 1.0]) |
75 | | - fig.gca().set_ylim([-0.5, 1.1]) |
76 | | - fig.gca().legend(loc=3) |
77 | | - fig.gca().grid() |
78 | | - #plt.draw() |
79 | | - plt.pause(0.0001) |
| 70 | + if i==Nsteps-1: |
| 71 | + fig.gca().clear() |
| 72 | + plt.plot(mesh, pnew_bdf, 'b', label='BDF-2') |
| 73 | + plt.plot(mesh, pnew_tp, 'r', label='Trapezoidal') |
| 74 | + plt.plot(mesh, pex, 'k', label='Slow Mode') |
| 75 | + fig.gca().set_xlim([0, 1.0]) |
| 76 | + fig.gca().set_ylim([-0.5, 1.1]) |
| 77 | + fig.gca().legend(loc=3) |
| 78 | + fig.gca().grid() |
| 79 | + plt.draw() |
| 80 | + #plt.pause(0.0001) |
80 | 81 | #if i==0: |
81 | 82 | #plt.gcf().savefig('initial.pdf', bbox_inches='tight') |
82 | | - filename = 'images/standard'+"%03d" % i |
83 | | - plt.gcf().savefig(filename+'.png', bbox_inches='tight') |
84 | | - os.system('convert -quality 100 '+filename+'.png '+filename+'.jpeg') |
85 | | - os.system('rm '+filename+'.png') |
| 83 | + #filename = 'images/standard'+"%03d" % i |
| 84 | + #plt.gcf().savefig(filename+'.png', bbox_inches='tight') |
| 85 | + #os.system('convert -quality 100 '+filename+'.png '+filename+'.jpeg') |
| 86 | + #os.system('rm '+filename+'.png') |
86 | 87 |
|
87 | 88 | y0_ie = ynew_ie |
88 | 89 | y0_tp = ynew_tp |
89 | 90 | ym1_bdf = y0_bdf |
90 | 91 | y0_bdf = ynew_bdf |
91 | | -#plt.show() |
| 92 | +plt.show() |
92 | 93 | #lt.gcf().savefig('final.pdf', bbox_inches='tight') |
93 | | -os.system('ffmpeg -r 25 -i images/standard-%03d.jpeg -vcodec libx264 -crf 25 movie.avi') |
| 94 | +#os.system('ffmpeg -r 25 -i images/standard-%03d.jpeg -vcodec libx264 -crf 25 movie.avi') |
94 | 95 |
|
0 commit comments