Skip to content

Commit aa6677c

Browse files
bors[bot]charleskawczynskidennisYatunin
authored
Merge #85
85: Revamp imex ark r=charleskawczynski a=charleskawczynski This PR revamps the imex ark time stepper, as outlined in the google doc. It's still a WIP. Related issue: #83. Co-authored-by: Charles Kawczynski <[email protected]> Co-authored-by: Dennis Yatunin <[email protected]>
2 parents 506e01c + 5eb48c9 commit aa6677c

File tree

14 files changed

+415
-43
lines changed

14 files changed

+415
-43
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ClimaTimeSteppers"
22
uuid = "595c0a79-7f3d-439a-bc5a-b232dc3bde79"
33
authors = ["Climate Modeling Alliance"]
4-
version = "0.3.0"
4+
version = "0.4.0"
55

66
[deps]
77
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"

docs/src/algorithms.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ ForwardEulerODEFunction
1515
## IMEX ARK methods
1616

1717
```@docs
18-
IMEXARKAlgorithm
19-
make_IMEXARKTableau
18+
OldIMEXARKAlgorithm
19+
Oldmake_IMEXARKTableau
2020
```
2121

2222
The convergence orders of the provided methods are verified using test cases from [ARKode](http://runge.math.smu.edu/ARKode_example.pdf). Plots of the solutions to these test cases, the errors of these solutions, and the convergence orders with respect to `dt` are shown below.
@@ -90,7 +90,7 @@ ARK548L2SA2KennedyCarpenter
9090

9191
### ARS
9292

93-
TODO: `ARS111`, `ARS121`, and `ARS343` should probably be types, and not constants, so that we can properly document them.
93+
TODO: add `ARS111`, `ARS121`, and `ARS343` docs.
9494

9595
## Multirate
9696

perf/flame.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ elseif problem_str=="fe"
3030
else
3131
error("Bad option")
3232
end
33-
algorithm = CTS.IMEXARKAlgorithm(ARS343(), NewtonsMethod(; max_iters = 2))
33+
algorithm = CTS.OldIMEXARKAlgorithm(OldARS343(), NewtonsMethod(; max_iters = 2))
3434
dt = 0.01
3535
integrator = DiffEqBase.init(prob, algorithm; dt)
3636
not_generated_cache = CTS.not_generated_cache(prob, algorithm)

perf/jet.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ end
1515
cts = joinpath(dirname(@__DIR__));
1616
include(joinpath(cts, "test", "problems.jl"))
1717
function config_integrators(problem)
18-
algorithm = CTS.IMEXARKAlgorithm(ARS343(), NewtonsMethod(; linsolve = linsolve_direct, max_iters = 2))
18+
algorithm = CTS.OldIMEXARKAlgorithm(OldARS343(), NewtonsMethod(; linsolve = linsolve_direct, max_iters = 2))
1919
dt = 0.01
2020
integrator = DiffEqBase.init(problem, algorithm; dt)
2121
not_generated_integrator = DiffEqBase.init(problem, algorithm; dt)

src/ClimaTimeSteppers.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ include("algorithms.jl")
6767
abstract type DistributedODEAlgorithm <: DiffEqBase.AbstractODEAlgorithm end
6868

6969
abstract type AbstractIMEXARKAlgorithm <: DistributedODEAlgorithm end
70-
abstract type AbstractIMEXARKTableau end
70+
71+
abstract type AbstractTableau end
72+
abstract type AbstractIMEXARKTableau <: AbstractTableau end
7173

7274
"""
7375
tableau(::DistributedODEAlgorithm)
@@ -93,6 +95,7 @@ include("solvers/convergence_condition.jl")
9395
include("solvers/convergence_checker.jl")
9496
include("solvers/newtons_method.jl")
9597
include("solvers/imex_ark.jl")
98+
include("solvers/imex_ark2.jl")
9699

97100
# Include concrete implementations
98101
include("solvers/imex_ark_tableaus.jl")

src/convergence_orders.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const second_order_tableau = [
3636
#####
3737
const third_order_tableau = [
3838
ARS233,
39+
OldARS343,
3940
ARS343,
4041
ARS443,
4142
IMKG342a,

src/solvers/imex_ark.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,44 +112,44 @@ Is this too messy to do in the general case?
112112
113113
Don't forget about the possible memory optimizations!
114114
=#
115-
export IMEXARKAlgorithm, make_IMEXARKTableau
115+
export OldIMEXARKAlgorithm, Oldmake_IMEXARKTableau
116116

117117
using Base: broadcasted, materialize!
118118
using StaticArrays: SMatrix, SVector
119119

120120
"""
121-
IMEXARKAlgorithm <: DistributedODEAlgorithm
121+
OldIMEXARKAlgorithm <: DistributedODEAlgorithm
122122
123123
A generic implementation of an IMEX ARK algorithm that can handle arbitrary
124124
Butcher tableaus and problems specified using either `ForwardEulerODEFunction`s
125125
or regular `ODEFunction`s.
126126
"""
127-
struct IMEXARKAlgorithm{as, cs, N} <: AbstractIMEXARKAlgorithm
127+
struct OldIMEXARKAlgorithm{as, cs, N} <: AbstractIMEXARKAlgorithm
128128
newtons_method::N
129129
end
130130

131-
IMEXARKAlgorithm{as, cs}(newtons_method::N) where {as, cs, N} =
132-
IMEXARKAlgorithm{as, cs, N}(newtons_method)
131+
OldIMEXARKAlgorithm{as, cs}(newtons_method::N) where {as, cs, N} =
132+
OldIMEXARKAlgorithm{as, cs, N}(newtons_method)
133133

134134
"""
135-
IMEXARKAlgorithm(::AbstractIMEXARKAlgorithm, newtons_method)
135+
OldIMEXARKAlgorithm(::AbstractIMEXARKAlgorithm, newtons_method)
136136
137137
Returns the imex ARK algorithm for a particular algorithm.
138138
"""
139-
function IMEXARKAlgorithm(tab::AbstractIMEXARKTableau, newtons_method)
139+
function OldIMEXARKAlgorithm(tab::AbstractIMEXARKTableau, newtons_method)
140140
tableau(tab)(newtons_method)
141141
end
142142

143143
"""
144-
make_IMEXARKTableau(; a_exp, b_exp, c_exp, a_imp, b_imp, c_imp)
144+
Oldmake_IMEXARKTableau(; a_exp, b_exp, c_exp, a_imp, b_imp, c_imp)
145145
146-
Generates an `IMEXARKAlgorithm` type from an IMEX ARK Butcher tableau. Only
146+
Generates an `OldIMEXARKAlgorithm` type from an IMEX ARK Butcher tableau. Only
147147
`a_exp` and `a_imp` are required arguments; the default values for `b_exp` and
148148
`b_imp` assume that the algorithm is FSAL (first same as last), and the default
149149
values for `c_exp` and `c_imp` assume that the algorithm is internally
150150
consistent.
151151
"""
152-
function make_IMEXARKTableau(;
152+
function Oldmake_IMEXARKTableau(;
153153
a_exp::SMatrix{s, s},
154154
b_exp::SVector{s} = vec(a_exp[end, :]),
155155
c_exp::SVector{s} = vec(sum(a_exp; dims = 2)),
@@ -165,7 +165,7 @@ function make_IMEXARKTableau(;
165165
as = (vcat(a_exp, b_exp'), vcat(a_imp, b_imp'))
166166
end
167167
cs = (c_exp, c_imp)
168-
return IMEXARKAlgorithm{as, cs}
168+
return OldIMEXARKAlgorithm{as, cs}
169169
end
170170

171171
# General helper functions
@@ -208,7 +208,7 @@ end
208208
# interval graph for all required cached values.
209209
function cache(
210210
prob::DiffEqBase.AbstractODEProblem,
211-
alg::IMEXARKAlgorithm{as, cs};
211+
alg::OldIMEXARKAlgorithm{as, cs};
212212
kwargs...
213213
) where {as, cs}
214214
f_cache(χ, a, f_type) = is_increment(f_type) ?
@@ -440,7 +440,7 @@ step_u!(integrator, cache::IMEXARKCache) =
440440

441441
function not_generated_cache(
442442
prob::DiffEqBase.AbstractODEProblem,
443-
alg::IMEXARKAlgorithm{as, cs};
443+
alg::OldIMEXARKAlgorithm{as, cs};
444444
kwargs...
445445
) where {as, cs}
446446
f_cache(χ, a, f_type) = is_increment(f_type) ?

0 commit comments

Comments
 (0)