# Evaluating the rhs of ODE

**URL:** <https://discourse.julialang.org/t/evaluating-the-rhs-of-ode/61144>\
**Category:** New to Julia\
**Tags:** diffeq, ode\
**Created:** [May 14, 2021, 11:16am UTC](https://discourse.julialang.org/t/evaluating-the-rhs-of-ode/61144 "2021-05-14T11:16:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chilperic](https://avatars.discourse-cdn.com/v4/letter/c/8e7dd6/32.png) [@Chilperic](https://discourse.julialang.org/u/Chilperic)\
**Post date:** [May 14, 2021, 11:16am UTC](https://discourse.julialang.org/t/evaluating-the-rhs-of-ode/61144/1 "2021-05-14T11:16:06Z")

</div>

Hi!

I am a beginner with Julia, just a week since I started learning Julia. I am having an issue with evaluating the rhs of a big ODE with 46 variables and more than a hundred parameters. The ODE was originally written in Mathematica and I translated it in Python, I am ending up having a numerical issue with the integration. So to debug the code I want to compare rhs of Python vs Julia. Indeed the Mathematica version was quickly translated in Julia and the integration works just fine.

Here is the link for the code

> **[Chilperic Armel Foko / Model Julia · GitLab](https://gitlab.com/chilperic/model-julia)**
>
> GitLab.com

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [May 14, 2021, 11:31am UTC](https://discourse.julialang.org/t/evaluating-the-rhs-of-ode/61144/2 "2021-05-14T11:31:21Z")

</div>

That all sounds pretty good up to this point, what’s the issue?

---

<div class="post-metadata">

**Author:** ![Chilperic](https://avatars.discourse-cdn.com/v4/letter/c/8e7dd6/32.png) [@Chilperic](https://discourse.julialang.org/u/Chilperic)\
**Post date:** [May 14, 2021, 11:57am UTC](https://discourse.julialang.org/t/evaluating-the-rhs-of-ode/61144/3 "2021-05-14T11:57:57Z")

</div>

The issue is that I don’t know how to pass the vector of the variables to the rhs of the ODE to evaluate it.

---

<div class="post-metadata">

**Author:** ![zdenek\_hurak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zdenek_hurak/32/53118_2.png) [@zdenek\_hurak](https://discourse.julialang.org/u/zdenek_hurak)\
**Post date:** [May 14, 2021, 12:39pm UTC](https://discourse.julialang.org/t/evaluating-the-rhs-of-ode/61144/4 "2021-05-14T12:39:54Z")

</div>

Isn’t it possible to come up with some (really) [minimal working example (MWE)](https://en.wikipedia.org/wiki/Minimal_working_example)? Perhaps it is possible to describe your problem with something as simple as a solution to the “hello-world” differential equation \dot x(t) = -5x(t).

---

<div class="post-metadata">

**Author:** ![Chilperic](https://avatars.discourse-cdn.com/v4/letter/c/8e7dd6/32.png) [@Chilperic](https://discourse.julialang.org/u/Chilperic)\
**Post date:** [May 14, 2021, 1:05pm UTC](https://discourse.julialang.org/t/evaluating-the-rhs-of-ode/61144/5 "2021-05-14T13:05:01Z")

</div>

Here is the code [Chilperic Armel Foko / Model Julia · GitLab](https://gitlab.com/chilperic/model-julia)

---

<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, 2021, 1:28pm UTC](https://discourse.julialang.org/t/evaluating-the-rhs-of-ode/61144/6 "2021-05-14T13:28:21Z")

</div>

Whatever is flagging your posts is a false positive. I’ll say sorry for the community and the mods should help this out.

It looks like you’re using ModelingToolkit.jl. What you’re looking for is:

[https://mtk.sciml.ai/dev/systems/ODESystem/#SciMLBase.ODEFunction](https://mtk.sciml.ai/dev/systems/ODESystem/#SciMLBase.ODEFunction)

It’ll create the standard DifferentialEquations.jl functions `f(u,p,t)` and `f(du,u,p,t)` where `u` follows the variable order of `states(sys)` and `p` follows the order of `parameters(sys)` (and as it shows, you can override the order if you please). Hopefully that helps.

---

<div class="post-metadata">

**Author:** ![Chilperic](https://avatars.discourse-cdn.com/v4/letter/c/8e7dd6/32.png) [@Chilperic](https://discourse.julialang.org/u/Chilperic)\
**Post date:** [May 14, 2021, 1:37pm UTC](https://discourse.julialang.org/t/evaluating-the-rhs-of-ode/61144/7 "2021-05-14T13:37:31Z")

</div>

Exactly it was I am using. The constructor does not allow me to evaluate the rhs

---

<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, 2021, 1:40pm UTC](https://discourse.julialang.org/t/evaluating-the-rhs-of-ode/61144/8 "2021-05-14T13:40:53Z")

</div>

If you use `ODEFunction(sys)` you’ll get the function.
