Skip to content

Commit 008112d

Browse files
committed
Merge pull request #82 from danielru/add/dirk_order_five
add fifth order DIRK method to 1d acoustic IMEX and boussinesq example
2 parents 06cce94 + bcb25d6 commit 008112d

File tree

4 files changed

+57
-11
lines changed

4 files changed

+57
-11
lines changed

examples/acoustic_1d_imex/runmultiscale.py

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

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

3737
# setup parameters "in time"
3838
t0 = 0.0
3939
Tend = 3.0
40-
dt = Tend/float(154)
40+
nsteps = 154 # 154 is value in Vater et al.
41+
nsteps = 2*154
42+
dt = Tend/float(nsteps)
4143

4244
# This comes as read-in for the problem class
4345
pparams = {}
@@ -87,8 +89,8 @@
8789
y0_dirk = y0_tp.astype('complex')
8890
y0_imex = y0_tp.astype('complex')
8991

90-
# Perform 154 time steps with standard integrators
91-
for i in range(0,154):
92+
# Perform time steps with standard integrators
93+
for i in range(0,nsteps):
9294

9395
# trapezoidal rule step
9496
ynew_tp = trap.timestep(y0_tp, dt)

examples/acoustic_1d_imex/standard_integrators.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def __init__(self, M, order):
241241
self.M = M
242242
self.order = order
243243

244-
assert self.order in [2,22,3,4], 'Order must be 2,22,3,4'
244+
assert self.order in [2,22,3,4,5], 'Order must be 2,22,3,4'
245245

246246
if (self.order==2):
247247
self.nstages = 1
@@ -302,6 +302,27 @@ def __init__(self, M, order):
302302
self.b[0] = 1.0/(6.0*alpha*alpha)
303303
self.b[1] = 1.0 - 1.0/(3.0*alpha*alpha)
304304
self.b[2] = 1.0/(6.0*alpha*alpha)
305+
306+
if (self.order==5):
307+
# From A. H. Al-Rabeh, "OPTIMAL ORDER DIAGONALLY IMPLICIT RUNGE-KUTTA METHODS"
308+
self.nstages = 4
309+
self.A = np.zeros((4,4))
310+
self.A[1,0] = 0.1090390091
311+
self.A[1,1] = 0.1090390091
312+
self.A[2,0] = 0.0177359481
313+
self.A[2,1] = 0.4277445474
314+
self.A[2,2] = 0.1090390091
315+
self.A[3,0] = 0.1173343519
316+
self.A[3,1] = 0.2044057169
317+
self.A[3,2] = 0.4601819131
318+
self.A[3,3] = 0.1090390091
319+
320+
self.tau = np.zeros(4)
321+
self.b = np.zeros(4)
322+
self.b[0] = 0.0707307044
323+
self.b[1] = 0.3078968440
324+
self.b[2] = 0.3589454736
325+
self.b[3] = 0.2624269779
305326

306327
self.stages = np.zeros((self.nstages,self.Ndof), dtype='complex')
307328

examples/boussinesq_2d_imex/rungmrescounter.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@
4646

4747
# setup parameters "in time"
4848
t0 = 0
49-
Tend = 3000
50-
Nsteps = 500
49+
50+
Tend = 3000
51+
Nsteps = 100
52+
5153
dt = Tend/float(Nsteps)
5254

5355
# This comes as read-in for the problem class
@@ -63,7 +65,7 @@
6365
pparams['gmres_maxiter'] = [500]
6466
pparams['gmres_restart'] = [10]
6567
pparams['gmres_tol_limit'] = [1e-5]
66-
pparams['gmres_tol_factor'] = [0.1]
68+
pparams['gmres_tol_factor'] = [0.05]
6769

6870
# This comes as read-in for the transfer operations
6971
tparams = {}
@@ -99,6 +101,7 @@
99101
method_split = 'MIS4_4'
100102
# method_split = 'RK3'
101103
splitp = SplitExplicit(P, method_split, pparams)
104+
102105
u0 = uinit.values.flatten()
103106
usplit = np.copy(u0)
104107
# for i in range(0,Nsteps):
@@ -107,7 +110,7 @@
107110
usplit = splitp.timestep(usplit, dt/2)
108111
print(np.linalg.norm(usplit))
109112

110-
dirkp = dirk(P, np.min([4,dirk_order]))
113+
dirkp = dirk(P, dirk_order)
111114
udirk = np.copy(u0)
112115
print("Running DIRK ....")
113116
print(np.linalg.norm(udirk))

examples/boussinesq_2d_imex/standard_integrators.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,8 @@ def __init__(self, problem, order):
423423
self.logger = logging()
424424
self.problem = problem
425425

426-
assert self.order in [2,22,3,4], 'Order must be 2,22,3,4'
427-
426+
assert self.order in [2,22,3,4,5], 'Order must be 2,22,3,4'
427+
428428
if (self.order==2):
429429
self.nstages = 1
430430
self.A = np.zeros((1,1))
@@ -485,6 +485,26 @@ def __init__(self, problem, order):
485485
self.b[1] = 1.0 - 1.0/(3.0*alpha*alpha)
486486
self.b[2] = 1.0/(6.0*alpha*alpha)
487487

488+
if (self.order==5):
489+
# From A. H. Al-Rabeh, "OPTIMAL ORDER DIAGONALLY IMPLICIT RUNGE-KUTTA METHODS"
490+
self.nstages = 4
491+
self.A = np.zeros((4,4))
492+
self.A[1,0] = 0.1090390091
493+
self.A[1,1] = 0.1090390091
494+
self.A[2,0] = 0.0177359481
495+
self.A[2,1] = 0.4277445474
496+
self.A[2,2] = 0.1090390091
497+
self.A[3,0] = 0.1173343519
498+
self.A[3,1] = 0.2044057169
499+
self.A[3,2] = 0.4601819131
500+
self.A[3,3] = 0.1090390091
501+
self.tau = np.zeros(4)
502+
self.b = np.zeros(4)
503+
self.b[0] = 0.0707307044
504+
self.b[1] = 0.3078968440
505+
self.b[2] = 0.3589454736
506+
self.b[3] = 0.2624269779
507+
488508
self.stages = np.zeros((self.nstages,self.Ndof))
489509

490510
def timestep(self, u0, dt):

0 commit comments

Comments
 (0)