A stiff spring rope is stable at a fixed 1/120 s physics step but explodes at 1/60 s; what causes it, and how do substeps fix it?
answer
- it blows up only when the step grows
- fastest natural frequency times the step
- semi-implicit Euler: omega dt below 2
- split the step, not the stiffness
basics
~20 sThe integrator crossed its stability limit: semi-implicit Euler stays bounded only while the fastest mode's angular frequency times the step is below 2. Substeps integrate several shorter steps per physics step, raising the limit proportionally at proportional cost.
solid answer
~40 sA spring of stiffness `k` on mass `m` oscillates at `ω = sqrt(k/m)`, and a chain of them has modes up to about `2*sqrt(k/m)`. Semi-implicit Euler is stable only while `ω*dt < 2` for the fastest mode; beyond it every step overshoots further and the amplitude grows geometrically. With 0.1 kg segments and `k = 1000 N/m` the fastest mode is near 200 rad/s, so 1/120 s gives 1.67 (stable) and 1/60 s gives 3.33 (explodes). Substepping runs the integrator `n` times per step at `dt/n`, multiplying the limit by `n` and the integration cost by `n`. Alternatives: softer springs, an implicit step for the stiff forces, or a constraint instead of a spring. Confirm by logging energy per step: geometric growth that starts above a step length is instability, not a sign error.
code
pseudocode · 8 lines// one fixed physics step of length dt, split into n substeps
h = dt / n
repeat n times:
for each particle p: // forces from current positions only
p.a = springForce(p) / p.m + gravity
for each particle p: // semi-implicit Euler per substep
p.v = p.v + p.a * h
p.x = p.x + p.v * hgo deeper
Recall that every integrator has a largest safe step for a given stiffness, and that a stiffer spring or a longer step can make a simulation explode.
Explain the omega times dt below 2 limit for semi-implicit Euler, why a chain's fastest mode is about twice a single spring's, and what substepping does.
Diagnose an explosion from its step dependence and geometric energy growth, compute the limit for the scene, and pick substeps, softer springs or an implicit step.
Turn the limit into policy: a stiffness budget designers tune within, substeps reserved for the subsystems that need them, and a test that runs worst-case steps.
## The symptom pattern A spring rope (a chain of point masses joined by springs) or a ragdoll with stiff spring joints behaves at one step length and **explodes** at a longer one: the oscillation grows each step until the bodies fly apart, and energy plotted per step rises **geometrically**. A step-dependent, geometric blow-up is the signature of an integrator crossing its **stability limit**. A sign error in the spring force fails at every step length, and rounding is far too small to grow this fast. If the loop ever hands the physics a longer step after a hitch, the same limit is crossed; keeping the step fixed is the game loop's job, and the integrator's job is to survive the step it is given. ## Confirming the diagnosis 1. Log the total energy, kinetic plus spring potential, every step. 2. Rerun the same scene at half the step length: if the blow-up disappears, the cause is stability, not the force code. 3. Compute `ω_max * dt` from the stiffest spring and the lightest masses it joins, and compare it with the integrator's limit. ## Where the limit comes from 1. A spring of stiffness `k` on a mass `m` oscillates at the angular frequency `ω = sqrt(k / m)`. 2. A chain of equal masses and springs has many modes; the fastest, where neighbours move in opposite directions, approaches `2 * sqrt(k / m)` for a long chain. 3. Semi-implicit Euler applied to a mode of frequency `ω` multiplies that mode's state each step by a matrix whose eigenvalues have magnitude one while `ω * dt < 2`, and one eigenvalue of magnitude above one beyond it. 4. Beyond the limit every step multiplies the amplitude by a factor above one, so any small disturbance grows geometrically. Explicit Euler is worse: on an undamped spring it gains energy at every step length. Velocity Verlet shares semi-implicit Euler's limit. ## Numbers for one rope Scenario figures: 0.1 kg segments joined by springs of `k = 1000 N/m`. Then `sqrt(k / m) = 100 rad/s` and the fastest mode is close to 200 rad/s. | Step | `ω_max * dt` | Semi-implicit Euler | |---|---|---| | 1/240 s | 0.83 | stable, reasonably accurate | | 1/120 s | 1.67 | stable, but coarse | | 1/60 s | 3.33 | the fastest mode grows every step | | 1/60 s in 4 substeps | 0.83 per substep | stable | The rope survives 1/120 s and explodes at 1/60 s exactly as the limit predicts. ## Substepping as an integration technique Substepping runs force evaluation and integration `n` times inside one physics step, each over `h = dt / n`. - The limit applies per substep, so the same frequency survives an `n` times longer outer step; equivalently, because `ω` grows with the square root of `k`, the stiffness can be `n²` times higher at the same outer step. - Force evaluation and integration cost grow by `n`. Work that does not need the fine step, such as updating the broad phase, can stay once per outer step when bodies move little inside it. - Compute every particle's force from the current substep's positions before updating any particle; mixing old and new positions inside one substep quietly changes the method. - Choose `n` from the stiffest mode you must support, with margin: `ω_max * h` near 1 or below gives acceptable accuracy, not just survival. ## Other remedies and their costs - **Softer springs or heavier segments** lower `ω`. Cheapest, but the rope stretches more. - **An implicit (backward) Euler step** for the stiff forces evaluates them at the end-of-step positions and is stable at any step length. It costs a linear solve over the connected particles and adds numerical damping that makes the rope look sluggish. - **Replacing the spring with a constraint** removes the stiffness from the integrator and hands it to a constraint solver, which has trade-offs of its own. - **Damping is not a fix.** With a damping rate per unit mass `c` integrated explicitly, semi-implicit Euler stays stable only while `(ω*dt)² < 4 - 2*c*dt`, so damping slightly **lowers** the limit, and `c*dt` of 2 or more is unstable by itself.
- Why does an implicit (backward) Euler step not explode, and why is it not the default?Backward Euler evaluates the spring at the end-of-step position, which on an undamped spring divides the energy by `1 + (ω*dt)²` each step: it can only lose energy, at any step length. The costs are a linear solve coupling all connected particles every step, and artificial damping that makes stiff things look soft and slow.
- How do you choose the substep count?From the fastest mode you must keep. Stability alone needs `ω_max * dt / n < 2`; for acceptable accuracy aim near 1 or below. For a fastest mode of 200 rad/s on a 1/60 s step, `ω_max * dt` is 3.33, so four substeps give 0.83. Apply substeps only to the stiff subsystem where possible, and cap the stiffness designers can set, because cost grows linearly with `n`.
Steering a car while glancing at the road only every few seconds: each correction is based on where you were, so you overshoot, and the swerves grow. Glance more often (substeps) or steer more gently (a softer spring).
- The rope explodes because of floating-point precision loss.
- A sign error in the spring force would explain a step-dependent blow-up.
- Adding damping always lets a stiff spring survive a longer step.
- Halving the step only halves the error; it cannot stop an explosion.
- Four substeps allow four times the spring stiffness.