Open oscardssmith opened 5 months ago
So it sounds to me like one path forward might be to have two initializealg
arguments, something like initializealg
and reinitializealg
, where reinitializealg
would just default to BrownFullBasicInit
? And reinitializealg
would be what gets called after discontinuities?
What information/flag does the standard initializealg use that prevents it from modifying differential variables when re-initializing after a callback?
the standard initializealg is BrownFullBasicInit.
Ah, and BrownFullBasicInit does not modify any differential variables.
So it sounds to me like one path forward might be to have two initializealg arguments, something like initializealg and reinitializealg, where reinitializealg would just default to BrownFullBasicInit? And reinitializealg would be what gets called after discontinuities?
In general you may want to tag callbacks with a reinitialization routine, because what variables to keep constant could depend on which ones you just modified.
Describe the bug 🐞 After hitting a callback,
dae
s are re-initialized with their initializealg (https://github.com/SciML/OrdinaryDiffEq.jl/blob/31d91572c490b6eb685d6793d8bfd80389160dae/src/integrators/integrator_interface.jl#L39) rather thanBrownFullBasicInit
. This means that if the user is using a custom initializealg (orShampineColocationInit
), that initialization will be called after callbacks which is likely not desired. Note, however that fixing this correctly is somewhat difficult (hence the lack of a PR), because if the user is using a custom init for different reasons (e.g. turning off autodiff for initialization), we don't want to use the defaultBrownFullBasicInit
as doing so would try to use autodiff and potentially crash. The code below reproduces this (and the problem with the obvious fix)