headmyshoulder / odeint-v2

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

maximum step size setting #122

Closed jtravs closed 8 years ago

jtravs commented 10 years ago

I may have missed it in the documentation, but is there a way to set the maximum step size? For some problems it is necessary to prevent the adaptive stepper from missing out fast events (I can provide an example). Currently I am using integrate_const as a workaround, but that strongly couples the observer output to the upper step size I would like.

headmyshoulder commented 10 years ago

Currently there is now way to set a maximum step size. The step size can be controlled with the parameters of the make_controlled function. The first parameter is the absolute error tolerance and the second one the relative. If you miss events you can decrease these values by one order.

The step size of integrate_const has not very much to do with the step size of the real ode solver. It is the step size at which times the solution of the ode is evaluated. Internally you can have a full controlled stepper with step size control.

Does this help you?

mariomulansky commented 10 years ago

Indeed, to introduce a maximum step size you currently would have to change the controlled_runge_kutta class which implements the step size control. Although it is true that the step size in integrate_const is not necessarily the step size of the stepper, for a controlled stepper (no dense output), the step size of the stepper can not become larger of the step size in integrate_const, so your workaround is valid.

Nevertheless, I think it would be nice if we decouple the step size computation from the controlled_runge_kutta class and thus make it more easily exchangeable so that such requests can be solved rather easily by the users?

jtravs commented 10 years ago

Yes, exactly - integrate_const forces a maximum step size. Reducing the error tolerance does work eventually also, so I can use that too, but as an extra safety measure it would be nice to have this feature.

BTW, thanks for the fast response, and great library!

mariomulansky commented 8 years ago

This new functionality has been included in #177 and will be part of the next release (Boost 1.60)