Combining ContinuousCallback and DiscreteCallback in solving ODEProblem (DifferentialEquations)

Is it possible to combine ContinuousCallback and DiscreteCallback while solving ODEProblem? While the former checks if some real quantity attains a zero value, checking a simultaneous satisfaction of some additional logical/boolean constraint with the help the latter can be useful.

As an example, consider the bouncing ball example in the documentation. Can we add an additional condition for hitting the ground that would require that the vertical component of the ball velocity is negative (the ball is falling)? Perhaps it is redundant in this case (well, is it really guaranteed that during the ā€œbouncing backā€ phase only a single crossing through zero is detected?) but in some other examples (of hybrid system) is can be necessary to condition triggering of some callback by an additional boolean condition.

Yes, just use a callback set. Thatā€™s in one of the tutorials:

https://tutorials.sciml.ai/html/introduction/04-callbacks_and_events.html

1 Like