Closed acoh64 closed 1 year ago
This is still a bit off. In a given step, integrator(t)
is an interpolation from integrator(t)
to integrator(t + dt)
. What this should be doing is evaluating at Gauss points theta[i]
with weights w[i]
, and doing saveval = sum(w[i]*integrator(t + theta[i]*dt), length(theta))
. No tstops
setting is necessary.
I think I fixed this now. I had to use integrator(t)
and integrator(tprev)
though since if the next time step was not exactly equal to dt
the results would not be accurate.
It might be good to include another test case that's simpler to work out by hand, like a linear ODE and check against the analytical solution. The vjp one is good too, but you need to add it to runtests.jl
and update the test dependencies. Otherwise, this is looking really good!
sounds good, I'll add a test like this soon!
We can do the mentioned optimizations in a follow up PR. I think other than that, this is good to go with the final suggestions.
I added a test for a simple linear system with an analytical solution. Let me know if I should make any other changes and I can start working on the method in SciMLSensitivity.jl
🎉
I made a new callback which works very similar to SavingCallback.
save_func
now becomesintegrand_func
which is a function passed to the callback to compute the integrand in the adjoint integral. The callback computes this at each time step of the integrator and saves the result. I need to change this so the callback computes this at the Gaussian quadrature nodes. @ChrisRackauckas let me know if you had something different in mind.