Commit ff465b8
Fix FieldError for Magnus/Linear integrators with OrdinaryDiffEqDifferentiation (#3232)
Magnus integrators (MagnusGL6, MagnusGL8, etc.) and other
OrdinaryDiffEqLinearExponentialAlgorithm subtypes have no `autodiff`
field — only `krylov`, `m`, `iop`. When OrdinaryDiffEqDifferentiation
is loaded (e.g. via DifferentialEquations.jl), the generic
`_alg_autodiff(::OrdinaryDiffEqExponentialAlgorithm{CS,AD})` dispatch
would call `alg.autodiff` on these types, causing a FieldError crash.
Fix:
- Import OrdinaryDiffEqLinearExponentialAlgorithm into
OrdinaryDiffEqDifferentiation
- Add _alg_autodiff(::OrdinaryDiffEqLinearExponentialAlgorithm)
returning Val{false}(), intercepting calls before the generic
ExponentialAlgorithm dispatch that accesses the nonexistent field
- The existing prepare_alg override in OrdinaryDiffEqCore (line 298)
already handles the prepare_alg path correctly
Also adds regression tests verifying _alg_autodiff, prepare_alg, and
forwarddiffs_model all work correctly for LinearExponentialAlgorithm
subtypes.1 parent a2c092a commit ff465b8
File tree
3 files changed
+37
-0
lines changed- lib/OrdinaryDiffEqDifferentiation
- src
- test
3 files changed
+37
-0
lines changedLines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
35 | 41 | | |
36 | 42 | | |
37 | 43 | | |
| |||
66 | 72 | | |
67 | 73 | | |
68 | 74 | | |
| 75 | + | |
| 76 | + | |
69 | 77 | | |
70 | 78 | | |
71 | 79 | | |
| |||
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
0 commit comments