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

Manually reject step from ODE function with adaptive step solvers #210

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

slishak
Copy link
Contributor

@slishak slishak commented Sep 1, 2022

For some ODE functions, there are certain feasible regions of state values, and states outside this region result in undefined derivatives. In this situation, it is helpful to be able to communicate to an adaptive solver that it should try a smaller step instead.

This PR adds a RejectStepError exception class that can be raised by an ODE function. If this happens, an adaptive step solver will reject the step and reduce the step size. If the step size is already at the minimum, the exception will be re-raised to avoid an infinite loop.

I've fixed the error ratio to 10 for the new step size calculation, but open to other ideas as this is somewhat arbitrary.

If you think this contribution is worth merging, I can add some documentation and tests.

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.

1 participant