# What is the proper way to handle a discontinuity in Differential Equations?

**URL:** <https://discourse.julialang.org/t/what-is-the-proper-way-to-handle-a-discontinuity-in-differential-equations/84963>\
**Category:** Modelling & Simulations\
**Tags:** question, diffeq\
**Created:** [July 29, 2022, 7:13am UTC](https://discourse.julialang.org/t/what-is-the-proper-way-to-handle-a-discontinuity-in-differential-equations/84963 "2022-07-29T07:13:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ge0rges](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ge0rges/32/38357_2.png) [@Ge0rges](https://discourse.julialang.org/u/Ge0rges)\
**Post date:** [July 29, 2022, 7:13am UTC](https://discourse.julialang.org/t/what-is-the-proper-way-to-handle-a-discontinuity-in-differential-equations/84963/1 "2022-07-29T07:13:18Z")

</div>

Hello all,

I have a system of two differential equations that I am able to solve using `Rosenbrock23()`.

I now would like to model this system with one modification, where at time `t` I manually change the value of one of the differential equation results, causing a discontinuity.

I thought that simply passing `t` to d\_discontinuties would handle this, but I run out of iterations, or the solver produces very unusual results. I currently have it manually set up to solve from `0` to `t-1` then from `t` to `f` starting with values from `t-1`, but that does not seem like an elegant solution and I get the following error:

`┌ Warning: dt(-1.6e-9) <= dtmin(1.862645149230957e-9) at t=1.059225e7. Aborting. There is either an error in your model specification or the true solution is unstable.`

Any tips for the proper way to handle this? My equations are stiff.

---

<div class="post-metadata">

**Author:** ![Ge0rges](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ge0rges/32/38357_2.png) [@Ge0rges](https://discourse.julialang.org/u/Ge0rges)\
**Post date:** [July 29, 2022, 7:34am UTC](https://discourse.julialang.org/t/what-is-the-proper-way-to-handle-a-discontinuity-in-differential-equations/84963/2 "2022-07-29T07:34:00Z")

</div>

See `DiscreteCallback` example. [Event Handling and Callback Functions · DifferentialEquations.jl](https://diffeq.sciml.ai/stable/features/callback_functions/#DiscreteCallback-Examples)

---

<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:** [July 29, 2022, 12:24pm UTC](https://discourse.julialang.org/t/what-is-the-proper-way-to-handle-a-discontinuity-in-differential-equations/84963/3 "2022-07-29T12:24:38Z")

</div>

Can you share your code? It seems like a very standard PresetTimeCallback use case?
