Skip to content

Commit 4e3d410

Browse files
author
Daniel Ruprecht
committed
script to generate residuals for different number of nodes and different values for c_s
1 parent d7c13eb commit 4e3d410

File tree

1 file changed

+54
-50
lines changed

1 file changed

+54
-50
lines changed

examples/acoustic_1d_imex/runitererror.py

Lines changed: 54 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from ProblemClass_conv import acoustic_1d_imex
77
from examples.acoustic_1d_imex.HookClass import plot_solution
88

9+
import pySDC.Stats as st
910
from pySDC.datatype_classes.mesh import mesh, rhs_imex_mesh
1011
from pySDC.sweeper_classes.imex_1st_order import imex_1st_order
1112
import pySDC.PFASST_stepwise as mp
@@ -28,58 +29,61 @@
2829

2930
sparams = {}
3031

31-
32-
# This comes as read-in for the problem class
33-
pparams = {}
34-
pparams['nvars'] = [(2,250)]
35-
pparams['cadv'] = 0.05
36-
pparams['cs'] = 5.0
37-
pparams['order_adv'] = 5
38-
pparams['waveno'] = 1
39-
40-
# This comes as read-in for the transfer operations
41-
tparams = {}
42-
tparams['finter'] = True
43-
44-
# Fill description dictionary for easy hierarchy creation
45-
description = {}
46-
description['problem_class'] = acoustic_1d_imex
47-
description['problem_params'] = pparams
48-
description['dtype_u'] = mesh
49-
description['dtype_f'] = rhs_imex_mesh
50-
description['collocation_class'] = collclass.CollGaussLobatto
51-
description['sweeper_class'] = imex_1st_order
52-
description['level_params'] = lparams
53-
description['hook_class'] = plot_solution
54-
#description['transfer_class'] = mesh_to_mesh_1d
55-
#description['transfer_params'] = tparams
56-
57-
for order in [3]:
58-
59-
# setup parameters "in time"
60-
t0 = 0
61-
Tend = 0.05
32+
cs_v = [0.5, 1.0, 1.5]
33+
sparams['maxiter'] = 25
34+
nodes_v = [2, 3]
35+
36+
residual = np.zeros((np.size(cs_v), np.size(nodes_v), sparams['maxiter']))
6237

63-
if order==2:
64-
description['num_nodes'] = 2
65-
elif order==3:
66-
description['num_nodes'] = 3
67-
elif order==4:
68-
description['num_nodes'] = 3
38+
for cs_ind in np.arange(np.size(cs_v)):
39+
40+
# This comes as read-in for the problem class
41+
pparams = {}
42+
pparams['nvars'] = [(2,250)]
43+
pparams['cadv'] = 0.05
44+
pparams['cs'] = cs_v[cs_ind]
45+
pparams['order_adv'] = 5
46+
pparams['waveno'] = 1
47+
48+
# This comes as read-in for the transfer operations
49+
tparams = {}
50+
tparams['finter'] = True
51+
52+
# Fill description dictionary for easy hierarchy creation
53+
description = {}
54+
description['problem_class'] = acoustic_1d_imex
55+
description['problem_params'] = pparams
56+
description['dtype_u'] = mesh
57+
description['dtype_f'] = rhs_imex_mesh
58+
description['collocation_class'] = collclass.CollGaussLobatto
59+
description['sweeper_class'] = imex_1st_order
60+
description['level_params'] = lparams
61+
description['hook_class'] = plot_solution
62+
#description['transfer_class'] = mesh_to_mesh_1d
63+
#description['transfer_params'] = tparams
64+
65+
for nodes_ind in np.arange(np.size(nodes_v)):
66+
# setup parameters "in time"
67+
t0 = 0
68+
Tend = 0.05
69+
description['num_nodes'] = nodes_v[nodes_ind]
70+
71+
# quickly generate block of steps
72+
MS = mp.generate_steps(num_procs,sparams,description)
73+
74+
dt = Tend
6975

70-
sparams['maxiter'] = 50
76+
# get initial values on finest level
77+
P = MS[0].levels[0].prob
78+
uinit = P.u_exact(t0)
7179

72-
# quickly generate block of steps
73-
MS = mp.generate_steps(num_procs,sparams,description)
74-
75-
dt = Tend
80+
# call main function to get things done...
81+
uend,stats = mp.run_pfasst(MS, u0=uinit, t0=t0, dt=dt, Tend=Tend)
82+
83+
for k,v in stats.items():
84+
iter = getattr(k,'iter')
85+
if iter is not -1:
86+
residual[cs_ind, nodes_ind, iter-1] = v
87+
# print residual
7688

77-
# get initial values on finest level
78-
P = MS[0].levels[0].prob
79-
uinit = P.u_exact(t0)
8089

81-
# call main function to get things done...
82-
uend,stats = mp.run_pfasst(MS, u0=uinit, t0=t0, dt=dt, Tend=Tend)
83-
84-
# compute exact solution and compare
85-
uex = P.u_exact(Tend)

0 commit comments

Comments
 (0)