Skip to content

Commit

Permalink
fix DynamicSS output
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Jul 6, 2019
1 parent 53aa6ff commit 67417e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
25 changes: 12 additions & 13 deletions src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,18 @@ function DiffEqBase.__solve(prob::DiffEqBase.AbstractSteadyStateProblem,
sol = solve(_prob,alg.alg,args...;kwargs...,
callback=TerminateSteadyState(alg.abstol,alg.reltol),
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) =
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 sol.retcode == :Terminated && all(abs(d) <= abstol ||
abs(d) <= reltol*abs(u) for (d,abstol, reltol, u) in
zip(du, Iterators.cycle(alg.abstol), Iterators.cycle(alg.reltol), sol.u[end]))
sol = DiffEqBase.solution_new_retcode(sol, :Success)
end
_sol = DiffEqBase.build_solution(prob,alg,sol.u[end],du;retcode = :Success)
else
_sol = DiffEqBase.build_solution(prob,alg,sol.u[end],du;retcode = :Failure)
end
sol
_sol
end
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using OrdinaryDiffEq
sol = solve(prob,DynamicSS(Rodas5()))
@test sol.retcode == :Success

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

sol = solve(prob,DynamicSS(Rodas5(),tspan=1e-3))
Expand All @@ -43,5 +43,5 @@ sol = solve(prob,DynamicSS(Rodas5(),tspan=1e-3))
sol = solve(prob,DynamicSS(CVODE_BDF()),dt=1.0)
@test sol.retcode == :Success

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

0 comments on commit 67417e3

Please sign in to comment.