# How to bring differential equations to wanted value with DiffEqFlux?

**URL:** <https://discourse.julialang.org/t/how-to-bring-differential-equations-to-wanted-value-with-diffeqflux/54167>\
**Category:** Numerics\
**Tags:** question\
**Created:** [January 29, 2021, 7:15am UTC](https://discourse.julialang.org/t/how-to-bring-differential-equations-to-wanted-value-with-diffeqflux/54167 "2021-01-29T07:15:55Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Post date:** [January 30, 2021, 11:02am UTC](https://discourse.julialang.org/t/how-to-bring-differential-equations-to-wanted-value-with-diffeqflux/54167/6 "2021-01-30T11:02:18Z")

</div>

Something weird happened. Until the day before yesterday, when I was introducing 200 million phages, the system went into a cyclic phase and then reached an equilibrium:

 ![treatment_8](https://global.discourse-cdn.com/julialang/original/3X/f/7/f7e33612790aa68d2f698091ef2f7775093ed1cb.png)  
Yesterday I ran this code:

```julia
parms = [mu, kappa, phi, omega, eta, beta, Vp]
# modification
condition1(u, t, integrator) = t==Tϕ
affect1!(integrator) = integrator.u[3] += integrator.p[7]
cb1 = DiscreteCallback(condition1, affect1!)
# extintion
condition2(u, t, integrator) = u[1]-1
function affect2!(integrator)
  integrator.u[1] = 0
  integrator.u[2] = 0
end
cb2 = ContinuousCallback(condition2, affect2!)
condition3(u, t, integrator) = u[3]-1
function affect3!(integrator)
  integrator.u[3] = 0
end
cb3 = ContinuousCallback(condition3, affect3!)
# run
modification = CallbackSet(cb1, cb2, cb3)
prob = ODEProblem(sir!, u0, tspan, parms)
soln = solve(prob, AutoVern7(Rodas5()), callback=modification, tstops=[Tp], sensealg=ForwardDiffSensitivity())

```

and, for the same amount I got the extinction:

 ![before](https://global.discourse-cdn.com/julialang/original/3X/b/8/b8b8373e3da744bfffceff42f3894df8925d1479.png)  
Since the amount inserted is the same, I thought the solver itself has changed. So, I closed Julia’s core and started a new session but the results are the same.  
What happened?  
Can the solver be reversed as it was?  
I think the question I have (found the amount of phage that extinguishes the bacterium) cannot be found mathematically, but from the [other post](https://discourse.julialang.org/t/how-to-bring-a-system-of-differential-equations-to-zero-with-differentialequations/53659/15) (obtained with the solver as it was) it can be seen that there must be an amount that triggers such extinction.  
So, I’ll rephrase the question: is there a computational savvy way to run the sir function in a loop providing different Vp?  
Thanks

---

_[View the full topic](https://discourse.julialang.org/t/how-to-bring-differential-equations-to-wanted-value-with-diffeqflux/54167)._
