Skip to content

Commit 524829a

Browse files
Merge pull request #1979 from CliMA/ck/reduce_deps_iter3
Remove OrdinaryDiffEq dependence in all environments
2 parents 7cb570d + 7a897fa commit 524829a

File tree

6 files changed

+7
-170
lines changed

6 files changed

+7
-170
lines changed

.buildkite/Manifest.toml

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
julia_version = "1.10.4"
44
manifest_format = "2.0"
5-
project_hash = "a3b8e1623c974758b823be61fb12f149202fadbb"
5+
project_hash = "fd1e670d65913da2cbb0367d634efd6165bc7d16"
66

77
[[deps.ADTypes]]
88
git-tree-sha1 = "99a6f5d0ce1c7c6afdb759daa30226f71c54f6b0"
@@ -693,12 +693,6 @@ git-tree-sha1 = "1c6317308b9dc757616f0b5cb379db10494443a7"
693693
uuid = "2e619515-83b5-522b-bb60-26c02a35a201"
694694
version = "2.6.2+0"
695695

696-
[[deps.ExponentialUtilities]]
697-
deps = ["Adapt", "ArrayInterface", "GPUArraysCore", "GenericSchur", "LinearAlgebra", "PrecompileTools", "Printf", "SparseArrays", "libblastrampoline_jll"]
698-
git-tree-sha1 = "8e18940a5ba7f4ddb41fe2b79b6acaac50880a86"
699-
uuid = "d4d017d3-3776-5f7e-afef-a10c40355c18"
700-
version = "1.26.1"
701-
702696
[[deps.ExprTools]]
703697
git-tree-sha1 = "27415f162e6028e81c72b82ef756bf321213b6ec"
704698
uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
@@ -911,12 +905,6 @@ git-tree-sha1 = "eb6f1f48aa994f3018cbd029a17863c6535a266d"
911905
uuid = "d54b0c1a-921d-58e0-8e36-89d8069c0969"
912906
version = "0.5.8"
913907

914-
[[deps.GenericSchur]]
915-
deps = ["LinearAlgebra", "Printf"]
916-
git-tree-sha1 = "af49a0851f8113fcfae2ef5027c6d49d0acec39b"
917-
uuid = "c145ed77-6b09-5dd9-b285-bf645a82121e"
918-
version = "0.5.4"
919-
920908
[[deps.Gettext_jll]]
921909
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Libiconv_jll", "Pkg", "XML2_jll"]
922910
git-tree-sha1 = "9b02998aba7bf074d14de89f9d37ca24a1a0b046"
@@ -1738,12 +1726,6 @@ git-tree-sha1 = "dfdf5519f235516220579f949664f1bf44e741c5"
17381726
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
17391727
version = "1.6.3"
17401728

1741-
[[deps.OrdinaryDiffEq]]
1742-
deps = ["ADTypes", "Adapt", "ArrayInterface", "DataStructures", "DiffEqBase", "DocStringExtensions", "EnumX", "ExponentialUtilities", "FastBroadcast", "FastClosures", "FillArrays", "FiniteDiff", "ForwardDiff", "FunctionWrappersWrappers", "IfElse", "InteractiveUtils", "LineSearches", "LinearAlgebra", "LinearSolve", "Logging", "MacroTools", "MuladdMacro", "NonlinearSolve", "Polyester", "PreallocationTools", "PrecompileTools", "Preferences", "RecursiveArrayTools", "Reexport", "SciMLBase", "SciMLOperators", "SciMLStructures", "SimpleNonlinearSolve", "SimpleUnPack", "SparseArrays", "SparseDiffTools", "Static", "StaticArrayInterface", "StaticArrays", "TruncatedStacktraces"]
1743-
git-tree-sha1 = "a8b2d333cd90562b58b977b4033739360b37fb1f"
1744-
uuid = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
1745-
version = "6.87.0"
1746-
17471729
[[deps.OrdinaryDiffEqCore]]
17481730
deps = ["ADTypes", "Adapt", "ArrayInterface", "DataStructures", "DiffEqBase", "DocStringExtensions", "EnumX", "FastBroadcast", "FastClosures", "FillArrays", "FunctionWrappersWrappers", "InteractiveUtils", "LinearAlgebra", "Logging", "MacroTools", "MuladdMacro", "Polyester", "PrecompileTools", "Preferences", "RecursiveArrayTools", "Reexport", "SciMLBase", "SciMLOperators", "SciMLStructures", "SimpleUnPack", "Static", "StaticArrayInterface", "StaticArraysCore", "TruncatedStacktraces"]
17491731
git-tree-sha1 = "bc70a38874c801549d415c16a23ec632ad91afd1"

