Skip to content

Commit afa33b1

Browse files
committed
Reformulate IMEX ARK and SSPRK timestepping schemes
1 parent c9ad882 commit afa33b1

38 files changed

+1327
-1549
lines changed

.buildkite/pipeline.yml

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ agents:
22
queue: new-central
33
slurm_mem: 8G
44
modules: climacommon/2024_05_27
5-
partition: expansion
65

76
env:
87
JULIA_LOAD_PATH: "${JULIA_LOAD_PATH}:${BUILDKITE_BUILD_CHECKOUT_PATH}/.buildkite"
@@ -24,40 +23,38 @@ steps:
2423
- echo "--- Instantiate perf"
2524
- "julia --project=perf -e 'using Pkg; Pkg.instantiate(;verbose=true); Pkg.precompile(;strict=true)'"
2625

26+
- echo "--- Instantiate docs"
27+
- "julia --project=docs -e 'using Pkg; Pkg.instantiate(;verbose=true); Pkg.precompile(;strict=true)'"
28+
2729
- echo "--- Package status"
2830
- "julia --project -e 'using Pkg; Pkg.status()'"
29-
30-
31-
# - label: "init gpu env"
32-
# key: "init_gpu_env"
33-
# command:
34-
# - echo "--- Configure MPI"
35-
# - julia -e 'using Pkg; Pkg.add("MPIPreferences"); using MPIPreferences; use_system_binary()'
36-
37-
# - echo "--- Instantiate project"
38-
# - "julia --project -e 'using Pkg; Pkg.instantiate(;verbose=true); Pkg.precompile(;strict=true)'"
39-
40-
# - echo "--- Instantiate test"
41-
# - "julia --project=test -e 'using Pkg; Pkg.develop(path=\".\"); Pkg.instantiate(;verbose=true); Pkg.precompile()'"
42-
43-
# - echo "--- Initialize CUDA runtime"
44-
# - "julia --project -e 'using CUDA; CUDA.precompile_runtime(); CUDA.versioninfo()'"
45-
46-
# - echo "--- Package status"
47-
# - "julia --project -e 'using Pkg; Pkg.status()'"
48-
# slurm_gres: "gpu:1"
31+
agents:
32+
slurm_gpus: 1
4933

5034
- wait
5135

5236
- label: "CPU tests"
5337
command: "julia --project=test --check-bounds=yes test/runtests.jl"
5438
artifact_paths: "output/*"
5539

56-
# - label: "GPU tests"
57-
# command:
58-
# - "julia --project=test --check-bounds=yes test/runtests.jl CuArray"
59-
# artifact_paths: "output/*"
60-
# slurm_gres: "gpu:1"
40+
- label: "Deformational flow limiter test (CPU)"
41+
command:
42+
- "julia --project=docs --check-bounds=yes docs/src/test_deformational_flow.jl CPU"
43+
artifact_paths: "output_CPU/*"
44+
45+
- label: "Deformational flow limiter test (GPU)"
46+
command:
47+
- "julia --project=docs docs/src/test_deformational_flow.jl GPU"
48+
artifact_paths: "output_GPU/*"
49+
agents:
50+
slurm_gpus: 1
51+
52+
- label: "Deformational flow limiter test (GPU w/ check-bounds)"
53+
command:
54+
- "julia --project=docs --check-bounds=yes docs/src/test_deformational_flow.jl GPU_checkbounds"
55+
artifact_paths: "output_GPU_checkbounds/*"
56+
agents:
57+
slurm_gpus: 1
6158

6259
- label: "Flame graph (1D diffusion)"
6360
command: "julia --project=perf perf/flame.jl --job_id diffusion_1D"

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ LinearOperators = "5c8ed15e-5a4c-59e4-a42b-c7e8811fb125"
1616
NVTX = "5da4648a-3479-48b8-97b9-01cb529c0a1f"
1717
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
1818
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
19+
UnrolledUtilities = "0fe1646c-419e-43be-ac14-22321958931b"
1920

2021
[weakdeps]
2122
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
@@ -45,4 +46,5 @@ NVTX = "0.3"
4546
SciMLBase = "1, 2"
4647
StaticArrays = "1"
4748
StatsBase = "0.33, 0.34"
49+
UnrolledUtilities = "0.1"
4850
julia = "1.8"

docs/Manifest.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ uuid = "cf7c7e5a-b407-4c48-9047-11a94a308626"
249249
version = "0.2.10"
250250

251251
[[deps.ClimaTimeSteppers]]
252-
deps = ["ClimaComms", "Colors", "DataStructures", "DiffEqBase", "DiffEqCallbacks", "KernelAbstractions", "Krylov", "LinearAlgebra", "LinearOperators", "NVTX", "SciMLBase", "StaticArrays"]
252+
deps = ["ClimaComms", "Colors", "DataStructures", "DiffEqBase", "DiffEqCallbacks", "KernelAbstractions", "Krylov", "LinearAlgebra", "LinearOperators", "NVTX", "SciMLBase", "StaticArrays", "UnrolledUtilities"]
253253
path = ".."
254254
uuid = "595c0a79-7f3d-439a-bc5a-b232dc3bde79"
255255
version = "0.7.31"
@@ -2123,6 +2123,11 @@ git-tree-sha1 = "6cc9d682755680e0f0be87c56392b7651efc2c7b"
21232123
uuid = "9602ed7d-8fef-5bc8-8597-8f21381861e8"
21242124
version = "0.1.5"
21252125

2126+
[[deps.UnrolledUtilities]]
2127+
git-tree-sha1 = "b73f7a7c25a2618c5052c80ed32b07e471cc6cb0"
2128+
uuid = "0fe1646c-419e-43be-ac14-22321958931b"
2129+
version = "0.1.2"
2130+
21262131
[[deps.UnsafeAtomics]]
21272132
git-tree-sha1 = "6331ac3440856ea1988316b46045303bef658278"
21282133
uuid = "013be700-e6cd-48c3-b4a1-df204f14c38f"

docs/src/api/ode_solvers.md

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,39 @@
44
CurrentModule = ClimaTimeSteppers
55
```
66

7-
## Interface
7+
## Tableau Interface
88

99
```@docs
10-
AbstractAlgorithmConstraint
11-
Unconstrained
12-
SSP
13-
IMEXTableau
14-
IMEXAlgorithm
15-
ExplicitTableau
16-
ExplicitAlgorithm
10+
ClimaTimeSteppers.RKTableau
11+
ClimaTimeSteppers.ButcherTableau
12+
ClimaTimeSteppers.ShuOsherTableau
13+
ClimaTimeSteppers.PaddedTableau
14+
ClimaTimeSteppers.ARKTableau
15+
ClimaTimeSteppers.is_ERK
16+
ClimaTimeSteppers.is_DIRK
1717
```
1818

19-
## IMEX Algorithm Names
19+
## Algorithm Interface
20+
21+
```@docs
22+
AbstractAlgorithmName
23+
ClimaTimeSteppers.RKAlgorithmName
24+
ClimaTimeSteppers.SSPRKAlgorithmName
25+
ClimaTimeSteppers.ARKAlgorithmName
26+
ClimaTimeSteppers.IMEXSSPRKAlgorithmName
27+
RKAlgorithm
28+
ARKAlgorithm
29+
```
30+
31+
## RK Algorithm Names
32+
33+
```@docs
34+
SSP22Heuns
35+
SSP33ShuOsher
36+
RK4
37+
```
38+
39+
## ARK Algorithm Names
2040

2141
```@docs
2242
ARS111
@@ -54,14 +74,6 @@ ARK548L2SA2
5474
SSPKnoth
5575
```
5676

57-
## Explicit Algorithm Names
58-
59-
```@docs
60-
SSP22Heuns
61-
SSP33ShuOsher
62-
RK4
63-
```
64-
6577
## Old LSRK Interface
6678

6779
```@docs

