-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
Event and PIDController: event doesn't always occure #507
Comments
This is a classical problem with event handling. Some ODE solvers attempt to reduce the impact of this by evaluating the event function e.g. 10 times every step, equally spaced apart. (You can still get the same issue of course, it just has to occur at a smaller resolution. As such Diffrax doesn't do this.) I recommend picking an event function that changes sign only once in your region of integration. Unfortunately there's no smarter way to handle this in general. |
Thank you for your quick answer. After I meet my issue, I realize that, if nothing was done in the solver part, the event will not always detect. I am not familiar with the event ode litterature, but I think that some author demonstrate some guaranties to detect the event for modern solver with fixed time such "Shampine, L. F., & Thompson, S. (2001). Event location for ordinary differential equations. Computers & Mathematics with Applications, 42(1-2), 85-93." Other reference: Reliable solution of special event location problems for ODEs For my understanding, they modify the original ode systems (it was my intuition) to obtain guaranties. The modification is quiet obvious by introducing the total derivative of the event function I think if diffrax doesn't integrate this kind of technics, it could be described in the documention. Because, at first when I don't know this issue, I was thinking that the error of detection will be related to the error of the ode solver and that diffrax manages that. |
Right, so this is a nice idea! It 'slows down' the integration to match the rate at which the event function varies. Unfortunately this requires that the event funtion be real-valued and differentiable. Neither of these things are necessarily true in the general case that we support in Diffrax. That said I could see us perhaps adding something like an |
First, I want to thank you for your amazing library. You have done a massive work which are very useful for my research.
diffrax 0.6.0
optimistix 0.0.7
jax 0.4.30
When using PID controler and Event functionnality are used simultaneously, I found that the event will not always raised due to the difference of complexity between the event function and the ode function. For example, If the ode function si very simple (straight line), the pid controler will allow to have large steps. Large step can miss the event condition if there is two changes of signs between this two steps.
To avoid this issue, I found that integrate the event condition in the ode function can correct the issue in my particular usecase. Is there a more mathematical grounded method to resolve this issue?
A small python example:
The text was updated successfully, but these errors were encountered: