LSODA solver library C++

529 views
Skip to first unread message

Dilawar Singh

unread,
Aug 12, 2018, 5:42:44 AM8/12/18
to wncc_iitb
For solving system of ODEs numerically, one needs to figure out which solver to pick based on the 'stiffness' of the system. Arthur Muttuck's excellent lectures on ODE system are here: https://www.youtube.com/watch?v=LbKKzMag5Rc. I recently heard in a talk that the speaker saw oscillatory behavior in his model and thought he discovered something exciting. Only to discover after couple of months that what he saw were due to inefficiency of the default solver of MATLAB which his student could not reproduce in scipy (which is basically odepack).

Stiff system requires much smaller step-size and therefore requires much longer time. ODE systems are not 'stiff' everywhere; and one can probably use much larger step-size in solution domain where stiffness is relatively small. The method LSODA does exactly that.

It quantifies stiffness automatically and switch the appropriate type of solver. It always assume that system is stiff. LSODA saves quite a lot of time.

We have been using bost GSL and Boost implementation of ODE solvers in MOOSE simulator. BOOST usually performs 2x better than GSL solvers. Recently I tried integrating the LSODA solver into our numerical engine. This library came out of this effort.

The original code was ported to C (http://www.ccl.net/cca/software/SOURCES/C/kinetics2/index.shtml) which was modified by Heng Li (http://lh3lh3.users.sourceforge.net/download/lsoda.c) to simplify the interface. This work port this version to C++ and uses some c++11 features. It is available here https://github.com/dilawar/lsoda_cpp under MIT license.  If you use it, discover memory leaks or bugs, I'd like to hear about it.

- Dilawar

Advait Raut

unread,
Aug 14, 2018, 5:37:23 AM8/14/18
to wncc...@googlegroups.com
Hi Dilwar
Looks good attempt to me.
I can see that your MIT licensed code contain some GPLed code.


--
--
The website for the club is http://wncc-iitb.org/
To post to this group, send email to wncc...@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "Web and Coding Club IIT Bombay" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wncc_iitb+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dilawar Singh

unread,
Aug 14, 2018, 6:19:18 AM8/14/18
to wncc...@googlegroups.com
Thanks Advait.

I've fixed the license. All code is under MIT license now. It is 3x faster now
than BOOST::ode lib implementation of rk5a which is a decent default solver
type.

It is slightly faster than c version; but I had only couple of test cases. It
can be used with std::thread as well.

best,
Dilawar

--
Reply all
Reply to author
Forward
0 new messages