Skip to content

Commit bfc09a1

Browse files
author
Daniel Ruprecht
committed
added comments pointing out where to change quadrature node type; number of nodes and number of iterations
1 parent bb7e8be commit bfc09a1

File tree

8 files changed

+61
-19
lines changed

8 files changed

+61
-19
lines changed

examples/acoustic_1d_imex/plot_dispersion.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,22 @@ def findomega(stab_fh):
3939
# the following are not used in the computation
4040
pparams['lambda_s'] = np.array([0.0])
4141
pparams['lambda_f'] = np.array([0.0])
42+
4243
pparams['u0'] = 1.0
4344
swparams = {}
45+
46+
### SET TYPE OF QUADRATURE NODES ###
4447
#swparams['collocation_class'] = collclass.CollGaussLobatto
4548
#swparams['collocation_class'] = collclass.CollGaussLegendre
4649
swparams['collocation_class'] = collclass.CollGaussRadau_Right
50+
51+
### SET NUMBER OF NODES ###
4752
swparams['num_nodes'] = 3
53+
54+
### SET NUMBER OF ITERATIONS ###
4855
K = 5
56+
57+
### ORDER OF DIRK/IMEX IS EQUAL TO NUMBER OF ITERATIONS AND THUS ORDER OF SDC ###
4958
dirk_order = K
5059

5160
c_speed = 1.0

examples/acoustic_1d_imex/runconvergence.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@
4141
description['problem_params'] = pparams
4242
description['dtype_u'] = mesh
4343
description['dtype_f'] = rhs_imex_mesh
44+
45+
### SET TYPE OF QUADRATURE NODES ###
4446
#description['collocation_class'] = collclass.CollGaussLobatto
4547
#description['collocation_class'] = collclass.CollGaussLegendre
4648
description['collocation_class'] = collclass.CollGaussRadau_Right
49+
4750
description['sweeper_class'] = imex_1st_order
4851
description['do_coll_update'] = True
4952
description['level_params'] = lparams
@@ -67,6 +70,7 @@
6770
else:
6871
file = open('conv-data.txt', 'a')
6972

73+
### SET NUMBER OF NODES DEPENDING ON REQUESTED ORDER ###
7074
if order==3:
7175
description['num_nodes'] = 3
7276
elif order==4:

examples/acoustic_1d_imex/runitererror.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535

3636
cs_v = [0.5, 1.0, 1.5, 5.0]
3737
sparams['maxiter'] = 15
38+
39+
### SET NUMBER OF NODES ###
3840
nodes_v = [3]
3941

4042
residual = np.zeros((np.size(cs_v), np.size(nodes_v), sparams['maxiter']))
@@ -62,9 +64,12 @@
6264
description['problem_params'] = pparams
6365
description['dtype_u'] = mesh
6466
description['dtype_f'] = rhs_imex_mesh
67+
68+
### SELECT TYPE OF QUADRATURE NODES ###
6569
#description['collocation_class'] = collclass.CollGaussLobatto
6670
#description['collocation_class'] = collclass.CollGaussLegendre
6771
description['collocation_class'] = collclass.CollGaussRadau_Right
72+
6873
description['sweeper_class'] = imex_1st_order
6974
description['level_params'] = lparams
7075
description['hook_class'] = plot_solution

examples/acoustic_1d_imex/runmultiscale.py

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

3434
sparams = {}
35+
36+
### SET NUMBER OF ITERATIONS ###
3537
sparams['maxiter'] = 2
3638

3739
# setup parameters "in time"
3840
t0 = 0.0
3941
Tend = 3.0
4042
nsteps = 154 # 154 is value in Vater et al.
41-
#nsteps = 2*154
4243
dt = Tend/float(nsteps)
4344

4445
# This comes as read-in for the problem class
@@ -59,11 +60,15 @@
5960
description['problem_params'] = pparams
6061
description['dtype_u'] = mesh
6162
description['dtype_f'] = rhs_imex_mesh
63+
64+
### SET TYPE OF QUADRATURE NODES ###
6265
#description['collocation_class'] = collclass.CollGaussLobatto
6366
#description['collocation_class'] = collclass.CollGaussLegendre
6467
description['collocation_class'] = collclass.CollGaussRadau_Right
65-
# Number of nodes
68+
69+
### SET NUMBER OF NODES ###
6670
description['num_nodes'] = 2
71+
6772
description['sweeper_class'] = imex_1st_order
6873
description['level_params'] = lparams
6974
description['hook_class'] = plot_solution

examples/boussinesq_2d_imex/rungmrescounter.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,23 @@
3535
lparams['restol'] = 1E-15
3636

3737
swparams = {}
38+
39+
### SET TYPE OF QUADRATURE NODES ###
3840
#swparams['collocation_class'] = collclass.CollGaussLobatto
39-
#swparams['collocation_class'] = collclass.CollGaussLegendre
40-
swparams['collocation_class'] = collclass.CollGaussRadau_Right
41+
swparams['collocation_class'] = collclass.CollGaussLegendre
42+
#swparams['collocation_class'] = collclass.CollGaussRadau_Right
43+
44+
### SET NUMBER OF NODES ###
4145
swparams['num_nodes'] = 3
46+
4247
swparams['do_LU'] = False
4348

4449
sparams = {}
50+
51+
### SET NUMBER OF ITERATIONS ###
4552
sparams['maxiter'] = 4
4653

54+
### ORDER OF DIRK/IMEX EQUAL TO NUMBER OF SDC ITERATIONS AND THUS SDC ORDER ###
4755
dirk_order = sparams['maxiter']
4856

4957
# setup parameters "in time"

