headmyshoulder / odeint-v2

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

controlled adams stepper #175

Open wds15 opened 8 years ago

wds15 commented 8 years ago

The Adams* family of steppers is supposed to do evaluate less frequently the system function which is of great benefit if the system function is expensive. However, at the moment there seems to be no way to control absolute and relative error. This would be very useful to have in order to perform adaptive integration.

mariomulansky commented 8 years ago

The current implementation (which is the standard way) relies on the fact that all steps are done with the same step size. So including step size control is not possible. However, there is a formulation of the adams-bashforth that allows for step size control [1] and indeed this would be a good addition to odeint. I will look into this but I can't promise quick progress with this right now.

[1] Hairer Norsett Wannier "Solving ODES I" Chapter III.3 (p. 397)

wds15 commented 8 years ago

Yes, this would be a great addition. Just to add here: CVODE implements a variable order Adams method. Maybe this is worthwhile to look into (I can't give you a reference here, maybe it is possibly even based on the same reference you are referring to).

mariomulansky commented 8 years ago

Variable order or adaptive step size? These are very different things!

wds15 commented 8 years ago

Sorry, I am only the user here and all I would like to have is Adams type algorithm which guarantees me an abs+rel error tolerance. CVODE uses variable order Adams, but also ensures abs+rel tolerance to be right. Ultimately, the integrator would be better from my perspective if less calls to the system functor are needed (whatever that takes).

mariomulansky commented 8 years ago

Sure, I understand. I was asking in case you happened to know how this is implemented in CVODE. Anyhow, I found the description in the CVODE docs. Apparently, CVODE does both, step size control and order adaption. Again, I will try to get something similar into odeint.

For the time being you might want to look into the Bulirsch-Stoer steppers, they also offer step size control, order adaption and additionally dense output. They are not multistep methods, but should be an improvement over dopri5.

wds15 commented 8 years ago

Great. Many thanks!

Bulirsch-Stoer are supposed to be good for "high" precision; what does high mean? 1e-6 rel+abs?

mariomulansky commented 8 years ago

Hrm hard to say, but my feeling is that its strength comes into play only for higher precision like 1e-10...1e-14

markusgft commented 7 years ago

Dear all, I have just come across this conversation since I'm very interested in using a variable-step adams_bashforth/adams_bashforth_moulton or adams_moulton integrator. I am wondering if there are any news on this issue? Any hints are highly appreciated, and thanks a lot in advance!

GregorDeCillia commented 7 years ago

If anyone wants to implement a variable step adams-bashforth-moulton stepper in odeint, here is some mathematical bakground: http://www.aip.de/groups/soe/local/numres/bookcpdf/c16-7.pdf. An implementation of a controlled 4th order adams-moulton method and a controlled 4th order adams-bashforth method can be derived from the formulas given there. There is also some discussion about varying orders on page 5.

vhartman commented 7 years ago

Dear all, I am currently in the process of writing a controlled adams bashforth moulton stepper (and as a byproduct an adaptive adams bashforth stepper). What's the process of integrating it into odeint respectively boost? Best regards

headmyshoulder commented 7 years ago

Hi @vhartman, can you open a pull request with the controlled adams bashforth stepper? We will review the code and merge it into the master branch. Thank you for your constribution.