Computing Library › Numerical Methods
Numerical Methods

Adaptive Step-Size Control

Adaptive ODE solvers estimate local error each step and adjust the step size to hold error near a tolerance, saving work where the solution is smooth.

Matching effort to the solution

A fixed step size is either too large where the solution changes fast or too small where it is smooth. Adaptive step control estimates the local error at each step and shrinks or grows the step to keep that error near a user tolerance, taking large steps through calm regions and small steps through rapid transients.

Estimating the error

Kronos motion — control room

Embedded Runge-Kutta pairs, such as Dormand-Prince (RK45), compute two solutions of different order from the same slope evaluations. Their difference approximates the local truncation error at almost no extra cost. Alternatively, step-doubling compares one full step with two half steps.

python
def new_step(h, err, tol, order):
    # PI-free basic controller
    if err == 0: return 2*h
    factor = 0.9 * (tol/err)**(1.0/(order+1))
    factor = max(0.2, min(5.0, factor))
    return h*factor

The control law

Given an estimated error and a tolerance, the step is scaled by roughly (tol/err)^{1/(p+1)}, with safety factors and limits to avoid wild swings. If the step's error exceeds tolerance the step is rejected and retried smaller; otherwise it is accepted and the next step may grow. More refined PI controllers smooth the step sequence.

Tolerances and pitfalls

Users set absolute and relative tolerances; the absolute tolerance matters when the solution passes near zero. Adaptivity does not fix stiffness: an explicit adaptive solver on a stiff problem simply takes many tiny steps and stalls. Detecting that pattern is a signal to switch to an implicit method.

Adaptive solvers are the default for production ODE integration, automatically resolving fast events and coasting through slow phases in the time-dependent models used across breeder Hyperion studies.