Skip to content

Commit 22b4a4a

Browse files
author
Daniel Ruprecht
committed
fixed parameter for convergence plot
1 parent 356b317 commit 22b4a4a

File tree

7 files changed

+38
-15
lines changed

7 files changed

+38
-15
lines changed

examples/acoustic_1d_imex/buildFDMatrix.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ def getMatrix(N, dx, bc_left, bc_right, order):
5454
stencil = [1.0, -8.0, 0.0, 8.0, -1.0]
5555
range = [ -2, -1, 0, 1, 2]
5656
coeff = 1.0/12.0
57+
elif order==6:
58+
stencil = [-1.0, 9.0, -45.0, 0.0, 45.0, -9.0, 1.0]
59+
range =[ -3, -2, -1, 0, 1, 2, 3]
60+
coeff = 1.0/60.0
5761

5862
A = sp.diags(stencil, range, shape=(N,N))
5963
A = sp.lil_matrix(A)
@@ -73,13 +77,28 @@ def getMatrix(N, dx, bc_left, bc_right, order):
7377
A[0,N-1] = stencil[1]
7478
A[1,N-1] = stencil[0]
7579

80+
elif order==6:
81+
A[0,N-3] = stencil[0]
82+
A[0,N-2] = stencil[1]
83+
A[0,N-1] = stencil[2]
84+
A[1,N-2] = stencil[0]
85+
A[1,N-1] = stencil[1]
86+
A[2,N-1] = stencil[0]
87+
7688
if bc_right in ['periodic']:
7789
if order==2:
7890
A[N-1,0] = stencil[2]
7991
elif order==4:
8092
A[N-2,0] = stencil[4]
8193
A[N-1,0] = stencil[3]
8294
A[N-1,1] = stencil[4]
95+
elif order==6:
96+
A[N-3,0] = stencil[6]
97+
A[N-2,0] = stencil[5]
98+
A[N-2,1] = stencil[6]
99+
A[N-1,0] = stencil[4]
100+
A[N-1,1] = stencil[5]
101+
A[N-1,2] = stencil[6]
83102

84103
#
85104
# Neumann boundary conditions

examples/acoustic_1d_imex/buildWave1DMatrix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import scipy.sparse as sp
55
from buildFDMatrix import getMatrix, getHorizontalDx, getBCLeft, getBCRight
66

7-
wave_order = 4
7+
wave_order = 6
88

99
def getWave1DMatrix(N, dx, bc_left, bc_right):
1010

examples/acoustic_1d_imex/plotconvdata.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@
4949
plt.xlabel('Number of time steps', fontsize=fs)
5050
plt.ylabel('Relative error', fontsize=fs, labelpad=2)
5151
plt.xlim([0.9*np.min(nsteps_plot), 1.1*np.max(nsteps_plot)])
52-
plt.ylim([1e-7, 1e0])
53-
#plt.yticks([1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 1e0],fontsize=fs)
54-
#plt.xticks([30, 40, 60, 80], fontsize=fs)
52+
plt.ylim([1e-5, 1e0])
53+
plt.yticks([1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 1e0],fontsize=fs)
54+
plt.xticks([20, 30, 40, 60, 80, 100], fontsize=fs)
5555
plt.gca().get_xaxis().get_major_formatter().labelOnlyBase = False
5656
plt.gca().get_xaxis().set_major_formatter(ScalarFormatter())
5757
#plt.show()

examples/acoustic_1d_imex/runconvergence.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
pparams['cadv'] = 0.1
3434
pparams['cs'] = 1.00
3535
pparams['order_adv'] = 5
36-
pparams['waveno'] = 0
36+
pparams['waveno'] = 5
3737

3838
# Fill description dictionary for easy hierarchy creation
3939
description = {}
@@ -49,8 +49,8 @@
4949
description['level_params'] = lparams
5050
description['hook_class'] = plot_solution
5151

