Skip to content

Commit

Permalink
Merge pull request #13 from benneti/master
Browse files Browse the repository at this point in the history
return success if steady state is reached for DynamicSS
  • Loading branch information
ChrisRackauckas authored Jun 21, 2019
2 parents cb1e42b + 01f8c7f commit 2b2decc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ function DiffEqBase.__solve(prob::DiffEqBase.AbstractSteadyStateProblem,
save_everystep=save_everystep,save_start=save_start)
if sol.t[end] == _prob.tspan[end]
sol = DiffEqBase.solution_new_retcode(sol, :Failure)
elseif sol.retcode == :Terminated
if isinplace(prob)
du = similar(sol.u[end])
prob.f(du, sol.u[end], prob.p, sol.t[end])
else
du = prob.f(sol.u[end], prob.p, sol.t[end])
end
if all(abs(d) <= abstol || abs(d) <= reltol*abs(u) for (d,abstol, reltol, u) =
zip(du, Iterators.cycle(alg.abstol), Iterators.cycle(alg.reltol), sol.u[end]))
sol = DiffEqBase.solution_new_retcode(sol, :Success)
end
end
sol
end
6 changes: 3 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ f(du,sol.u,nothing,0)

using OrdinaryDiffEq
sol = solve(prob,DynamicSS(Rodas5()))
@test sol.retcode == :Terminated
@test sol.retcode == :Success

f(du,sol.u[end],p,0)
@test du [0,0] atol = 1e-7

sol = solve(prob,DynamicSS(Rodas5(),tspan=1e-3))
@test sol.retcode != :Terminated
@test sol.retcode != :Success

sol = solve(prob,DynamicSS(CVODE_BDF()),dt=1.0)
@test sol.retcode == :Terminated
@test sol.retcode == :Success

f(du,sol.u[end],p,0)
@test du [0,0] atol = 1e-6

0 comments on commit 2b2decc

Please sign in to comment.