11using ClimaTimeSteppers, LinearAlgebra, Test
22
3- dts = 0.5 .^ (4 : 7 )
4-
5- for (prob, sol, tscale) in [
6- (linear_prob, linear_sol, 1 )
7- (sincos_prob, sincos_sol, 1 )
8- ]
9-
10- @test convergence_order (prob, sol, LSRKEulerMethod (), dts.* tscale) ≈ 1 atol= 0.1
11- @test convergence_order (prob, sol, LSRK54CarpenterKennedy (), dts.* tscale) ≈ 4 atol= 0.05
12- @test convergence_order (prob, sol, LSRK144NiegemannDiehlBusch (), dts.* tscale) ≈ 4 atol= 0.05
3+ include (joinpath (@__DIR__ , " convergence_utils.jl" ))
4+ include (joinpath (@__DIR__ , " utils.jl" ))
5+ include (joinpath (@__DIR__ , " problems.jl" ))
6+
7+ @testset " LSRK and SSP convergence" begin
8+ dts = 0.5 .^ (4 : 7 )
9+
10+ for (prob, sol, tscale) in [
11+ (linear_prob (), linear_sol, 1 )
12+ (sincos_prob (), sincos_sol, 1 )
13+ ]
14+
15+ @test convergence_order (prob, sol, LSRKEulerMethod (), dts.* tscale) ≈ 1 atol= 0.1
16+ @test convergence_order (prob, sol, LSRK54CarpenterKennedy (), dts.* tscale) ≈ 4 atol= 0.05
17+ @test convergence_order (prob, sol, LSRK144NiegemannDiehlBusch (), dts.* tscale) ≈ 4 atol= 0.05
18+
19+ @test convergence_order (prob, sol, SSPRK22Heuns (), dts.* tscale) ≈ 2 atol= 0.05
20+ @test convergence_order (prob, sol, SSPRK22Ralstons (), dts.* tscale) ≈ 2 atol= 0.05
21+ @test convergence_order (prob, sol, SSPRK33ShuOsher (), dts.* tscale) ≈ 3 atol= 0.05
22+ @test convergence_order (prob, sol, SSPRK34SpiteriRuuth (), dts.* tscale) ≈ 3 atol= 0.05
23+ end
1324
14- @test convergence_order (prob, sol, SSPRK22Heuns (), dts.* tscale) ≈ 2 atol= 0.05
15- @test convergence_order (prob, sol, SSPRK22Ralstons (), dts.* tscale) ≈ 2 atol= 0.05
16- @test convergence_order (prob, sol, SSPRK33ShuOsher (), dts.* tscale) ≈ 3 atol= 0.05
17- @test convergence_order (prob, sol, SSPRK34SpiteriRuuth (), dts.* tscale) ≈ 3 atol= 0.05
18- end
25+ for (prob, sol, tscale) in [
26+ (linear_prob_wfactt (), linear_sol, 1 )
27+ ]
28+ @test convergence_order (prob, sol, SSPKnoth (linsolve= linsolve_direct), dts.* tscale) ≈ 2 atol= 0.05
1929
20- for (prob, sol, tscale) in [
21- (linear_prob_wfactt, linear_sol, 1 )
22- ]
23- @test convergence_order (prob, sol, SSPKnoth (linsolve= linsolve_direct), dts.* tscale) ≈ 2 atol= 0.05
30+ end
2431
25- end
2632
33+ # ForwardEulerODEFunction
34+ for (prob, sol, tscale) in [
35+ (linear_prob_fe (), linear_sol, 1 )
36+ (sincos_prob_fe (), sincos_sol, 1 )
37+ ]
38+ @test convergence_order (prob, sol, SSPRK22Heuns (), dts.* tscale) ≈ 2 atol= 0.05
39+ @test convergence_order (prob, sol, SSPRK22Ralstons (), dts.* tscale) ≈ 2 atol= 0.05
40+ @test convergence_order (prob, sol, SSPRK33ShuOsher (), dts.* tscale) ≈ 3 atol= 0.05
41+ @test convergence_order (prob, sol, SSPRK34SpiteriRuuth (), dts.* tscale) ≈ 3 atol= 0.05
2742
28- # ForwardEulerODEFunction
29- for (prob, sol, tscale) in [
30- (linear_prob_fe, linear_sol, 1 )
31- (sincos_prob_fe, sincos_sol, 1 )
32- ]
33- @test convergence_order (prob, sol, SSPRK22Heuns (), dts.* tscale) ≈ 2 atol= 0.05
34- @test convergence_order (prob, sol, SSPRK22Ralstons (), dts.* tscale) ≈ 2 atol= 0.05
35- @test convergence_order (prob, sol, SSPRK33ShuOsher (), dts.* tscale) ≈ 3 atol= 0.05
36- @test convergence_order (prob, sol, SSPRK34SpiteriRuuth (), dts.* tscale) ≈ 3 atol= 0.05
37-
43+ end
3844end
3945
4046ENV [" GKSwstype" ] = " nul" # avoid displaying plots
@@ -46,14 +52,14 @@ ENV["GKSwstype"] = "nul" # avoid displaying plots
4652 algs2 = (algs2... , IMKG254b, IMKG254c, HOMMEM1)
4753 algs3 = (ARS233, ARS343, ARS443, IMKG342a, IMKG343a, DBM453)
4854 dict = Dict (((algs1 .=> 1 ). .. , (algs2 .=> 2 ). .. , (algs3 .=> 3 ). .. ))
49- test_algs (" IMEX ARK" , dict, ark_analytic_nonlin_test, 400 )
50- test_algs (" IMEX ARK" , dict, ark_analytic_sys_test, 60 )
55+ test_algs (" IMEX ARK" , dict, ark_analytic_nonlin_test (Float64) , 400 )
56+ test_algs (" IMEX ARK" , dict, ark_analytic_sys_test (Float64) , 60 )
5157
5258 # For some bizarre reason, ARS121 converges with order 2 for ark_analytic,
5359 # even though it is only a 1st order method.
5460 dict′ = copy (dict)
5561 dict′[ARS121] = 2
56- test_algs (" IMEX ARK" , dict′, ark_analytic_test, 16000 )
62+ test_algs (" IMEX ARK" , dict′, ark_analytic_test (Float64) , 16000 )
5763end
5864
5965#=
0 commit comments