-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Symbolic Indexing Mismatch Between ODESolution
and integrator
#100
Comments
This is not a bug. Notice that the callback function has the signature
Note how you're indexing |
Ah gotcha, my mistake. Is there anyway to easily use symbolic indexing within the saving function? My original use case was basically defining an observable (just a ratio of sums of different variables) within the saving callback, so that I wouldn't have to save the full solution array only to reduce it afterwards. |
You can use the function returned by |
What would be the recommended way of saving an observable like
|
Inconsistent Results from Symbolic Indexing in ODESolution vs SavingCallback
There appears to be a discrepancy between the values obtained through symbolic indexing of an
ODEProblem
solution and those saved using aSavingCallback
with symbolic indexing of the integrator. This occurs when usingSymbolicIndexingInterface.jl
within the context of solving ODEs withModelingToolkit
andDifferentialEquations
.Specifically, when solving an ODE system and saving a variable (in this case, 'x') using two different methods:
ODESolution
usingsol[:x]
SavingCallback
withintegrator[:x]
The results show a noticeable difference, suggesting that the symbolic indexing within the
SavingCallback
may not be accurately capturing the state of the system at each time point.Expected behavior
The values saved using the
SavingCallback
with symbolic indexing (integrator[:x]
) should match those obtained directly from theODESolution
(sol[:x]
) at corresponding time points, as both methods are intended to access the same state variable 'x' throughout the solution process.Minimal Reproducible Example 👇
This issue suggests a potential problem with how SymbolicIndexingInterface.jl interacts with the integrator object within SavingCallback, possibly related to caching or how the symbolic indexing is resolved during the callback execution.
However, I'm not quite sure and this issue may be better placed under the other packages used here. This might have more to do with
DiffEqCallbacks
than the symbolic indexing. The discrepancy goes away when using numerical indexing in thesave_func
, likesave_func = (u, t, integrator) -> u[1]
.Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
The text was updated successfully, but these errors were encountered: