Richard
Richard

Reputation: 61499

Set a maximum step size in odeint

I create a boost::odeint stepper as follows:

auto stepper=boost::numeric::odeint::make_dense_output(0.01/*Absolute*/,0.1/*Relative*/, boost::numeric::odeint::runge_kutta_dopri5< CombinedState >() );

There will be times during the integration of my system where it "lies low" for a while. During this periods it seems as though the integrator sometimes increases its step size to the point where it then jumps over areas of interest.

Is there a way to limit the integrator's step size so it never exceeds a given maximum?

Upvotes: 1

Views: 935

Answers (2)

Karmo
Karmo

Reputation: 351

The step size limit was added in boost 1.60. Now the third argument is optionally max step size.

auto stepper=boost::numeric::odeint::make_dense_output(0.01/*Absolute*/,0.1/*Relative*/, 0.01/*max_dt*/, boost::numeric::odeint::runge_kutta_dopri5< CombinedState >() );

It was implemented in https://github.com/headmyshoulder/odeint-v2/pull/177

Upvotes: 1

headmyshoulder
headmyshoulder

Reputation: 6320

I am sorry, but this is not possible at the moment. Nevertheless, if this feature is really important for you, just copy the controlled_runge_kutta to a stepper with a different name like max_dt_controlled_runge_kutta and insert a check for the maximal time-step by hand. The code is not too complicated. You only have to do it twice, since there exist two specializations of controlled_runge_kutta.

If there are problems just let me know.

Upvotes: 2

Related Questions