Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tspan option to DynamicSS #8

Merged
merged 4 commits into from
Oct 18, 2018
Merged

Conversation

tkf
Copy link
Contributor

@tkf tkf commented Oct 18, 2018

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

src/solve.jl Outdated
_prob = ODEProblem(prob.f,prob.u0,tspan,prob.p)
sol = solve(_prob,alg.alg,args...;kwargs...,
callback=TerminateSteadyState(alg.abstol,alg.reltol))
if sol.t[end] ≈ _prob.tspan[end]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel dumb to do this. Is = safer? (e.g., when u0 happened to be a steady state) Or we need a callback that sets a flag? Maybe it's better to have a :Terminated return code which is set by terminate!.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

== is safer. The handling should make this exact.

@tkf
Copy link
Contributor Author

tkf commented Oct 18, 2018

If we go with :Terminated return code #8 (comment), 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
Copy link
Member

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

@tkf
Copy link
Contributor Author

tkf commented Oct 18, 2018

Yeees! enum retcode would be really nice.

@ChrisRackauckas
Copy link
Member

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 ChrisRackauckas merged commit f3bf5ef into SciML:master Oct 18, 2018
@ChrisRackauckas
Copy link
Member

This should get docs

tkf added a commit to tkf/DiffEqDocs.jl that referenced this pull request Oct 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants