SciML / SteadyStateDiffEq.jl

Solvers for steady states in scientific machine learning (SciML)
Other
30 stars 22 forks source link

Add tspan option to DynamicSS #8

Closed tkf closed 5 years ago

tkf commented 5 years ago

You can limit the solver by maxiters but sometimes it's handy to stop it via the simulated time tspan.

tkf commented 5 years ago

If we go with :Terminated return code https://github.com/JuliaDiffEq/SteadyStateDiffEq.jl/pull/8#discussion_r226174375, I guess we can do something like the following.

In DiffEqBase, define:

function __terminate! end

function terminate!(integrator)
  __terminate!(integrator)
  integrator.sol = solution_new_retcode(integrator.sol, :Terminated)
end

In OrdinaryDiffEq, define __terminate! instead of terminate! (and similar in Sundials):

function DiffEqBase.__terminate!(integrator::ODEIntegrator)
  integrator.opts.tstops.valtree = typeof(integrator.opts.tstops.valtree)()
end

Also, maybe define a simple function so that it's easy to support compatibility for common cases:

iserror(sol) = !(sol.retcode in (:Success, :Terminated))
ChrisRackauckas commented 5 years ago

Honestly I think the return codes should be enums, so if we redo them we should go all the way there.

tkf commented 5 years ago

Yeees! enum retcode would be really nice.

ChrisRackauckas commented 5 years ago

I'll merge when tests pass. But the retcode changes of adding a terminate and changing to enums is something that should get followup when we have time.

ChrisRackauckas commented 5 years ago

This should get docs