Skip to content

Commit

Permalink
Merge pull request #213 from SciML/ChrisRackauckas-patch-1
Browse files Browse the repository at this point in the history
Hotfix: allow presettime callback on integrators without a dt
  • Loading branch information
ChrisRackauckas authored Apr 1, 2024
2 parents 6f2f07c + 50a240f commit 73255e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ NonlinearSolve = "3.7.2"
ODEProblemLibrary = "0.1.5"
OrdinaryDiffEq = "6.68"
Parameters = "0.12"
QuadGK = "2.4"
QuadGK = "2.9"
RecipesBase = "1.3.4"
RecursiveArrayTools = "3.9"
SciMLBase = "2.26"
Expand Down
12 changes: 10 additions & 2 deletions src/preset_time.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,19 @@ function PresetTimeCallback(tstops, user_affect!;
tstops = sort(tstops)
end
condition = function (u, t, integrator)
insorted(t, tstops) && (integrator.t - integrator.dt) != integrator.t
if hasproperty(integrator, :dt)
insorted(t, tstops) && (integrator.t - integrator.dt) != integrator.t
else
insorted(t, tstops)
end
end
elseif tstops isa Number
condition = function (u, t, integrator)
t == tstops && (integrator.t - integrator.dt) != integrator.t
if hasproperty(integrator, :dt)
t == tstops && (integrator.t - integrator.dt) != integrator.t
else
t == tstops
end
end
else
throw(ArgumentError("tstops must either be a number or a Vector. Was $tstops"))
Expand Down

0 comments on commit 73255e6

Please sign in to comment.