A wrong result does not have one cause. It may come from an implementation bug, unstable numerical method, incorrect input data, or an approximation used outside its range. Good scientific software helps you tell those failure modes apart instead of silently turning them into a smooth-looking plot.
| Symptom | First question | Likely next check |
|---|---|---|
| Result changes wildly when time step halves | Is the update method stable and converging? | Run a step-size sweep. |
| Units do not match | Was a value converted at the boundary? | Check quantity types and labels. |
| Test fixture passes but measurement disagrees | Does the fixture cover the operating range? | Inspect assumptions and input data. |
| Energy or probability drifts | Is the invariant actually preserved by this method? | Compare integrators and tolerances. |
const coarse = simulate({ step: 0.1 });
const fine = simulate({ step: 0.05 });
if (Math.abs(coarse.output - fine.output) > tolerance) {
warn("numerical result has not converged at this step size");
}
This does not prove the fine result is true. It tests a narrower claim: whether changing one numerical resolution parameter still changes the answer enough to matter. Record both values, the tolerance, and the measure being compared.
An error message can teach. “Mass must be positive” tells a reader which precondition was violated. “Explicit diffusion requires diffusivity × step ≤ 1/4” says why a visually exploding grid is not a surprising physical discovery. A chart should display missing data, invalid input, and uncertainty rather than interpolate over them without notice.
When a model fails physically, name the missing mechanism. A projectile model may need drag; a resistor model may need heating; a simple orbit may need another body. Replacing an equation without recording why loses the most useful part of the investigation.
Prediction: If an error is numerical rather than physical, refining a controlled numerical setting should change the result systematically.
Choose a time-step or grid-size model. Predict what should happen as resolution improves, run at three settings, and decide whether the evidence points first to numerical error or to an invalid physical assumption.Failure is information when it is labelled. Separate code, numerical, data, and approximation errors; add diagnostics; and revise the smallest layer that the evidence actually challenges.
Treat the lesson as a small function before treating it as a fact to memorize. Give every value a unit, keep only the state needed for the next step, and make the output easy to inspect.
\[\text{observable output} = f(\text{inputs},\,\text{state})\]For When Models Fail, write down the quantities you can control, the values your program must retain, and the result a reader could inspect. In Thinking Like a Computational Physicist, the useful program is not the drawing: it is the smallest explicit model that makes a prediction you can test.
Prediction: changing one declared input while holding the others fixed should change only the outputs that the model connects to that input. Choose one input, predict the direction of change, then check a limiting case such as zero, a symmetric arrangement, or a familiar low-speed or small-change approximation.
This lesson is a teaching model, not a complete simulator. Before using it outside the stated question, check which interactions, scales, uncertainties, boundary conditions, and measurement limits it leaves out.
Treat When Models Fail as a contract: named inputs and units enter a rule, the rule produces an observable result, and a known limit or invariant checks whether the implementation deserves trust.
Make validity ranges, residuals, counterexamples, and fallback explanations part of every model interface.