docs/src/dev/report_gen.jl

Lines changed: 28 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,66 +8,53 @@ using InteractiveUtils: subtypes
88

99
ENV["GKSwstype"] = "nul" # avoid displaying plots
1010

11-
include(joinpath(@__DIR__, "..", "plotting_utils.jl"))
1211
include(joinpath(pkgdir(ClimaTimeSteppers), "test", "problems.jl"))
12+
include(joinpath(@__DIR__, "..", "plotting_utils.jl"))
1313

1414
all_subtypes(::Type{T}) where {T} = isabstracttype(T) ? vcat(all_subtypes.(subtypes(T))...) : [T]
1515

1616
let # Convergence
1717
title = "All Algorithms"
1818
algorithm_names = map(T -> T(), all_subtypes(ClimaTimeSteppers.AbstractAlgorithmName))
19-
algorithm_names = filter(name -> !(name isa ARK437L2SA1 || name isa ARK548L2SA2), algorithm_names) # too high order
2019

21-
# NOTE: Some imperfections in the convergence order for SSPKnoth are to be
22-
# expected because we are not using the exact Jacobian
20+
verify_convergence(title, algorithm_names, ark_analytic_nonlin_test_cts(Float64), 300)
21+
verify_convergence(title, algorithm_names, ark_analytic_sys_test_cts(Float64), 350)
22+
verify_convergence(title, algorithm_names, onewaycouple_mri_test_cts(Float64), 2000)
23+
verify_convergence(
24+
title,
25+
algorithm_names,
26+
ark_analytic_test_cts(Float64),
27+
16650;
28+
num_test_points = 6,
29+
num_steps_scaling_factor = 23,
30+
super_convergence = (ARS121(),),
31+
)
2332

24-
verify_convergence(title, algorithm_names, ark_analytic_nonlin_test_cts(Float64), 200)
25-
verify_convergence(title, algorithm_names, ark_analytic_sys_test_cts(Float64), 400)
26-
verify_convergence(title, algorithm_names, ark_analytic_test_cts(Float64), 40000; super_convergence = (ARS121(),))
27-
verify_convergence(title, algorithm_names, onewaycouple_mri_test_cts(Float64), 10000; num_steps_scaling_factor = 5)
2833
verify_convergence(
2934
title,
3035
algorithm_names,
3136
climacore_1Dheat_test_cts(Float64),
32-
400;
33-
num_steps_scaling_factor = 4,
34-
numerical_reference_algorithm_name = ARS343(),
37+
40;
38+
numerical_reference_algorithm_name = ARK548L2SA2(),
39+
numerical_reference_num_steps = 500000,
3540
)
36-
rosenbrock_schems = filter(name -> name isa ClimaTimeSteppers.RosenbrockAlgorithmName, algorithm_names)
37-
verify_convergence(title, rosenbrock_schems, climacore_1Dheat_test_implicit_cts(Float64), 400)
3841
verify_convergence(
3942
title,
4043
algorithm_names,
4144
climacore_2Dheat_test_cts(Float64),
42-
600;
43-
num_steps_scaling_factor = 4,
44-
numerical_reference_algorithm_name = ARS343(),
45+
40;
46+
numerical_reference_algorithm_name = ARK548L2SA2(),
47+
numerical_reference_num_steps = 500000,
4548
)
46-
end
4749

