Concepts
Stiff models
Updated 3 November 2026 · 2 min read
A model is stiff when something in it happens much faster than everything else. Stiff models aren’t wrong, but they can make an ordinary solver slow to a crawl. This page explains why, and why a stiff solver doesn’t have the same problem.
Fast and slow in one model#
Picture a small tank that equalises with a large one through a short pipe, in seconds, inside a model that runs for a thousand seconds to follow the large one draining. After the first second or so, the small tank simply follows the large one; nothing fast is happening any more. But the fast process is still in the equations, ready to react to any disturbance in hundredths of a second.
That is stiffness: time scales far apart in one model. The fast one has finished, but it still constrains how the model can be solved.
Why an ordinary solver crawls#
Ode45 and the other non-stiff solvers are explicit: they step forward using only what they know now. For such a solver, a step much longer than the fastest time scale doesn’t just lose accuracy, it blows up. The solver’s error control sees this and cuts the step, so every step has to stay short enough for the fastest process, for the whole run.
Put numbers on the tanks. If the small tank equalises with a time constant of 0.01 s, Ode45 can’t step much more than about 0.03 s at a time. A thousand-second run then needs tens of thousands of steps, almost all of them spent watching a fast process that finished in the first second. That is how a model with three stocks can run into the 30-second limit.
Why a stiff solver doesn’t#
Ode32s, Ode43s and Ode85s are implicit: each step solves an equation for where the model will be at the end of the step, not just where it was at the start. That makes them stable with long steps however fast the fast process is, so they can take steps sized to what is actually changing, the slow drain. For the tanks that is a few dozen steps instead of tens of thousands. Each implicit step costs more, but there are so many fewer that the run is far faster.
When to suspect it#
- A run is slow for a model of its size, or stops at the time limit.
- The model has something fast beside something slow: a reaction and a build-up, an absorption in minutes and a clearance over weeks, a fast aquifer and a slow reservoir.
- Rates in the model differ by a factor of a thousand or more.
Switch the solver to Ode43s and run again. If it is suddenly fast, the model was stiff. If it is no faster, it wasn’t, and something else is slow: a nonlinear function struggling to find its root, or simply a long run with a fine report.
See also
- Choose a solverWhich of the nine solvers to use, and how to tell when a model is stiff.
- SolversThe nine ODE solvers, what each is for, and the accuracy they hold.
- LimitsHow long a run may take, how often you may run, and other bounds.
- Nonlinear function (Fzero)The x between two bounds that makes an expression zero, at every step.