I am trying the implement the following odeint solver example but my differential equations are different.


The system I have is stiff so the rosenbrock method is a good fit for that. However, the solution process is really slow, often taking 2 million steps to reach t = 2.5s.

Is there any way to tweak the adaptive stepping settings and see what steps are being taken by the solver? I haven't been able to find a good documentation for this, the only one I found is


If there is a way to speed it up without tweaking the stepping, that would work as well.



From the documentation and this spot in the code show that it is doing Gustafsson acceleration. That's usually a good technique and is advocated by Hairer. I have found in my own tests that actually PI-controllers work surprisingly well with high order Rosenbrock methods, but YMMV. It's probably problem and tableau dependent. But anyways, that's the spot in the code you'd modify.

But I do want to address one other thing.

The system I have is stiff so the rosenbrock method is a good fit for that.

Not necessarily, I wouldn't not blindly say this at all. The Rosenbrock methods tend to be good for stiff equations when you are trying to solve for error less than $\approx10^{-6}$ and your system of equations is not sufficiently large (I'll point to Hairer II, the DiffEqBenchmarks, and lots of other currently unpublished benchmarks which all pretty much say the same thing). But then again, multistep methods can still "sneak a win" if the system is smooth enough every one in awhile, so it's not a hard-fast rule. If you really want to be sure what's good for your problem, I would recommend solving a small part of your real equation using some suite that has easy access to Radau, both high and low order Rosenbrock, a BDF, and optionally high and low order (E)SDIRK methods since these tend to do the best in various regimes. You should also generate a reference solution since comparing timings without comparing error is never a good idea (many times the faster one can just have a higher error), which is why work-precision diagrams are a good tool if you want to do this comparison easily. This example in the DiffEqBenchmarks shows an easy way to run such a test, though you can also setup something similar with MATLAB or with wrappers to Hairer's solver suite for example to see similar results (but with some missing methods in each case).

| cite | improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.