I look for a book/manual where I can find implementations of different integration schemes for ordinary differential equations (like 4-th order Runge-Kutta) in Python with Numba.
To be more specific, let me provide some details and background. In my research I deal with a system of coupled non-linear differential equations that looks like $$\frac{dx_i}{dt}=F(g,x_i(t),x_j(t)),$$ where $F$ is non-linear function, $g$ is the parameter and there are $N$ equations. My goal is to obtain the solutions $x_i=x_i(t)$ on the interval $[0,T]$ for all the parameter values from the interval $[g_1,g_2]$ as fast as possible and easily perform basic mathematical manipulations with values $x_i(t=T)$.
Now background:
- Currently I use Wolfram Mathematica built-in
NDSolve
andNDSolveValue
functions and use parallelization (Parallelize
,ParallelTable
). I see that the performance is not good enough for values $N>1000$ - Recently I have known that it seems possible to improve performance in Mathematica: one can implement integration scheme by hand and next use
Compile
(it is quite similar to byte-code compilation, as I understand) and/or use C++ compilation. For me, this program is desirable but I cast some doubts.
These doubts come from the fact that I can use my GPU with CUDA (it is quite "small" card, NVIDIA GTX 1050) and try to improve performance. Next, I am not sure that built-in functions and any manipulations with compilation in Wolfram Mathematica will be faster than another programming language.
From other programming languages, the appropriate choice for me is Python. I know the following opportunities in Python:
odeint
fromscipy
torchdiffeq
packagediffeqpy
that operates withJulia
numba
in order to wrapnumpy
-code and make it more fast
So, my ultimate question is:
- What is the fastest tool for the stated problem:
torchdiffeq
ordiffeqpy
or combinationnumpy
+numba
(where integration scheme is written by hand)? - Does this fastest tool allow me to run my code at cluster/server (in future, now I have only my laptop)?
diffeqpy
will likely win. It does a code transformation to a complete julia script, compiles that and executes it. Selecting the recommended methods depending on the stiffness should give code that could be faster than even other compiled code. Depending on what $x_j$ in $\dot x_i=F(g,x_i,x_j)$ means, your system could have structure, at least sparseness, that can be fully used in the Julia context. $\endgroup$