JuliaGNI / GeometricIntegrators.jl

Geometric Numerical Integration in Julia
MIT License
47 stars 9 forks source link

Parameter `t` in the function `v` of ODEProblem is not the current time #148

Closed LivelyLiz closed 1 year ago

LivelyLiz commented 1 year ago

Maybe I misunderstand something crucial, but I tried to integrate a time varying ODE and the result is just wrong. When I looked at the value t that I get, it seems to be always the timestep taken, not the total time of the current integration step.

Example:

using GeometricIntegrators

function eo(xdot, t, x, params)
    println(t)
    xdot[1] = x[1]
end

prob = ODEProblem(eo, (0.0, 1.0), 0.1, [3.0])
int = Integrator(prob, TableauRK4())

integrate(prob, int)

prints:

0.0
0.05
0.05
0.1
0.0
0.05
0.05
0.1
0.0
0.05
0.05
0.1
0.0
0.05
0.05
0.1
0.0
0.05
0.05
0.1
0.0
0.05
0.05
0.1
0.0
0.05
0.05
0.1
0.0
0.05
0.05
0.1
0.0
0.05
0.05
0.1
0.0
0.05
0.05
0.1
michakraus commented 1 year ago

This is curious! From what I can see (a) you are doing everything correctly and (b) there is no obvious issue in the integrator causing this problem. I may have an idea, though. I will investigate this...

michakraus commented 1 year ago

This is fixed in the master branch for most Runge-Kutta methods (not yet for more special integrators). This was a rather nasty thing. I guess we don't have tests for time-dependent problems...

Please update to master

]add GeometricIntegrators #master

and try again.

LivelyLiz commented 1 year ago

:+1: Looks like it's working now. Thanks for the quick response