I am writing an ODE model that describes the positions of a system of N interacting particles living in a 2D box. My ODE state vector u is an N x 2 array of numbers. Each call to the model updates a pre-allocated N x 2 array named F_arr, which I preallocated using DiffCache from PreallocationTools.jl. I am able to solve the model using non-stiff and stiff solvers (e.g. Tsit5 and Rodas5), and it’s compatible with dual numbers/autodifferentiation.
Now I’m wondering if I can improve the performance through using MVectors. Since the position of each particle is of fixed length (2), I was trying to come up with a way to store each particles position as an MVector. To do this, I changed the state variable u to be a vector (of length N) of MVectors (of length 2(. This approach worked when solving the model using Tsit5, but it I ran into issues when using stiff solvers such as Rodas 5 because apparently the stiff solvers expect u to be an N-dimensional array of numbers.
Any suggestions for how to incorporate MVectors into my model to maximize (or at least improve) performance, while also being compatible with stiff solvers and Dual numbers?