I’ve been rereading some of the docs and tutorials in SciML and in particular this https://tutorials.sciml.ai/html/introduction/03-optimizing_diffeq_code.html, and tried using StaticArrays as in the lorenz example, but on a problem of my own. In my case, the execution time went from about 70 ms using the modifying form with normal vectors, to about 300 ms using SVector. My problem has only 4 ODEs, and is needing about 22000 points to solve (mostly driven by a PeriodicCallback that fires 6000 times).
The solutions appear to be the same, but I do see a difference in the number of points saved, 22241 (modifying form) vs 22533 (SVector) which seems suspicious.
I’m not specifying the solver, but both report CompositeAlgorithm of Vern7, Rodas4 in the sol.alg field.
Due to proprietary stuff in my file I can’t just post it, so before I try to make an MWE I’ll try asking a couple of questions:
Have changes in Julia made the SVector optimization less valuable or possibly counterproductive?
Does the heavy use of PeriodicCallback do something that would cause this to backfire?
I’m using Julia 1.5.3 on Windows.
EDIT: The time point sets are generally different (other than those forced by the DiscreteCallback). I confirmed by
all(isapprox(sol(t),sol2(t);atol=1e-6) for t ∈ 0.0:0.001:0.6) that the answers are equivalent to within the abstol I specified, but why would the change of mutating or not cause the simulation to take a (slightly) different path?