# Callback of DiffEq detecting "whether a certain condition has been satisfied for a given duration"

**URL:** <https://discourse.julialang.org/t/callback-of-diffeq-detecting-whether-a-certain-condition-has-been-satisfied-for-a-given-duration/63433>\
**Category:** New to Julia\
**Created:** [June 23, 2021, 10:25am UTC](https://discourse.julialang.org/t/callback-of-diffeq-detecting-whether-a-certain-condition-has-been-satisfied-for-a-given-duration/63433 "2021-06-23T10:25:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![iHany](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihany/32/18151_2.png) [@iHany](https://discourse.julialang.org/u/iHany)\
**Post date:** [June 23, 2021, 10:25am UTC](https://discourse.julialang.org/t/callback-of-diffeq-detecting-whether-a-certain-condition-has-been-satisfied-for-a-given-duration/63433/1 "2021-06-23T10:25:48Z")

</div>

Hi,

is it possible in DifferentialEquations.jl to detect whether a certain condition has been satisfied for a given time duration?

---

<div class="post-metadata">

**Author:** ![SteffenPL](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/steffenpl/32/206270_2.png) [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)\
**Post date:** [June 23, 2021, 10:40am UTC](https://discourse.julialang.org/t/callback-of-diffeq-detecting-whether-a-certain-condition-has-been-satisfied-for-a-given-duration/63433/2 "2021-06-23T10:40:36Z")

</div>

I’m no expert. I also cannot find a ready-made solution. Maybe you could do it yourself similar to this:

> <https://github.com/SciML/DiffEqCallbacks.jl/blob/master/src/autoabstol.jl>

Where instead of `p.curmax` you somehow store how long the condition is active already.

---

<div class="post-metadata">

**Author:** ![iHany](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihany/32/18151_2.png) [@iHany](https://discourse.julialang.org/u/iHany)\
**Post date:** [June 23, 2021, 2:22pm UTC](https://discourse.julialang.org/t/callback-of-diffeq-detecting-whether-a-certain-condition-has-been-satisfied-for-a-given-duration/63433/3 "2021-06-23T14:22:33Z")

</div>

It seems that there is no direct solution provided from DiffEq.jl.  
Thanks a lot 🙂