examples/fwsw/plot_stability.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,17 @@
2929
pparams['lambda_f'] = np.array([0.0])
3030
pparams['u0'] = 1.0
3131
swparams = {}
32+
### SET TYPE OF QUADRATURE NODES ###
3233
#swparams['collocation_class'] = collclass.CollGaussLobatto
33-
#swparams['collocation_class'] = collclass.CollGaussLegendre
34-
swparams['collocation_class'] = collclass.CollGaussRadau_Right
34+
swparams['collocation_class'] = collclass.CollGaussLegendre
35+
#swparams['collocation_class'] = collclass.CollGaussRadau_Right
36+
37+
### SET NUMBER OF QUADRATURE NODES ###
3538
swparams['num_nodes'] = 3
36-
K = 3
39+
40+
### SET NUMBER OF ITERATIONS - SET K=0 FOR COLLOCATION SOLUTION ###
41+
K = 4
42+
3743
do_coll_update = True
3844

3945
#
@@ -79,7 +85,7 @@
7985
fig = plt.figure()
8086
#pcol = plt.pcolor(lambda_s.imag, lambda_f.imag, np.absolute(stab), vmin=0.99, vmax=2.01)
8187
#pcol.set_edgecolor('face')
82-
levels = np.array([0.25, 0.5, 0.75, 0.9, 1.1])
88+
levels = np.array([0.25, 0.5, 0.75, 0.9, 1.01])
8389
# levels = np.array([1.0])
8490
CS1 = plt.contour(lambda_s.imag, lambda_f.imag, np.absolute(stab), levels, colors='k', linestyles='dashed')
8591
CS2 = plt.contour(lambda_s.imag, lambda_f.imag, np.absolute(stab), [1.0], colors='k')

examples/fwsw/plot_stablimits.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def get_stab_function(LHS, RHS, Kmax, lambd, do_coll_update):
2727
return stab_fh
2828

2929
if __name__ == "__main__":
30-
mvals = [2, 4]
31-
kvals = np.arange(1,15)
32-
lambdaratio = [2, 10, 50]
30+
mvals = [4]
31+
kvals = np.arange(2,9)
32+
lambdaratio = [1, 5, 50]
3333
stabval = np.zeros((np.size(mvals), np.size(lambdaratio), np.size(kvals)))
3434

3535
for i in range(0,np.size(mvals)):
@@ -49,7 +49,7 @@ def get_stab_function(LHS, RHS, Kmax, lambd, do_coll_update):
4949
step = stepclass.step(params={})
5050
L = lvl.level(problem_class=swfw_scalar, problem_params=pparams, dtype_u=mesh, dtype_f=rhs_imex_mesh, sweeper_class=imex, sweeper_params=swparams, level_params={}, hook_class=hookclass.hooks, id="stability")
5151
step.register_level(L)
52-
step.status.dt = 1.0
52+
step.status.dt = 1.0 # Needs to be 1.0, change dt through lambdas
5353
step.status.time = 0.0
5454
u0 = step.levels[0].prob.u_exact(step.status.time)
5555
step.init_step(u0)
@@ -62,7 +62,7 @@ def get_stab_function(LHS, RHS, Kmax, lambd, do_coll_update):
6262
Q = level.sweep.coll.Qmat[1:,1:]
6363

6464
for j in range(0,np.size(lambdaratio)):
65-
lambda_slow = 1j
65+
lambda_slow = 0.1*1j
6666
lambda_fast = lambdaratio[j]*lambda_slow
6767

6868
LHS = np.eye(nnodes) - step.status.dt*( lambda_fast*QI + lambda_slow*QE )
@@ -74,9 +74,13 @@ def get_stab_function(LHS, RHS, Kmax, lambd, do_coll_update):
7474
stabval[i,j,k] = np.absolute(stab_fh)
7575

7676
fig = plt.figure()
77-
plt.plot(kvals, stabval[0,0,:], '-', color='b')
78-
plt.plot(kvals, stabval[0,1,:], '-', color='r')
79-
plt.plot(kvals, stabval[0,2,:], '-', color='g')
77+
fs = 8
78+
plt.plot(kvals, stabval[0,0,:], 'o-', color='b', label=("Ratio: %3.0f" % lambdaratio[0]))
79+
plt.plot(kvals, stabval[0,1,:], 's-', color='r', label=("Ratio: %3.0f" % lambdaratio[1]))
80+
plt.plot(kvals, stabval[0,2,:], 'd-', color='g', label=("Ratio: %3.0f" % lambdaratio[2]))
81+
plt.plot(kvals, 1.0+0.0*kvals, '--', color='k')
82+
plt.legend(loc='lower right', fontsize=fs, prop={'size':fs})
83+
8084
#plt.plot(kvals, stabval[1,0,:], '-', color='r')
8185
#plt.plot(kvals, stabval[1,1,:], '--', color='r')
8286
#plt.plot(kvals, stabval[1,2,:], '-.', color='r')

examples/fwsw/plot_stifflimit_specrad.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
fs = 8
1818

1919
pparams = {}
20+
### SET VALUE FOR lambda_slow AND VALUES FOR lambda_fast ###
2021
pparams['lambda_s'] = np.array([1.0*1j], dtype='complex')
2122
pparams['lambda_f'] = np.array([50.0*1j, 100.0*1j], dtype='complex')
2223
pparams['u0'] = 1.0
2324
swparams = {}
24-
#
25-
#
26-
#
25+
26+
27+
### SET TYPE OF QUADRATURE NODES ###
2728
#swparams['collocation_class'] = collclass.CollGaussLobatto
2829
#swparams['collocation_class'] = collclass.CollGaussLegendre
2930
swparams['collocation_class'] = collclass.CollGaussRadau_Right

0 commit comments

Comments
 (0)