Skip to content

Commit 597b82b

Browse files
Merge #99
99: Add theoretic convergence order func stub r=charleskawczynski a=charleskawczynski This PR adds a theoretic convergence order stub, that we can use per algorithm. This will be nice for users, and for our tests. Co-authored-by: Charles Kawczynski <[email protected]>
2 parents 08384f5 + bbc32c2 commit 597b82b

File tree

4 files changed

+68
-6
lines changed

4 files changed

+68
-6
lines changed

src/ClimaTimeSteppers.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,16 @@ include("functions.jl")
6464
include("operators.jl")
6565
include("algorithms.jl")
6666

67-
abstract type DistributedODEAlgorithm <: DiffEqBase.AbstractODEAlgorithm
68-
end
67+
abstract type DistributedODEAlgorithm <: DiffEqBase.AbstractODEAlgorithm end
68+
69+
"""
70+
theoretical_convergence_order
71+
72+
Returns the theoretical convergence order of an ODE algorithm
73+
"""
74+
function theoretical_convergence_order end
75+
theoretical_convergence_order(alg::DistributedODEAlgorithm) =
76+
error("No convergence order found for algo $alg, please open an issue or PR.")
6977

7078
SciMLBase.allowscomplex(alg::DistributedODEAlgorithm) = true
7179
include("integrators.jl")
@@ -89,4 +97,6 @@ include("solvers/rosenbrock.jl")
8997

9098
include("callbacks.jl")
9199

100+
include("convergence_orders.jl")
101+
92102
end

src/convergence_orders.jl

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#####
2+
##### 1st order
3+
#####
4+
5+
const first_order_methods = [
6+
# ARS111,
7+
# ARS121,
8+
]
9+
10+
#####
11+
##### 2nd order
12+
#####
13+
14+
const second_order_methods = [
15+
# ARS122,
16+
# ARS232,
17+
# ARS222,
18+
# IMKG232a,
19+
# IMKG232b,
20+
# IMKG242a,
21+
# IMKG242b,
22+
# IMKG252a,
23+
# IMKG252b,
24+
# IMKG253a,
25+
# IMKG253b,
26+
# IMKG254a,
27+
# IMKG254b,
28+
# IMKG254c,
29+
# HOMMEM1,
30+
]
31+
32+
#####
33+
##### 3rd order
34+
#####
35+
const third_order_methods = [
36+
# ARS233,
37+
# ARS343,
38+
# ARS443,
39+
# IMKG342a,
40+
# IMKG343a,
41+
# DBM453,
42+
]
43+
44+
for m in first_order_methods
45+
@eval theoretical_convergence_order(::$m) = 1
46+
end
47+
for m in second_order_methods
48+
@eval theoretical_convergence_order(::$m) = 2
49+
end
50+
for m in third_order_methods
51+
@eval theoretical_convergence_order(::$m) = 3
52+
end

src/solvers/imex_ark.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ js_to_save(i, a) = filter(
178178

179179
# Helper functions for tendencies
180180
has_implicit_step(i, a) = i <= size(a, 2) && a[i, i] != 0
181-
save_tendency(i, a) =
181+
save_tendency(i, a) =
182182
!isnothing(findlast(i′ -> a[i′, i] != 0, (i + 1):size(a, 1)))
183183

184184
# Helper functions for increments and tendencies
@@ -440,10 +440,10 @@ function not_generated_cache(
440440
))
441441
newtons_method_cache =
442442
allocate_cache(alg.newtons_method, u, prob.f.f1.jac_prototype)
443-
443+
444444
f_types = (typeof(prob.f.f2), typeof(prob.f.f1))
445445
@inbounds _cache = (;
446-
_cache...,
446+
_cache...,
447447
u_alias_is_ = u_alias_is(as[1], as[2]),
448448
first_i_s = map-> map(j -> first_i(j, as[χ]), j_range(as[χ])), Tuple(1:2)),
449449
new_js_s = map-> map(i -> new_js(i, as[χ]), i_range(as[χ])), Tuple(1:2)),

test/ode_tests_common.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ DirectSolver(args...) = DirectSolver()
5050
function (::DirectSolver)(x,A,b,matrix_updated; kwargs...)
5151
n = length(x)
5252
M = mapslices(y -> mul!(similar(y), A, y), Matrix{eltype(x)}(I,n,n), dims=1)
53-
x .= M \ b
53+
x .= M \ b
5454
end

0 commit comments

Comments
 (0)