I have an ODE system of the general form

  y' = k(y)(x) + q(z)(x)
  x' = a(z)(x) + b(x)(x) 

where k,q,a and b are also dependent on the states x and y. The solver(ODEINT) is throwing the error: "Max number of iterations exceeded. A new step size was not found". I am using the Rosenbrock method on a stiff system. Is the step size for Rosenbrock method iteratively calculated? If so, what parameters should I look to adjust to prevent this isssue?


Rosenbrock methods utilize embedded lower order methods in order to calculate errors for adaptive time stepping. In addition, Rosenbrock methods do not have to solve an implicit system (just a linear system). There is no form of iteration then that takes place in them (unless you're using a Krylov linear solver).

Maximum number of steps for stiff solver can be due to many reasons. The first one is simply that the solver diverged. If it diverges, then the errors grow and the time steps shrink. In many cases, the number of steps could just run out before the solver notices it diverged, and throws this error accidentally.

Divergence of the solver can happen for many reasons. One reason this could happen is because the tolerances are too high. While in theory these methods are L-stable, adaptive time stepping and errors in the Jacobian change this in practice. But it will always be stable below some tolerance, so give that a try. If that doesn't work, then look at your derivative function. Most likely it's user-error.

If it's not divergence (which you'd be able to see from a plot), then you might just be taking too many steps if you're asking for a really low tolerance. In that case, make sure you really need that much accuracy and if you do, there's no choice except increase the number of max steps.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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