I’ve been improving performance of my differential equations with @SVector
and @MVector
but I’ve got stuck when it comes to using it with callbacks specifically PresetTimeCallback
.
The idea is there is a large spike in volume (u[1]
) at time 25 but then it goes “back to normal” at the next time hence the two callbacks. Then these two callbacks go into a CallbackSet
. It is working but I would like to know if there’s a way to use StaticArrays.jl
with the callbacks. Any thoughts?
big_volume_jump = 25.0
function big_volume_jump!(integrator)
integrator.u[1] += 250.0
end
function return_volume_to_normal!(integrator)
integrator.u[1] -= 250.0
end
big_volume_jump_callback = PresetTimeCallback(big_volume_time, big_volume_jump!)
resume_volume_callback = PresetTimeCallback(big_volume_time + 0.01, return_volume_to_normal!)
callbacks = CallbackSet(big_volume_jump_callback, resume_volume_callback)