48-
let # Unconstrained vs SSP results without limiters
49-
algorithm_names = map(T -> T(), all_subtypes(ClimaTimeSteppers.IMEXSSPRKAlgorithmName))
50-
for (test_case, num_steps) in (
51-
(ark_analytic_nonlin_test_cts(Float64), 200),
52-
(ark_analytic_sys_test_cts(Float64), 400),
53-
(ark_analytic_test_cts(Float64), 40000),
54-
(onewaycouple_mri_test_cts(Float64), 10000),
55-
(climacore_1Dheat_test_cts(Float64), 200),
56-
(climacore_2Dheat_test_cts(Float64), 200),
50+
verify_convergence(
51+
title,
52+
algorithm_names,
53+
climacore_1Dheat_test_implicit_cts(Float64),
54+
60;
55+
num_test_points = 4,
56+
num_steps_scaling_factor = 8,
57+
numerical_reference_algorithm_name = ARK548L2SA2(),
58+
numerical_reference_num_steps = 500000,
5759
)
58-
prob = test_case.split_prob
59-
dt = test_case.t_end / num_steps
60-
newtons_method = NewtonsMethod(; max_iters = test_case.linear_implicit ? 1 : 2)
61-
for algorithm_name in algorithm_names
62-
algorithm = IMEXAlgorithm(algorithm_name, newtons_method)
63-
reference_algorithm = IMEXAlgorithm(algorithm_name, newtons_method, Unconstrained())
64-
solution = solve(deepcopy(prob), algorithm; dt).u[end]
65-
reference_solution = solve(deepcopy(prob), reference_algorithm; dt).u[end]
66-
if norm(solution .- reference_solution) / norm(reference_solution) > 30 * eps(Float64)
67-
alg_str = string(nameof(typeof(algorithm_name)))
68-
@warn "Unconstrained and SSP versions of $alg_str \
69-
give different results for $(test_case.test_name)"
70-
end
71-
end
72-
end
7360
end

docs/src/dev/report_gen.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Verifying Correctness
22

3-
The `IMEXAlgorithm` supports problems that specify any combination of the following: an implicit tendency `T_imp!`, an explicit tendency `T_exp!`, a limited tendency `T_lim!`, a function `dss!` that applies a direct stiffness summation, and a function `lim!` that applies a monotonicity-preserving limiter.
3+
The `ARKAlgorithm` supports problems that specify any combination of the following: an implicit tendency `T_imp!`, an explicit tendency `T_exp!`, a limited tendency `T_lim!`, a function `dss!` that applies a direct stiffness summation, and a function `lim!` that applies a monotonicity-preserving limiter.
44

55
## Convergence without a Limiter
66

@@ -12,7 +12,9 @@ The test cases we use for this analysis are:
1212
- `ark_analytic`, which uses a nonlinear `T_exp!` and a linear `T_imp!`
1313
- `ark_analytic_sys` and `ark_onewaycouple_mri`, which use a linear `T_imp!`
1414
- `ark_analytic_nonlin`, which uses a nonlinear `T_imp!`
15-
- `1d_heat_equation` and `2d_heat_equation`, which use a nonlinear `T_exp!` and `dss!`, where the spatial discretization is implemented using `ClimaCore`
15+
- `1d_heat_equation`, which uses a nonlinear `T_exp!` implemented with `ClimaCore`
16+
- `2d_heat_equation`, which uses a nonlinear `T_exp!` and `dss!` implemented with `ClimaCore`
17+
- `1d_heat_equation_implicit`, which uses a nonlinear `T_imp!` implemented with `ClimaCore`
1618

1719
```@example
1820
include("report_gen.jl")
@@ -23,6 +25,7 @@ include("report_gen.jl")
2325
![](output/convergence_ark_analytic_nonlin_all_algorithms.png)
2426
![](output/convergence_1d_heat_equation_all_algorithms.png)
2527
![](output/convergence_2d_heat_equation_all_algorithms.png)
28+
![](output/convergence_1d_heat_equation_implicit_all_algorithms.png)
2629

2730
## Errors with a Limiter
2831

@@ -40,8 +43,8 @@ limiter_summary(Float64, [SSP333(), ARS343()], horizontal_deformational_flow_tes
4043
```
4144

4245
Plots of the tracer specific humidities that were used to compute this table are shown below.
43-
![](output/limiter_summary_SSP333.png)
44-
![](output/limiter_summary_ARS343.png)
46+
![](output/horizontal_deformational_flow_limiter_summary_SSP333.png)
47+
![](output/horizontal_deformational_flow_limiter_summary_ARS343.png)
4548

4649
## References
4750

0 commit comments

Comments
 (0)