I’m modelling cell population dynamics. Cells die and divide so the size of system is always changing. I love DifferentialEquations.jl because it is the only library I know of that has an API for this. Most of my state variables can trigger events (i.e. death or division) so it seems that VectorContinuousCallback is the way to go. Unfortunately, the constructor for VectorContinuousCallback requires the length of the returned vector which in my case will change frequently. I could specify a very large length and pad the return vector with non-zero values but that seems inelegant and inefficient.
Have I missed something in the API? Can I simple change VectorContinuousCallback.len in an affect! call? What is the best way to handle this?
There isn’t a way to change that right now. It’s worth adding though. Open an issue. As a workaround, you could have a single ContinuousCallback that is the multiplication of conditions and then calculate which one had the crossing.
This can fail if the solver steps over the sign change from two callbacks. I’m finding it a bit difficult to work with. At the moment, I’m forcing dtmax to be very small but that’s not ideal.
How difficult is this? Is it simply matter of rejigging data structures during an affect! call? If so, I could have a crack it myself. Or does it require an understanding of DE methods, in which case, I’m probably not qualified.
Yeah it’s actually not so hard. You’d need code just like:
that checks if there are any VectorContinuousCallbacks in integrator.opts.callback and then calls resize! on them, and the dispatch for that needs to resize! the internal cache vector.