52-
nsteps = np.zeros((3,7))
53-
nsteps[0,:] = [10, 15, 20, 25, 30, 35, 40]
52+
nsteps = np.zeros((3,9))
53+
nsteps[0,:] = [20, 30, 40, 50, 60, 70, 80, 90, 100]
5454
nsteps[1,:] = nsteps[0,:]
5555
nsteps[2,:] = nsteps[0,:]
5656

@@ -73,15 +73,16 @@
7373
description['num_nodes'] = 3
7474
elif order==5:
7575
description['num_nodes'] = 3
76+
7677
sparams['maxiter'] = order
7778

7879
for ii in range(0,np.shape(nsteps)[1]):
7980

8081
ns = nsteps[order-3,ii]
8182
if ((order==3) or (order==4)):
82-
pparams['nvars'] = [(2,4*ns)]
83+
pparams['nvars'] = [(2,5*ns)]
8384
elif order==5:
84-
pparams['navrs'] = [(2,3*ns)]
85+
pparams['nvars'] = [(2,5*ns)]
8586

8687
# quickly generate block of steps
8788
MS = mp.generate_steps(num_procs,sparams,description)

examples/acoustic_1d_imex/runitererror.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
# This comes as read-in for the level class
3131
lparams = {}
32-
lparams['restol'] = 1E-14
32+
lparams['restol'] = 1E-10
3333

3434
sparams = {}
3535

@@ -62,7 +62,9 @@
6262
description['problem_params'] = pparams
6363
description['dtype_u'] = mesh
6464
description['dtype_f'] = rhs_imex_mesh
65-
description['collocation_class'] = collclass.CollGaussLegendre
65+
#description['collocation_class'] = collclass.CollGaussLobatto
66+
#description['collocation_class'] = collclass.CollGaussLegendre
67+
description['collocation_class'] = collclass.CollGaussRadau_Right
6668
description['sweeper_class'] = imex_1st_order
6769
description['level_params'] = lparams
6870
description['hook_class'] = plot_solution
@@ -97,7 +99,7 @@
9799

98100
# Compute convergence rates
99101
for iter in range(0,sparams['maxiter']-1):
100-
if residual[cs_ind, nodes_ind, iter]<lparams['restol']:
102+
if residual[cs_ind, nodes_ind, iter]< lparams['restol']:
101103
lastiter[cs_ind,nodes_ind] = iter
102104
else:
103105
convrate[cs_ind, nodes_ind, iter] = residual[cs_ind, nodes_ind, iter+1]/residual[cs_ind, nodes_ind, iter]
@@ -127,7 +129,7 @@
127129
plt.yticks(fontsize=fs)
128130
plt.xticks(fontsize=fs)
129131
plt.show()
130-
filename = 'sdc-fwsw-iteration.pdf'
132+
filename = 'iteration.pdf'
131133
fig.savefig(filename,bbox_inches='tight')
132134
call(["pdfcrop", filename, filename])
133135

examples/acoustic_1d_imex/runmultiscale.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
t0 = 0.0
3939
Tend = 3.0
4040
nsteps = 154 # 154 is value in Vater et al.
41-
nsteps = 2*154
41+
#nsteps = 2*154
4242
dt = Tend/float(nsteps)
4343

4444
# This comes as read-in for the problem class

examples/ruprecht_speck_2016.README

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
Figure 1: fwsw/plot_stifflimit_specrad.py
22
Figure 2: fwsw/plot_stability.py
33
Figure 3: acoustic_1d_imex/plot_dispersion.py
4-
Figure 4: acoustic_1d_imex/runconvergence.py and then plotconvergence.py
4+
Figure 4 (left): acoustic_1d_imex/runconvergence.py and then plotconvergence.py
5+
Figure 4 (right): acoustic_1d_imex/runitererror.py
56
Figure 5:
67
Figure 6: boussinesq_2d_imex/rungmrescounter.py and then plotgmrescounter.py for sparams['maxiter']=4 and dirk_order=4
78

0 commit comments

Comments
 (0)