Nested struct as state variable in DifferentialEquations

That’s the best way.

The key is you need to define enough of the array interface for it to “work”. ComponentArrays is probably the nicest structure for this, and is designed to work without overhead of just using a flat array.

2 Likes