bmcage / odes

The ODES scikit for ordinary differential and algebraic equations, an extension to scipy
https://scikits-odes.readthedocs.io/
Other
124 stars 45 forks source link

sparse jacobians and iterative solvers in IDA #77

Open mrkwjc opened 6 years ago

mrkwjc commented 6 years ago

Hi!

Nice work with odes! But, of course, i have a question. Is this possible to use sparse jacobians in IDA? And another one: can i use iterative preconditioned solvers with custom preconditioner? Unfortunately my problems are quite large and dense jacobians is not an option for me so i'm looking for possible solutions...

Best regards, Marek

bmcage commented 6 years ago

Yes Sparse is possible. There are several ways, but not all are exposed in the API. For preconditioning, I have not used it myself, but if memory serves a contributor added this somewhat. It is possible in the C++ solver, exposing this in the python interface is possible. Ideally you help with #76 and help expose the relevant interfaces. Adding the preconditioner part of sundials 2.7.0 (current odes) would mean redoing it soon after for the 3.1.0 port

rtimms commented 5 years ago

Great job with the scikits.odes! We are currently using the sundials solvers in a battery modelling package PyBaMM, and are trying to use sparse jacobians in IDA and CVODE. I was just wondering if you had any more information on how to get sparse jacobians into these solvers, please?

Thanks!

martinjrobins commented 5 years ago

I can see how you can use sparse matrices using CVODE, using the iterative solvers and the CV_JacTimesVecFunction provided by scikits.odes (https://bmcage.github.io/odes/dev/api.html#module-scikits.odes.sundials.cvode). But a similar option does not seem to exist for IDA, which only has IDA_WrapJacRhsFunction. Or am I missing something?

martinjrobins commented 5 years ago

Seems like it would be straightforward to implement IDA_JacTimesVecFunction following the example of CV_JacTimesVecFunction. I can create a PR for this if it would be helpful @bmcage?

bmcage commented 5 years ago

Yes, all extra exposure of sundials API is useful! Intelligent copy paste and adaptation of cvode code should indeed be straightforward.
I do assume people only add stuff they intend to use, so add a test for it too !