# Is there a way to customize retcodes for different callback functions using DifferentialEquations?

**URL:** <https://discourse.julialang.org/t/is-there-a-way-to-customize-retcodes-for-different-callback-functions-using-differentialequations/81051>\
**Category:** General Usage\
**Tags:** differentialequation\
**Created:** [May 14, 2022, 8:28am UTC](https://discourse.julialang.org/t/is-there-a-way-to-customize-retcodes-for-different-callback-functions-using-differentialequations/81051 "2022-05-14T08:28:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fsyhantis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fsyhantis/32/19686_2.png) [@fsyhantis](https://discourse.julialang.org/u/fsyhantis)\
**Post date:** [May 14, 2022, 8:28am UTC](https://discourse.julialang.org/t/is-there-a-way-to-customize-retcodes-for-different-callback-functions-using-differentialequations/81051/1 "2022-05-14T08:28:48Z")

</div>

I’m trying to solve odes using the package DifferentialEquations.

The odes are constrained by several conditions.

The solutions are terminated by different conditions.

How should I determine the specific condition (cond1 or cond2) for later analyses?

> Blockquote  
> func = ODEFunction(func!, jac=jac\_λ!)  
> prob = ODEProblem(func, u0, span, p)  
> condition(u, t, integrator) = cond\_1(u,t) || cond\_2(u,t)  
> affect!(integrator) = terminate!(integrator)  
> cb = DiscreteCallback(condition, affect!)  
> solve(prob; callback=cb)

---

<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 14, 2022, 8:45am UTC](https://discourse.julialang.org/t/is-there-a-way-to-customize-retcodes-for-different-callback-functions-using-differentialequations/81051/2 "2022-05-14T08:45:49Z")

</div>

> [@fsyhantis](#):
>
> How should I determine the specific condition (cond1 or cond2) for later analyses?

you could have a parameter that is mutated as a signifier for it. But no, you cannot reliably set the retcode.
