Skip to content

Commit 041c442

Browse files
oscardssmithChrisRackauckas
authored andcommitted
prevent solvers from getting stuck at the same timepoint without giving an error
1 parent 4b086b6 commit 041c442

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/common_interface/solve.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,9 @@ function DiffEqBase.solve!(integrator::AbstractSundialsIntegrator; early_free =
14001400
integrator.userfun.p = integrator.p
14011401
solver_step(integrator, tstop)
14021402
integrator.t = first(integrator.tout)
1403+
if integrator.t == integrator.tprev
1404+
integrator.flag = -3
1405+
end
14031406
integrator.flag < 0 && break
14041407
handle_callbacks!(integrator) # this also updates the interpolation
14051408
integrator.flag < 0 && break

test/common_interface/ida.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,8 @@ sol = solve(prob, IDA(), initializealg = DumbInit())
112112
isapprox(only(sol.u[begin]), 1, rtol = 1e-3)
113113
# test that solve produced the right answer.
114114
isapprox(only(sol.u[end]), exp(1), rtol = 1e-3)
115+
116+
f_noconverge(out, du, u, p, t) = out .= [du[1]+u[1]/(t-1)]
117+
prob= DAEProblem(f, [1.], [1.], (0,2); differential_vars=[true])
118+
sol = solve(prob, IDA())
119+
@test !(sol.retcode in (ReturnCode.Success, ReturnCode.MaxIters)

0 commit comments

Comments
 (0)