# DifferentialEquations Events

**URL:** https://discourse.julialang.org/t/differentialequations-events/24393
**Category:** Specific Domains
**Tags:** diffeq
**Created:** [May 20, 2019, 9:08am UTC](https://discourse.julialang.org/t/differentialequations-events/24393 "2019-05-20T09:08:11Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![tomaklutfu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomaklutfu/32/2411_2.png) [@tomaklutfu](https://discourse.julialang.org/u/tomaklutfu)
#### Post date: [May 20, 2019, 9:08am UTC](https://discourse.julialang.org/t/differentialequations-events/24393/1 "2019-05-20T09:08:11Z")

</div>

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

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

```

For many pendulum, one may do

```julia
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?

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [May 20, 2019, 9:57am UTC](https://discourse.julialang.org/t/differentialequations-events/24393/2 "2019-05-20T09:57:20Z")

</div>

> [@tomaklutfu](#):
>
> 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](https://github.com/JuliaDiffEq/DifferentialEquations.jl/issues/331)

---

<div class="post-metadata">

### Author: ![tomaklutfu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomaklutfu/32/2411_2.png) [@tomaklutfu](https://discourse.julialang.org/u/tomaklutfu)
#### Post date: [May 20, 2019, 10:33am UTC](https://discourse.julialang.org/t/differentialequations-events/24393/3 "2019-05-20T10:33:24Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [May 20, 2019, 10:34am UTC](https://discourse.julialang.org/t/differentialequations-events/24393/4 "2019-05-20T10:34:53Z")

</div>

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.
