Accessing derivative using HermiteInterpolation with DifferentialEquations.jl


#1

I have a solution to a DAE via DifferentialEquations.jl, which uses Hermite interpolation as can be seen here:

julia> sol
retcode: Success
Interpolation: 3rd order Hermite
...

(the example in the tutorial page linked above can be used as a MWE if you need one)

I can use the interpolation to obtain solutions to my system via:

julia> sol(1987.4)
5-element Array{Float64,1}:
 1877.24
  913.053
 3522.07
    0.512887
  731.781

which are interpolated values of sol.u at time t = 1987.4.
sol.u is an Array{Array{Float64,1},1} with a corresponding array sol.t calculated at specific times.

I’d also like to access the interpolation for my derivatives sol.du, which again is an Array{Array{Float64,1},1} corresponding to sol.t.

Is it possible to do this? Neither sol(1987.4).du or sol.du(1987.4) work.
I’d be happy to set up my own linear interpolation of the sol.du array after the fact, but at face value it seems like accessing this data should be possible already since struct HermiteInterpolation uses t, u, du, and I’ve just missed that section of the docs.


#2

Are you asking for sol(t,Val{1}), the function for the derivative?

http://docs.juliadiffeq.org/latest/basics/solution.html#Interpolations-1

If you access that at one of the solution time points it will just give you the value of the derivative that it had stored in sol.k (and then the structure of k is different depending on the algorithm though… we can add a fake sol.du using getproperty overloading on v0.7 though if that’s useful?). But this is an interpolating function of the derivative as well.


#3

Thanks Chris,

Yeah, sol(t,Val{1}) is what I was after—looks like I missed the point of the second argument to the interpolation functions when reading this before.

As for the second point, I’m not sure if that would be needed in my case, so probably not worth the trouble of implementing anything here.