Skip to content

Commit e192c08

Browse files
committed
Fix precompilation errors from OrdinaryDiffEq
1 parent 4ea9ee5 commit e192c08

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

examples/heat_freeW_samoylov.jl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ soilprofile = SoilProfile(
2626
initT = initializer(:T, CryoGrid.SamoylovDefault.tempprofile);
2727

2828
# We choose the default grid discretization with 5 cm spacing at the surface.
29-
grid = CryoGrid.DefaultGrid_5cm;
29+
grid = CryoGrid.DefaultGrid_10cm;
3030

3131
# Now we construct the Tile using the built-in model configuration `SoilHeatTile` which defines a
3232
# standalone soil straigraphy with only heat conduction and no water flow.
@@ -41,20 +41,25 @@ tile = CryoGrid.SoilHeatTile(
4141
);
4242

4343
# Here we define the time span:
44-
tspan = (DateTime(2010,12,31),DateTime(2011,12,31));
44+
tspan = (DateTime(2010,12,31),DateTime(2012,12,31));
4545

4646
# Evaluate the initial condition
4747
u0, du0 = initialcondition!(tile, tspan);
4848

4949
# Here we construct a CryoGridProblem with tile, initial condition, and timespan.
50-
prob = CryoGridProblem(tile, u0, tspan, saveat=24*3600.0, savevars=(:T,));
50+
prob = CryoGridProblem(tile, u0, tspan, saveat=24*3600.0, savevars=(:T,), step_limiter=nothing);
5151

5252
# Solve the configured problem with the built-in forward Euler method.
5353
# note that, due to compile time, this may take 1-2 minutes when executed in a fresh Julia
5454
# session. Subsequent solves will be much faster.
55-
sol = @time solve(prob);
55+
sol = @time solve(prob, Euler(), dt=900.0);
5656
out = CryoGridOutput(sol)
5757

58+
dts = []
59+
for integrator in init(prob, Euler(), dt=900.0)
60+
push!(dts, integrator.dt)
61+
end
62+
5863
# Now we plot the reuslts!
5964
import Plots
6065
zs = [1,10,20,30,50,100,200,500,1000]u"cm"

src/Solvers/DiffEq/DiffEq.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ function __init__()
3838
# OrdinaryDiffEq compatibility
3939
@require OrdinaryDiffEq="1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" begin
4040
using .OrdinaryDiffEq
41-
using .OrdinaryDiffEq: NLSolver, OrdinaryDiffEqAlgorithm, DAEAlgorithm
41+
import .OrdinaryDiffEq.OrdinaryDiffEqNonlinearSolve: NLSolver, NLStatus, AbstractNLSolverAlgorithm, AbstractNLSolverCache, build_nlsolver
42+
import .OrdinaryDiffEq.OrdinaryDiffEqCore: OrdinaryDiffEqAlgorithm, DAEAlgorithm
4243
# re-export selected types from OrdinaryDiffEq;
4344
export OrdinaryDiffEq
4445
# explicit methods

src/Solvers/DiffEq/nlsolve/nlsolve.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Base type for custom nonlinear solver algorithms.
33
"""
4-
abstract type AbstractCryoGridNLSolverAlgorithm <: OrdinaryDiffEq.AbstractNLSolverAlgorithm end
4+
abstract type AbstractCryoGridNLSolverAlgorithm <: AbstractNLSolverAlgorithm end
55

66
kappa(::AbstractCryoGridNLSolverAlgorithm) = 1e-2
77

@@ -16,7 +16,7 @@ Constructs the nonlinear solver cache for `nlalg`.
1616
"""
1717
build_nlcache(::AbstractCryoGridNLSolverAlgorithm, f, u, p, t) = error("not implemented")
1818

19-
function OrdinaryDiffEq.build_nlsolver(
19+
function build_nlsolver(
2020
alg,
2121
nlalg::AbstractCryoGridNLSolverAlgorithm,
2222
u,
@@ -46,7 +46,7 @@ function OrdinaryDiffEq.build_nlsolver(
4646
ηold = one(t)
4747
NLSolver{true, tTypeNoUnits}(z, tmp, ztmp, γ, c, α, nlalg, kappa(nlalg),
4848
fast_convergence_cutoff(nlalg), ηold, 0, maxiters(nlalg),
49-
OrdinaryDiffEq.Divergence,
49+
NLStatus.Divergence,
5050
nlcache)
5151
end
5252

src/Solvers/DiffEq/nlsolve/nlsolve_cglite.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Base.@kwdef struct NLCGLite <: AbstractCryoGridNLSolverAlgorithm
55
check_div::Bool = false
66
end
77

8-
mutable struct NLCGLiteCache{Tu,Tt,Tcache} <: OrdinaryDiffEq.AbstractNLSolverCache
8+
mutable struct NLCGLiteCache{Tu,Tt,Tcache} <: AbstractNLSolverCache
99
ustep::Tu
1010
tstep::Tt
1111
innercache::Tcache
@@ -35,7 +35,7 @@ end
3535
# and is probably used by the adaptive timestepping algorithms.
3636
initial_η(nlsolver::NLSolver{<:NLCGLite}, integrator) = nlsolver.ηold
3737

38-
DiffEqBase.@muladd function OrdinaryDiffEq.initialize!(nlsolver::NLSolver{<:NLCGLite}, integrator::DiffEqBase.DEIntegrator)
38+
DiffEqBase.@muladd function initialize!(nlsolver::NLSolver{<:NLCGLite}, integrator::DiffEqBase.DEIntegrator)
3939
nlsolver.cache.tstep = integrator.t + nlsolver.c * integrator.dt
4040
copyto!(nlsolver.cache.innercache.uprev, nlsolver.tmp)
4141
# this won't work if u has units
@@ -44,7 +44,7 @@ DiffEqBase.@muladd function OrdinaryDiffEq.initialize!(nlsolver::NLSolver{<:NLCG
4444
return nothing
4545
end
4646

47-
DiffEqBase.@muladd function OrdinaryDiffEq.compute_step!(nlsolver::NLSolver{<:NLCGLite, true}, integrator)
47+
DiffEqBase.@muladd function compute_step!(nlsolver::NLSolver{<:NLCGLite, true}, integrator)
4848
@unpack p, dt = integrator
4949
@unpack z, tmp, ztmp, γ, α, cache = nlsolver
5050
@unpack ustep, tstep, innercache = cache

0 commit comments

Comments
 (0)