headmyshoulder / odeint-v2

odeint - solving ordinary differential equations in c++ v2
http://headmyshoulder.github.com/odeint-v2/
Other
341 stars 101 forks source link

Missing ending point with dopri5 (dense output) #220

Closed brankaleon closed 5 years ago

brankaleon commented 7 years ago

I'm using dense output to get the value of the system state at large, constant time steps. However, the endpoint is not getting evaluated.

typedef result_of::make_dense_output<runge_kutta_dopri5>::type my_dense_stepper_type; my_dense_stepper_type dense2 = make_dense_output(1.0e-6, 1.0e-6, runge_kutta_dopri5< state_type >()); t0 = 0.; tf=1.; dt = 0.2; integrate_const(make_dense_output(1.0e-6, 1.0e-6, runge_kutta_dopri5< state_type >()), rhs, x0, t0, tf, dt, write_cout);

On the other hand, if i use "integrate_adaptive" the endpoint is evaluated and printed out

mariomulansky commented 5 years ago

This is probably due to finite precision. If you call integrate_const with tf+dt/2 you should see tf as the last evaluation point. However, if you want to take exactly 5 steps with dt=0.2 you should use integrate_n_steps instead of integrate_conts