Skip to content

Commit 4a259f3

Browse files
Merge pull request #3 from ranocha/pull-request/8fc9926f
added tableaus for SSPRK methods
2 parents 4fb36eb + 8fc9926 commit 4a259f3

File tree

3 files changed

+85
-1
lines changed

3 files changed

+85
-1
lines changed

src/DiffEqDevTools.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export constructEuler, constructKutta3, constructRK4, constructRK438Rule,
5959
constructTanakaKasugaYamashitaYazaki6B, constructTanakaKasugaYamashitaYazaki6A,
6060
constructMikkawyEisa, constructChummund6, constructChummund62,
6161
constructHuta62, constructHuta6, constructRKF4, constructVerner7, constructVerner8,
62-
constructVerner9, constructVerner6
62+
constructVerner9, constructVerner6, constructSSPRK22, constructSSPRK33,
63+
constructSSPRK43, constructSSPRK104
6364

6465
end # module

src/ode_tableaus.jl

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,73 @@ function constructRK438Rule(T::Type = Float64)
138138
return(ExplicitRKTableau(A,c,α,4))
139139
end
140140

141+
"""
142+
Explicit SSP method of order 2 using 2 stages.
143+
"""
144+
function constructSSPRK22(T::Type = Float64)
145+
A = [0 0
146+
1 0]
147+
c = [0; 1]
148+
α = [1//2; 1//2]
149+
A = map(T,A)
150+
α = map(T,α)
151+
c = map(T,c)
152+
return(ExplicitRKTableau(A,c,α,2))
153+
end
154+
155+
"""
156+
Explicit SSP method of order 3 using 3 stages.
157+
"""
158+
function constructSSPRK33(T::Type = Float64)
159+
A = [0 0 0
160+
1 0 0
161+
1//4 1//4 0]
162+
c = [0; 1; 1//2]
163+
α = [1//6; 1//6; 2//3]
164+
A = map(T,A)
165+
α = map(T,α)
166+
c = map(T,c)
167+
return(ExplicitRKTableau(A,c,α,3))
168+
end
169+
170+
"""
171+
Explicit SSP method of order 3 using 4 stages.
172+
"""
173+
function constructSSPRK43(T::Type = Float64)
174+
A = [0 0 0 0
175+
1//2 0 0 0
176+
1//2 1//2 0 0
177+
1//6 1//6 1//6 0]
178+
c = [0; 1//2; 1; 1//2]
179+
α = [1//6; 1//6; 1//6; 1//2]
180+
A = map(T,A)
181+
α = map(T,α)
182+
c = map(T,c)
183+
return(ExplicitRKTableau(A,c,α,3))
184+
end
185+
186+
"""
187+
Explicit SSP method of order 4 using 10 stages.
188+
"""
189+
function constructSSPRK104(T::Type = Float64)
190+
A = [0 0 0 0 0 0 0 0 0 0
191+
1//6 0 0 0 0 0 0 0 0 0
192+
1//6 1//6 0 0 0 0 0 0 0 0
193+
1//6 1//6 1//6 0 0 0 0 0 0 0
194+
1//6 1//6 1//6 1//6 0 0 0 0 0 0
195+
1//15 1//15 1//15 1//15 1//15 0 0 0 0 0
196+
1//15 1//15 1//15 1//15 1//15 1//6 0 0 0 0
197+
1//15 1//15 1//15 1//15 1//15 1//6 1//6 0 0 0
198+
1//15 1//15 1//15 1//15 1//15 1//6 1//6 1//6 0 0
199+
1//15 1//15 1//15 1//15 1//15 1//6 1//6 1//6 1//6 0]
200+
c = [0; 1//6; 1//3; 1//2; 2//3; 1//3; 1//2; 2//3; 5//6; 1]
201+
α = [1//10; 1//10; 1//10; 1//10; 1//10; 1//10; 1//10; 1//10; 1//10; 1//10]
202+
A = map(T,A)
203+
α = map(T,α)
204+
c = map(T,c)
205+
return(ExplicitRKTableau(A,c,α,4))
206+
end
207+
141208
"""
142209
Implicit Euler Method
143210
"""

test/ode_tableau_convergence_tests.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,34 @@ for i = 1:2 # 1 = num, 2 = ExplicitRK
4949
sim = test_convergence(dts,prob,tabalg)
5050
@test abs(sim.𝒪est[:l∞]-2) < testTol
5151

52+
tabalg = ExplicitRK(tableau=constructSSPRK22())
53+
sim = test_convergence(dts,prob,tabalg)
54+
@test abs(sim.𝒪est[:l∞]-2) < testTol
55+
5256
# Order 3
5357

5458
tabalg = ExplicitRK(tableau=constructBogakiShampine3())
5559
sim = test_convergence(dts,prob,tabalg)
5660
@test abs(sim.𝒪est[:l∞]-3) < testTol
5761

62+
tabalg = ExplicitRK(tableau=constructSSPRK33())
63+
sim = test_convergence(dts,prob,tabalg)
64+
@test abs(sim.𝒪est[:l∞]-3) < testTol
65+
66+
tabalg = ExplicitRK(tableau=constructSSPRK43())
67+
sim = test_convergence(dts,prob,tabalg)
68+
@test abs(sim.𝒪est[:l∞]-3) < testTol
69+
5870
# Order 4
5971

6072
tabalg = ExplicitRK(tableau=constructRKF4())
6173
sim = test_convergence(dts,prob,tabalg)
6274
@test abs(sim.𝒪est[:l∞]-4) < testTol
6375

76+
tabalg = ExplicitRK(tableau=constructSSPRK104())
77+
sim = test_convergence(dts,prob,tabalg)
78+
@test abs(sim.𝒪est[:l∞]-4) < testTol
79+
6480
# Order 5
6581

6682
dts = 1.//2.^(7:-1:4)

0 commit comments

Comments
 (0)