Commit d20c351
Support null u0 with callbacks for all solvers
When `u0 === nothing`, convert u to an empty Float64 array to allow
initialization to proceed. This enables problems with no state variables
but with callbacks to be solved with any solver.
Changes:
1. OrdinaryDiffEqCore/src/solve.jl: Convert null u0 to Float64[]
2. OrdinaryDiffEqDifferentiation/src/derivative_wrappers.jl: Skip Jacobian
computation for empty state vectors
This fixes the issue where MTK systems that simplify to having no differential
equations (resulting in `u0 === nothing`) but have `SymbolicDiscreteCallback`
could not trigger callbacks.
Tested with explicit (FunctionMap, Tsit5, Euler, RK4) and implicit
(Rosenbrock23, Rodas5P, TRBDF2, KenCarp4, ImplicitEuler, QNDF, FBDF) solvers.
References: SciML/ModelingToolkit.jl#4078
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>1 parent 7ce26b5 commit d20c351
File tree
2 files changed
+11
-0
lines changed- lib
- OrdinaryDiffEqCore/src
- OrdinaryDiffEqDifferentiation/src
2 files changed
+11
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
215 | 221 | | |
216 | 222 | | |
217 | 223 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
189 | 194 | | |
190 | 195 | | |
191 | 196 | | |
| |||
0 commit comments