Evaluating the rhs of ODE

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

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

1 Like

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.

Isn’t it possible to come up with some (really) minimal working example (MWE)? 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).

Here is the code Chilperic Armel Foko / Model Julia · GitLab

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

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.

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

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

2 Likes