Skip to content

Commit 30878be

Browse files
author
Daniel Ruprecht
committed
paramter fixes for multiscale initial data in 1d acoustic
1 parent 0af9fbc commit 30878be

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

examples/acoustic_1d_imex/run_standard.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import numpy as np
22
import scipy.sparse as sp
33
import scipy.sparse.linalg as LA
4+
import os
45
from matplotlib import pyplot as plt
56
from buildWave1DMatrix import getWave1DMatrix, getWave1DAdvectionMatrix
67

78
sigma_0 = 0.1
89
k = 7.0*2*np.pi
910
x_0 = 0.75
1011
x_1 = 0.25
11-
multi_scale = 1.0
1212

1313
nvars = 512
1414
cs = 1.0
1515
cadv = 0.0
1616
order = 4
1717

18-
def u(x,t):
19-
u0 = np.exp(-np.square( np.mod( mesh- cs*t, 1.0 ) -x_0 )/(sigma_0*sigma_0)) + multi_scale*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)
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)
2020
p0 = u0
2121
return u0, p0
2222

@@ -38,7 +38,7 @@ def u(x,t):
3838
M_trap = Id - alpha*dt*(A+Dx)
3939
B_trap = Id + (1-alpha)*dt*(A+Dx)
4040

41-
u0, p0 = u(mesh, 0.0)
41+
u0, p0 = u(mesh, 0.0, 1.0)
4242
y0_ie = np.concatenate( (u0, p0) )
4343
y0_tp = y0_ie
4444

@@ -65,23 +65,30 @@ def u(x,t):
6565
unew_ie, pnew_ie = np.split(ynew_ie, 2)
6666
unew_tp, pnew_tp = np.split(ynew_tp, 2)
6767
unew_bdf, pnew_bdf = np.split(ynew_bdf, 2)
68-
uex, pex = u(mesh, float(i+1)*dt)
68+
uex, pex = u(mesh, float(i+1)*dt, 0.0)
6969

7070
fig.gca().clear()
7171
#plt.plot(mesh, pnew_bdf, 'b', label='BDF-2')
7272
plt.plot(mesh, pnew_tp, 'r', label='Trapezoidal')
73-
plt.plot(mesh, pex, 'k', label='Exact')
73+
plt.plot(mesh, pex, 'k', label='Slow Mode')
7474
fig.gca().set_xlim([0, 1.0])
7575
fig.gca().set_ylim([-0.5, 1.1])
7676
fig.gca().legend(loc=3)
7777
fig.gca().grid()
78-
plt.draw()
78+
#plt.draw()
7979
plt.pause(0.0001)
8080
#if i==0:
81-
# plt.gcf().savefig('initial.pdf', bbox_inches='tight')
81+
#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')
86+
8287
y0_ie = ynew_ie
8388
y0_tp = ynew_tp
8489
ym1_bdf = y0_bdf
8590
y0_bdf = ynew_bdf
8691
#plt.show()
87-
#plt.gcf().savefig('final.pdf', bbox_inches='tight')
92+
#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+

0 commit comments

Comments
 (0)