.buildkite/Project.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
3434
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
3535
NVTX = "5da4648a-3479-48b8-97b9-01cb529c0a1f"
3636
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
37-
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
3837
OrdinaryDiffEqSSPRK = "669c94d9-1f4b-4b64-b377-1aa079aa2388"
3938
OrdinaryDiffEqTsit5 = "b1df2697-797e-41e3-8120-5422d3b24e4a"
4039
PProf = "e4faabce-9ead-11e9-39d9-4379958e3056"
@@ -60,5 +59,4 @@ ThreadsX = "ac1d9e8a-700a-412c-b207-f0111f4b6c0d"
6059
URIs = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
6160

6261
[compat]
63-
OrdinaryDiffEq = "6"
6462
SnoopCompileCore = "2"

examples/hybrid/driver.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ callback = SciMLBase.CallbackSet(
151151
additional_callbacks...,
152152
)
153153

154-
problem = ODE.ODEProblem(
154+
problem = SciMLBase.ODEProblem(
155155
CTS.ClimaODEFunction(;
156156
T_imp! = ODEFunction(
157157
implicit_tendency!;

examples/hybrid/ode_config.jl

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import SciMLBase
2-
import OrdinaryDiffEq as ODE
32
import ClimaTimeSteppers as CTS
43

54
is_explicit_CTS_algo_type(alg_or_tableau) =
@@ -8,35 +7,13 @@ is_explicit_CTS_algo_type(alg_or_tableau) =
87
is_imex_CTS_algo_type(alg_or_tableau) =
98
alg_or_tableau <: CTS.IMEXARKAlgorithmName
109

11-
is_implicit_type(::typeof(ODE.IMEXEuler)) = true
12-
is_implicit_type(alg_or_tableau) =
13-
alg_or_tableau <: Union{
14-
ODE.OrdinaryDiffEqImplicitAlgorithm,
15-
ODE.OrdinaryDiffEqAdaptiveImplicitAlgorithm,
16-
} || is_imex_CTS_algo_type(alg_or_tableau)
17-
18-
is_ordinary_diffeq_newton(::typeof(ODE.IMEXEuler)) = true
19-
is_ordinary_diffeq_newton(alg_or_tableau) =
20-
alg_or_tableau <: Union{
21-
ODE.OrdinaryDiffEqNewtonAlgorithm,
22-
ODE.OrdinaryDiffEqNewtonAdaptiveAlgorithm,
23-
}
24-
2510
is_imex_CTS_algo(::CTS.IMEXAlgorithm) = true
2611
is_imex_CTS_algo(::SciMLBase.AbstractODEAlgorithm) = false
2712

28-
is_implicit(::ODE.OrdinaryDiffEqImplicitAlgorithm) = true
29-
is_implicit(::ODE.OrdinaryDiffEqAdaptiveImplicitAlgorithm) = true
30-
is_implicit(ode_algo) = is_imex_CTS_algo(ode_algo)
31-
32-
is_rosenbrock(::ODE.Rosenbrock23) = true
33-
is_rosenbrock(::ODE.Rosenbrock32) = true
34-
is_rosenbrock(::SciMLBase.AbstractODEAlgorithm) = false
35-
use_transform(ode_algo) =
36-
!(is_imex_CTS_algo(ode_algo) || is_rosenbrock(ode_algo))
13+
use_transform(ode_algo) = !is_imex_CTS_algo(ode_algo)
3714

3815
function jac_kwargs(ode_algo, Y, jacobi_flags)
39-
if is_implicit(ode_algo)
16+
if is_imex_CTS_algo(ode_algo)
4017
W = SchurComplementW(Y, use_transform(ode_algo), jacobi_flags)
4118
if use_transform(ode_algo)
4219
return (; jac_prototype = W, Wfact_t = Wfact!)
@@ -57,32 +34,17 @@ function ode_configuration(
5734
ode_name = split(ode_name, ".")[end]
5835
end
5936
ode_sym = Symbol(ode_name)
60-
alg_or_tableau = if hasproperty(ODE, ode_sym)
61-
@warn "apply_limiter flag is ignored for OrdinaryDiffEq algorithms"
62-
getproperty(ODE, ode_sym)
63-
else
64-
getproperty(CTS, ode_sym)
65-
end
37+
alg_or_tableau = getproperty(CTS, ode_sym)
6638
@info "Using ODE config: `$alg_or_tableau`"
6739

6840
if is_explicit_CTS_algo_type(alg_or_tableau)
6941
return CTS.ExplicitAlgorithm(alg_or_tableau())
70-
elseif !is_implicit_type(alg_or_tableau)
42+
elseif !is_imex_CTS_algo_type(alg_or_tableau)
7143
return alg_or_tableau()
72-
elseif is_ordinary_diffeq_newton(alg_or_tableau)
73-
if max_newton_iters == 1
74-
error("OridinaryDiffEq requires at least 2 Newton iterations")
75-
end
76-
# κ like a relative tolerance; its default value in ODE is 0.01
77-
nlsolve = ODE.NLNewton(;
78-
κ = max_newton_iters == 2 ? Inf : 0.01,
79-
max_iter = max_newton_iters,
80-
)
81-
return alg_or_tableau(; linsolve = linsolve!, nlsolve)
8244
elseif is_imex_CTS_algo_type(alg_or_tableau)
8345
newtons_method = CTS.NewtonsMethod(; max_iters = max_newton_iters)
8446
return CTS.IMEXAlgorithm(alg_or_tableau(), newtons_method)
8547
else
86-
return alg_or_tableau(; linsolve = linsolve!)
48+
error("Uncaught case")
8749
end
8850
end
Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
1-
using OrdinaryDiffEq:
2-
AbstractNLSolver,
3-
isnewton,
4-
DIRK,
5-
update_W!,
6-
initialize!,
7-
Divergence,
8-
get_new_W!,
9-
initial_η,
10-
compute_step!,
11-
apply_step!,
12-
Convergence,
13-
isJcurrent,
14-
postamble!,
15-
TryAgain
161
using SciMLBase: RECOMPILE_BY_DEFAULT
172

18-
import OrdinaryDiffEq: nlsolve!
193
import SciMLBase: SplitFunction
204

215
#=
@@ -40,90 +24,3 @@ function SplitFunction{iip}(f1, f2; kwargs...) where {iip}
4024
tgrad = f1.tgrad,
4125
)
4226
end
43-
44-
#=
45-
Issue: nlsolve! has a goto statement that restarts the solver when the
46-
conditions for DiffEqBase.SlowConvergence (denoted by TryAgain) are
47-
satisfied. These conditions include !isJcurrent, which is always true
48-
when a custom Wfact or Wfact_t is used because of how calc_W! is written.
49-
So, when a custom Wfact or Wfact_t is used, nlsolve! sometimes enters an
50-
infinite loop (though there are also situations where it converges after
51-
several iterations of the loop). This is probably not the intended
52-
behavior, so this patch limits the number of loop iterations to 100,
53-
after which divergence is declared.
54-
=#
55-
function nlsolve!(
56-
nlsolver::AbstractNLSolver,
57-
integrator,
58-
cache = nothing,
59-
repeat_step = false,
60-
)
61-
num_redos = 0
62-
@label REDO
63-
if isnewton(nlsolver)
64-
cache === nothing && throw(
65-
ArgumentError(
66-
"cache is not passed to `nlsolve!` when using NLNewton",
67-
),
68-
)
69-
if nlsolver.method === DIRK
70-
γW = nlsolver.γ * integrator.dt
71-
else
72-
γW = nlsolver.γ * integrator.dt / nlsolver.α
73-
end
74-
update_W!(nlsolver, integrator, cache, γW, repeat_step)
75-
end
76-
77-
(; maxiters, κ, fast_convergence_cutoff) = nlsolver
78-
79-
initialize!(nlsolver, integrator)
80-
nlsolver.status = Divergence
81-
η = get_new_W!(nlsolver) ? initial_η(nlsolver, integrator) : nlsolver.ηold
82-
83-
local ndz
84-
for iter in 1:maxiters
85-
nlsolver.iter = iter
86-
87-
# compute next step and calculate norm of residuals
88-
iter > 1 && (ndzprev = ndz)
89-
ndz = compute_step!(nlsolver, integrator)
90-
if !isfinite(ndz)
91-
nlsolver.status = Divergence
92-
break
93-
end
94-
95-
# check divergence (not in initial step)
96-
if iter > 1
97-
θ = ndz / ndzprev
98-
99-
# divergence
100-
if θ > 2
101-
nlsolver.status = Divergence
102-
break
103-
end
104-
end
105-
106-
apply_step!(nlsolver, integrator)
107-
108-
# check for convergence
109-
iter > 1 &&= θ / (1 - θ))
110-
if (iter == 1 && ndz < 1e-5) ||
111-
(iter > 1 &&>= zero(η) && η * ndz < κ))
112-
nlsolver.status = Convergence
113-
break
114-
end
115-
end
116-
117-
if isnewton(nlsolver) &&
118-
nlsolver.status == Divergence &&
119-
!isJcurrent(nlsolver, integrator)
120-
num_redos += 1
121-
if num_redos < 100
122-
nlsolver.status = TryAgain
123-
@goto REDO
124-
end
125-
end
126-
127-
nlsolver.ηold = η
128-
postamble!(nlsolver, integrator)
129-
end

perf/Project.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
2020
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
2121
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
2222
NVTX = "5da4648a-3479-48b8-97b9-01cb529c0a1f"
23-
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
2423
PProf = "e4faabce-9ead-11e9-39d9-4379958e3056"
2524
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
2625
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
@@ -37,7 +36,6 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3736
URIs = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
3837

3938
[compat]
40-
OrdinaryDiffEq = "6"
4139
Plots = "1"
4240
SciMLBase = "1, 2"
4341
SnoopCompileCore = "2"

0 commit comments

Comments
 (0)