278. Numerical Integration

Methods for numerically integrating the ODEs of a system-dynamics model. Critical for simulation accuracy.

278.1. Euler method (default for SD)

𝑆𝑡+Δ𝑡=𝑆𝑡+Δ𝑡(net flow𝑡)

Forward Euler. Simple, fast, error per step 𝑂(Δ𝑡2), total error 𝑂(Δ𝑡).

For SD models, Euler with a small enough Δ𝑡 is usually good enough.

278.2. Time step (Δ𝑡) selection rule

Δ𝑡min(𝜏𝑖)4

where 𝜏𝑖 are the time constants of the system. Rule of thumb: divide the fastest time constant by 4-10.

Why? At Δ𝑡=𝜏4, Euler captures the dominant time scale; faster than that, all time scales are well-resolved.

278.3. Runge-Kutta 2 (RK2 / midpoint)

𝑘1=𝑓(𝑆𝑡,𝑡)𝑘2=𝑓(𝑆𝑡+(Δ𝑡2)𝑘1,𝑡+Δ𝑡2)𝑆𝑡+Δ𝑡=𝑆𝑡+Δ𝑡𝑘2

Error per step 𝑂(Δ𝑡3), total 𝑂(Δ𝑡2). Twice the work of Euler per step, better accuracy.

278.4. Runge-Kutta 4 (RK4)

The “classical” RK4:

𝑘1=𝑓(𝑆𝑡,𝑡)𝑘2=𝑓(𝑆𝑡+(Δ𝑡2)𝑘1,𝑡+Δ𝑡2)𝑘3=𝑓(𝑆𝑡+(Δ𝑡2)𝑘2,𝑡+Δ𝑡2)𝑘4=𝑓(𝑆𝑡+Δ𝑡𝑘3,𝑡+Δ𝑡)𝑆𝑡+Δ𝑡=𝑆𝑡+(Δ𝑡6)(𝑘1+2𝑘2+2𝑘3+𝑘4)

Error per step 𝑂(Δ𝑡5), total 𝑂(Δ𝑡4). Four times the work per step, much higher accuracy.

278.5. Which to use?

MethodPer-step costPer-step errorBest for
Euler1 eval𝑂(Δ𝑡2)Most SD models, small Δ𝑡
RK22 evals𝑂(Δ𝑡3)Moderate accuracy needs
RK44 evals𝑂(Δ𝑡5)High-accuracy / oscillatory systems

For smooth SD models with Δ𝑡=𝜏min4: Euler is fine. For oscillatory or stiff systems: RK4 or adaptive methods.

278.6. Stiff systems

When time constants span orders of magnitude (e.g., 𝜏1=1, 𝜏2=1000), explicit methods (Euler, RK) need tiny Δ𝑡 to stay stable on the fast time scale, wasting effort on the slow.

Implicit methods (backward Euler, BDF) trade per-step cost for stability — large Δ𝑡 allowed.

In SD, stiff systems are rare; explicit methods are usually sufficient.

278.7. Initialization in equilibrium

Common SD practice: set initial stocks so that all flows balance at 𝑡=0 (system at steady state). Then study the response to a perturbation.

This isolates the dynamic response from initial-condition transients.

278.8. See also