Skip to content

Commit 356b317

Browse files
author
Daniel Ruprecht
committed
some fixes in convergence plots
1 parent e37df72 commit 356b317

File tree

3 files changed

+36
-27
lines changed

3 files changed

+36
-27
lines changed

examples/acoustic_1d_imex/plotconvdata.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
if not line: break
1616
items = str.split(line, " ", 3)
1717
order = np.append(order, int(items[0]))
18-
nsteps = np.append(nsteps, int(items[1]))
18+
nsteps = np.append(nsteps, int(float(items[1])))
1919
error = np.append(error, float(items[2]))
2020

2121
assert np.size(order)==np.size(nsteps), 'Found different number of entries in order and nsteps'
@@ -49,13 +49,13 @@
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-5, 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-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)
5555
plt.gca().get_xaxis().get_major_formatter().labelOnlyBase = False
5656
plt.gca().get_xaxis().set_major_formatter(ScalarFormatter())
57-
plt.show()
58-
filename = 'sdc-fwsw-convergence.pdf'
57+
#plt.show()
58+
filename = 'convergence.pdf'
5959
fig.savefig(filename,bbox_inches='tight')
6060
call(["pdfcrop", filename, filename])
6161

examples/acoustic_1d_imex/runconvergence.py

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,56 +28,65 @@
2828

2929
sparams = {}
3030

31-
3231
# This comes as read-in for the problem class
3332
pparams = {}
34-
pparams['nvars'] = [(2,300)]
3533
pparams['cadv'] = 0.1
3634
pparams['cs'] = 1.00
3735
pparams['order_adv'] = 5
38-
pparams['waveno'] = 5
36+
pparams['waveno'] = 0
3937

4038
# Fill description dictionary for easy hierarchy creation
4139
description = {}
4240
description['problem_class'] = acoustic_1d_imex
4341
description['problem_params'] = pparams
4442
description['dtype_u'] = mesh
4543
description['dtype_f'] = rhs_imex_mesh
46-
description['collocation_class'] = collclass.CollGaussLegendre
44+
#description['collocation_class'] = collclass.CollGaussLobatto
45+
#description['collocation_class'] = collclass.CollGaussLegendre
46+
description['collocation_class'] = collclass.CollGaussRadau_Right
4747
description['sweeper_class'] = imex_1st_order
4848
description['do_coll_update'] = True
4949
description['level_params'] = lparams
5050
description['hook_class'] = plot_solution
5151

52-
Nsteps = [30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80]
52+
nsteps = np.zeros((3,7))
53+
nsteps[0,:] = [10, 15, 20, 25, 30, 35, 40]
54+
nsteps[1,:] = nsteps[0,:]
55+
nsteps[2,:] = nsteps[0,:]
5356

54-
for order in [2, 3, 4]:
57+
for order in [3, 4, 5]:
5558

56-
error = np.zeros(np.size(Nsteps))
59+
error = np.zeros(np.shape(nsteps)[1])
5760

5861
# setup parameters "in time"
5962
t0 = 0
6063
Tend = 1.0
6164

62-
if order==2:
65+
if order==3:
6366
file = open('conv-data.txt', 'w')
6467
else:
6568
file = open('conv-data.txt', 'a')
6669

67-
if order==2:
68-
description['num_nodes'] = 2
69-
elif order==3:
70+
if order==3:
7071
description['num_nodes'] = 3
7172
elif order==4:
7273
description['num_nodes'] = 3
73-
74+
elif order==5:
75+
description['num_nodes'] = 3
7476
sparams['maxiter'] = order
7577

76-
# quickly generate block of steps
77-
MS = mp.generate_steps(num_procs,sparams,description)
78-
for ii in range(0,np.size(Nsteps)):
78+
for ii in range(0,np.shape(nsteps)[1]):
7979

80-
dt = Tend/float(Nsteps[ii])
80+
ns = nsteps[order-3,ii]
81+
if ((order==3) or (order==4)):
82+
pparams['nvars'] = [(2,4*ns)]
83+
elif order==5:
84+
pparams['navrs'] = [(2,3*ns)]
85+
86+
# quickly generate block of steps
87+
MS = mp.generate_steps(num_procs,sparams,description)
88+
89+
dt = Tend/float(ns)
8190

8291
# get initial values on finest level
8392
P = MS[0].levels[0].prob
@@ -94,11 +103,11 @@
94103
uex = P.u_exact(Tend)
95104

96105
error[ii] = np.linalg.norm(uex.values-uend.values,np.inf)/np.linalg.norm(uex.values,np.inf)
97-
file.write(str(order)+" "+str(Nsteps[ii])+" "+str(error[ii])+"\n")
106+
file.write(str(order)+" "+str(ns)+" "+str(error[ii])+"\n")
98107

99108
file.close()
100109

101-
if np.size(Nsteps)==1:
110+
if np.shape(nsteps)[1]==1:
102111
fig = plt.figure(figsize=(8,8))
103112

104113
plt.plot(P.mesh, uex.values[0,:], '+', color='b', label='u (exact)')
@@ -110,5 +119,5 @@
110119
plt.ylim([-1.0, 1.0])
111120
plt.show()
112121
else:
113-
for ii in range(0,np.size(Nsteps)):
114-
print('error for nsteps= %s: %s' % (Nsteps[ii], error[ii]))
122+
for ii in range(0,np.shape(nsteps)[1]):
123+
print('error for nsteps= %s: %s' % (nsteps[order-3,ii], error[ii]))

examples/ruprecht_speck_2016.README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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:
4+
Figure 4: acoustic_1d_imex/runconvergence.py and then plotconvergence.py
55
Figure 5:
66
Figure 6: boussinesq_2d_imex/rungmrescounter.py and then plotgmrescounter.py for sparams['maxiter']=4 and dirk_order=4
77

0 commit comments

Comments
 (0)