# DifferentialEquations sanity check

**URL:** <https://discourse.julialang.org/t/differentialequations-sanity-check/35517>\
**Category:** New to Julia\
**Created:** [March 4, 2020, 12:34pm UTC](https://discourse.julialang.org/t/differentialequations-sanity-check/35517 "2020-03-04T12:34:40Z")\
**Posts on this page:** 7\
**Page:** 1

<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:** [March 4, 2020, 12:34pm UTC](https://discourse.julialang.org/t/differentialequations-sanity-check/35517/1 "2020-03-04T12:34:40Z")

</div>

Hello,  
I have been using DifferentialEquations to try and model microbial interactions. In the first approach, I give some absolute concentrations of bacteria and phages (viruses of bacteria) and I get this figure:  
bacteria = 50000  
viruses = 80  
 ![absQuant](https://global.discourse-cdn.com/julialang/original/3X/3/1/31086493ba2ae1ae4351f73829fbfaee35a196b1.png)  
In a second approach, I give relative quantifications:  
bacteria = 1  
viruses = 0.0016  
 ![relQuant](https://global.discourse-cdn.com/julialang/original/3X/4/4/44794cf61fd0deec665cd5c456977e3b183084ae.png)  
I obtain the same identical figure (the difference in label position is due from changing loc=“best” to loc=“lower right”). So my question is: is there a way to assess the sanity of the result? How can be that both figures have the same y-axis values? The plots are slightly different on the x-axis, but is there a trick to be sure of the result?

---

<div class="post-metadata">

**Author:** ![briochemc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/briochemc/32/4209_2.png) [@briochemc](https://discourse.julialang.org/u/briochemc)\
**Post date:** [March 5, 2020, 2:24am UTC](https://discourse.julialang.org/t/differentialequations-sanity-check/35517/2 "2020-03-05T02:24:32Z")

</div>

I think a MWE would help but it just looks like you are just running two simulations with different initial values. The plots somewhat show a similar convergence but are different at the start (for time \< 100 h), right?

---

<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:** [March 6, 2020, 4:24pm UTC](https://discourse.julialang.org/t/differentialequations-sanity-check/35517/3 "2020-03-06T16:24:47Z")

</div>

Yes, it is the same simulation with different starting values. Does it make sense to have the same Y scale? How can I be sure that there is no flaw somewhere that I overlooked?.. Or simply the initial conditions are no so important as long as their ratio is maintained (as in this case). The difference between 50 000 and 1 is just a constant k and k\*0.0016=80, as expected.

---

<div class="post-metadata">

**Author:** ![briochemc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/briochemc/32/4209_2.png) [@briochemc](https://discourse.julialang.org/u/briochemc)\
**Post date:** [March 9, 2020, 6:12am UTC](https://discourse.julialang.org/t/differentialequations-sanity-check/35517/4 "2020-03-09T06:12:57Z")

</div>

> 

> [@Luigi\_Marongiu](#):
>
> Does it make sense to have the same Y scale? How can I be sure that there is no flaw somewhere that I overlooked?

I’m not sure but nothing here seems crazy to me. I don’t think that DifferentialEquations.jl has a bug that would manifest in your simulation. If you are scared that your simulation is not realistic then I can’t really help you without a minimal working example of code and explanation 🤷‍♂️

---

<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:** [March 9, 2020, 7:56am UTC](https://discourse.julialang.org/t/differentialequations-sanity-check/35517/5 "2020-03-09T07:56:27Z")

</div>

I did not think of a bug in DifferentialEquations, just wanted to know if there is a way to implement a sanity check on the results.

---

<div class="post-metadata">

**Author:** ![briochemc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/briochemc/32/4209_2.png) [@briochemc](https://discourse.julialang.org/u/briochemc)\
**Post date:** [March 9, 2020, 8:13am UTC](https://discourse.julialang.org/t/differentialequations-sanity-check/35517/6 "2020-03-09T08:13:13Z")

</div>

Well, you can probably do that but I cannot help you further without more information! Maybe check that the convergence equilibrium is a (unique?) steady-state solution? Or try to do normalize/[nondimensionalize](https://en.wikipedia.org/wiki/Nondimensionalization) your equations on paper?

---

<div class="post-metadata">

**Author:** ![John\_Gibson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/john_gibson/32/5321_2.png) [@John\_Gibson](https://discourse.julialang.org/u/John_Gibson)\
**Post date:** [March 9, 2020, 11:34am UTC](https://discourse.julialang.org/t/differentialequations-sanity-check/35517/7 "2020-03-09T11:34:15Z")

</div>

Best way to get a sanity check is to simulate a similar differential equation that has an analytic solution. Then compare the numerical answer to the analytic solution. If the two match and the numerical solution converges toward the analytic as dt → 0, then at least you know the library code is correct and you’re using and interpreting it correctly,. Your system looks like a 2d linear ODE with complex eigenvalues with negative real parts.
