DifferentialEquations Events

I want to simulate a hybrid system with many different parameters. They all have the same event function but the location is dependent on the parameters given. Let’s say we have inverted pendulum and I want to give a reverse rotation at some different angles(parameter). For one pendulum, event condition is like

cond(u,t,integ) = abs(u[1]) - integ.p

For many pendulum, one may do

cond(u,t,integ, ith) = abs(u[ith, 1]) - integ.p[ith]

and add as many callbacks as there are pendulums. However, although this same calculations over many pendulums(1000 or up maybe) can be done in vectorized form, the separate callbacks cannot do them in vectorized form (I think). Is there a way that we can return an array from the event condition and get which entries are up(down)-crosses in the affect! function? Or is there an API to follow for ourselves to define such callbacks?

It’s something we are currently missing, and would be a good thing to implement sooner rather than later. You can track this here: Vector of crossing functions for condition/affect! · Issue #331 · SciML/DifferentialEquations.jl · GitHub

Thanks for reply. Because of separate callbacks, I also get multiple events at the same time error that may happen and, in fact, I have to handle many events at the same time. Is there a pointer where to start that I might help get it faster?

Right now you’d need to write a DiscreteCallback that does your own rootfinding. It’s an unfortunate situation and instead of writing a detailed hack here I’d rather get work done and hopefully get this implemented.