Skip to content

Commit 18e25ab

Browse files
author
Daniel Ruprecht
committed
adjusted plot of multiscale example
1 parent c74d23b commit 18e25ab

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

examples/acoustic_1d_imex/runmultiscale.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
lparams['restol'] = 1E-10
3333

3434
sparams = {}
35-
sparams['maxiter'] = 2
35+
sparams['maxiter'] = 4
3636

3737
# setup parameters "in time"
3838
t0 = 0.0
@@ -59,7 +59,7 @@
5959
description['dtype_f'] = rhs_imex_mesh
6060
description['collocation_class'] = collclass.CollGaussLegendre
6161
# Number of nodes
62-
description['num_nodes'] = 2
62+
description['num_nodes'] = 3
6363
description['sweeper_class'] = imex_1st_order
6464
description['level_params'] = lparams
6565
description['hook_class'] = plot_solution
@@ -118,7 +118,7 @@
118118
unew_dirk, pnew_dirk = np.split(ynew_dirk, 2)
119119
unew_imex, pnew_imex = np.split(ynew_imex, 2)
120120

121-
rcParams['figure.figsize'] = 5, 2.5
121+
rcParams['figure.figsize'] = 2.5, 2.5
122122
fig = plt.figure()
123123

124124
sigma_0 = 0.1
@@ -131,9 +131,11 @@
131131
print ('Maximum pressure in RK-IMEX: %5.3e' % np.linalg.norm(pnew_imex, np.inf))
132132

133133
#plt.plot(P.mesh, pnew_tp, '-', color='c', label='Trapezoidal')
134-
plt.plot(P.mesh, pnew_imex, '-', color='c', label='IMEX('+str(rkimex.order)+')')
134+
if np.linalg.norm(pnew_imex, np.inf)<=2:
135+
plt.plot(P.mesh, pnew_imex, '-', color='c', label='IMEX('+str(rkimex.order)+')')
135136
plt.plot(P.mesh, uend.values[1,:], '--', color='b', label='SDC('+str(sparams['maxiter'])+')')
136-
plt.plot(P.mesh, pnew_bdf, '-', color='r', label='BDF-2')
137+
if dirk.order==2:
138+
plt.plot(P.mesh, pnew_bdf, '-', color='r', label='BDF-2')
137139
plt.plot(P.mesh, pnew_dirk, color='g', label='DIRK('+str(dirk.order)+')')
138140
#plt.plot(P.mesh, uex.values[1,:], '+', color='r', label='p (exact)')
139141
#plt.plot(P.mesh, uend.values[1,:], '-', color='b', linewidth=2.0, label='p (SDC)')
@@ -152,3 +154,18 @@
152154
plt.gcf().savefig(filename, bbox_inches='tight')
153155
call(["pdfcrop", filename, filename])
154156

157+
#plt.plot(P.mesh, uend.values[1,:], '-', color='b', linewidth=2.0, label='p (SDC)')
158+
159+
fig = plt.figure()
160+
p_slow = np.exp(-np.square( np.mod( P.mesh-pparams['cadv']*Tend, 1.0 ) -x_0 )/(sigma_0*sigma_0))
161+
plt.plot(P.mesh, uinit.values[1,:], '-', color='b')
162+
plt.xlabel('x', fontsize=fs, labelpad=0)
163+
plt.ylabel('Pressure', fontsize=fs, labelpad=0)
164+
fig.gca().set_xlim([0, 1.0])
165+
fig.gca().set_ylim([-0.5, 1.1])
166+
fig.gca().tick_params(axis='both', labelsize=fs)
167+
fig.gca().grid()
168+
#plt.show()
169+
filename = 'sdc-fwsw-multiscale-initial.pdf'
170+
plt.gcf().savefig(filename, bbox_inches='tight')
171+
call(["pdfcrop", filename, filename])

0 commit comments

Comments
 (0)