Solution Verification
Theory: three errors in a numerical solution
Overview
Refining the grid to get the convergence order, I got first order or even negative instead of the expected second. Is the scheme broken?
Suspect iterative convergence before the scheme. Besides discretisation error from the grid, a numerical solution carries iterative error from stopping iterations early and round-off from finite precision. Refining reduces discretisation error, but with an unchanged tolerance iterative error doesn't shrink and may even grow. Once iterative error rivals discretisation error, observed orders scatter. Solution verification separates the three and estimates discretisation error alone.
Error decomposition
Estimating discretisation error by grid comparison presupposes that iterative and round-off errors are small enough.
The example problem
Solved with second-order central differences; observed order $p_{obs}$ follows from the error ratio when spacing is halved and should approach 2 if all is well.
Separating verification from validation
Until the 1990s, discussions of computational credibility often confused whether a calculation solves its equations correctly (verification) with whether the equations represent reality (validation). In his 1998 book Roache separated the two clearly and further split verification into code verification, checking the program, and solution verification, estimating the error of individual calculations. This framework later became the backbone of the ASME V&V standards. Without first grasping numerical error through solution verification, a difference against experiment can't be attributed to the model or the numerics.
Worked examples
Example 1: effect of iterative tolerance
Using Gauss–Seidel, the stopping criterion (residual reduction relative to initial) was varied, and maximum error and observed order were found under refinement:
| Tolerance | 10 cells | 20 cells (order) | 40 cells (order) | 80 cells (order) |
|---|---|---|---|---|
| 10⁻³ | 7.3×10⁻³ | 1.1×10⁻³ (2.77) | 4.8×10⁻⁴ (1.16) | 8.7×10⁻⁴ (−0.85) |
| 10⁻⁶ | 8.3×10⁻³ | 2.1×10⁻³ (2.01) | 5.1×10⁻⁴ (2.00) | 1.3×10⁻⁴ (2.01) |
| 10⁻¹⁰ | 8.3×10⁻³ | 2.1×10⁻³ (2.01) | 5.1×10⁻⁴ (2.00) | 1.3×10⁻⁴ (2.00) |
Converging the 80-cell case to 10⁻⁶ took about 9,000 iterations, and to 10⁻¹⁰ about 15,000. Finer grids need more iterations to reach the same tolerance.
Example 2: single-precision round-off
| Cells | Double-precision error | Single-precision error |
|---|---|---|
| 40 | 5.1×10⁻⁴ | 5.1×10⁻⁴ |
| 160 | 3.2×10⁻⁵ | 3.7×10⁻⁵ |
| 640 | 2.0×10⁻⁶ | 1.5×10⁻⁴ |
| 2,560 | 1.3×10⁻⁷ | 3.6×10⁻³ |
| 10,240 | 7.9×10⁻⁹ | 0.45 |
In single precision, error grows as the grid gets finer!
Refining multiplies subtractions of nearly equal values in the difference formulas, each losing significant digits. Single precision carries only about seven digits, so beyond a certain fineness round-off overtakes discretisation error. Double precision, with about sixteen digits, was fine to far finer grids here. Practical CFD and structural codes default to double, but beware when using single precision on GPUs for speed. If refining doesn't improve — or worsens — results, suspect round-off.
Solution verification workflow
- Check convergence by both residuals and change in quantities of interest (drag, temperature).
- Tighten the tolerance by an order of magnitude and confirm results don't change, estimating iterative error.
- Estimate discretisation error with GCI or similar on three or more grids.
- For transients, vary the time step similarly.
- Compute in double precision and confirm round-off doesn't matter.
“Worse results on finer grids”
In a thermal-fluid grid study, results settled up to the medium grid but jumped on the finest. The finest grid had been stopped after the same wall-clock time without more iterations, so residuals hadn't dropped enough. Continuing to lower residuals by two orders brought the finest result into line. The rule in grid studies: confirm iterations have converged on each grid before comparing.
Common mistakes
Mistakes and fixes
| Mistake | Effect | Fix |
|---|---|---|
| Same iteration count per grid | Fine grids unconverged | Judge by residuals |
| Residuals alone | Quantities not settled | Monitor quantities too |
| Single precision on fine grids | Round-off degrades results | Double precision |
| Judging from two grids | Order unconfirmed | Three or more levels |
| Fixed time step | Temporal error remains | Vary the time step |
I'd like to learn related topics.
Try orders with the Richardson extrapolation tool. Related pages include Roache's GCI, three-grid GCI, code verification, the method of manufactured solutions and ASME V&V 20.
Related Topics
Experience the theory firsthand with the interactive simulator for this field
All Simulators