Skip to content
Snippets Groups Projects
Commit 29c18756 authored by Brian Groenke's avatar Brian Groenke
Browse files

Fix dispatch issues with CFL callback

parent 8274ff57
No related branches found
No related tags found
1 merge request!36Fix CFL step limiter callback choking on autodiff types
......@@ -50,6 +50,7 @@ p.soil.n .= 2.0
p.soil.Tₘ .= 273.15 # K
# CryoGrid front-end for ODEProblem
prob = CryoGridProblem(model,tspan,p)
# OPTIONAL: solve for short time period to
# solve with forward Euler (w/ CFL) and construct CryoGridOutput from solution
out = @time solve(prob, Euler(), dt=2*60.0, callback=CFLStepLimiter(model), saveat=24*3600.0, progress=true) |> CryoGridOutput;
# Plot it!
......
......@@ -4,6 +4,7 @@ import CryoGrid
using CryoGrid.Numerics
using CryoGrid.Setup: CryoGridSetup, HeatOnlySetup, getvar
using CryoGrid.Utils
using DiffEqCallbacks
......
......@@ -2,7 +2,7 @@ struct CFLHeatState{A}
Δt::A
default_dt::Float64
end
function (fn::CryoGridCallbackFunction{CFLHeatState{<:AbstractArray}})(u,p,t)
function (fn::CryoGridCallbackFunction{<:CFLHeatState{<:AbstractArray}})(u,p,t)
let Δt = fn.state.Δt,
Δx = Δ(fn.setup.grid),
Ceff = getvar(:Ceff, fn.setup, u), # apparent heat capacity
......@@ -12,7 +12,7 @@ function (fn::CryoGridCallbackFunction{CFLHeatState{<:AbstractArray}})(u,p,t)
IfElse.ifelse(isfinite(Δt_min), Δt_min, fn.default_dt)
end
end
function (fn::CryoGridCallbackFunction{CFLHeatState{Nothing}})(u,p,t)
function (fn::CryoGridCallbackFunction{<:CFLHeatState{Nothing}})(u,p,t)
let Δx = Δ(fn.setup.grid),
Ceff = getvar(:Ceff, fn.setup, u), # apparent heat capacity
kc = getvar(:kc, fn.setup, u); # thermal cond. at grid centers
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment