So I’ve figured out how to make a simulation of the life-stages of some hypothetical model organism in R. I can use “N” as the number of life-stages, the number of differential equations to be solved, during each simulation. However, I would love to implement something much faster in Julia. In R, it’s somewhat convenient because I only have to put the first equation in explicitly and then R formulates the other differential equations depending upon my choice of N for that run of the simulation. The simulations as they are now take about 1.5 hours to run with moderate time-step, with smaller time-steps (which I’d prefer in my experiments) the sims take about 9 hours to run. Since the equation terms depend upon how many equations there are in total for each simulation, I’m having trouble figuring out how to form up a function in Julia. As in, how do I “tell” Julia, the first equation is solved, then the second, then the N-th.

You can use a loop. Or maybe make use of a tool like https://github.com/JuliaDiffEq/ModelingToolkit.jl

Thanks for your very fast reply! I was able, in an hour, to sit down and code for some simple versions of my model, where there’s 2,3 or 5 equations. Julia runs fast! I definitely am coming around…

3 Likes