headmyshoulder / odeint-v2

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

Added Controlled Adams Bashforth Moulton Stepper #208

Closed vhartman closed 7 years ago

vhartman commented 7 years ago

Implemented a controlled adams bashforth moulton Stepper requested by Issue #175. The stepper is based on the divided difference method, which is used to calculate the coefficients for the prediction and correction step. The order can be chosen arbitrarily large. I added the stepper to the integration-test as well.

The currently implemented stepsize controller is described in [0].

[0] http://www.maths.lth.se/na/staff/gustaf/filtern.pdf

vhartman commented 7 years ago

Thank you for the comments! I added the testcases for the numeric precision. There seems to be a problem with the higher order adaptive_adams_bashforth_moulton (The magnitude of the error is correct, but still slightly over the upper bound).

I am currently looking into the implementation of a slightly different formulation which allows to avoid new calculations of the coefficients if the stepsize is the same.

mariomulansky commented 7 years ago

Looks good so far. I can merge if you want and you can add improvements in a following PR. Or we wait and you check the other formulation first, however you want. As for the numerical check: The upper bound (I think its called f in the code) is only hand-wavy. There is an a priori unknown pre-factor that I adjusted such that it passes the tests. If the order is right you might just have to increase f slightly to have things pass.

vhartman commented 7 years ago

I would prefer to finish the other formulation first, and push it here. It might take another week though. Thank you very much!

vhartman commented 7 years ago

Hey! Thank you for the patience, the stepper should be pretty much done now. There are a few things that I am not sure if they could be designed better (the operation for the controller), and a few things that could be added (e.g. pre-computation of the coefficients, additional controllers, support for boost::range), but it should be fine for now.

Could you review it again, and if you don't want me anything to change, merge it? I would then start the documentation, and open another pull request for that.

vhartman commented 7 years ago

Alright, now it should be actually done. I just added proper treatment of the absolute and relative error (in the same way as it is done in controlled_runge_kutta).

mariomulansky commented 7 years ago

great work, thanks a lot!

vhartman commented 7 years ago

Thanks for merging! I have found a bug in the initialization that somehow slipped through the numerical unit test (apparently nan is larger than nan). Sorry for the inconvenience.

Should I open another pullrequest?

mariomulansky commented 7 years ago

sure, just open another PR.