Is the training data right?

A surrogate learns the solver’s errors too: mesh convergence, failed runs and outliers are checked before training.

Outcome: Check that training runs are mesh-independent and converged; find failed and outlier runs before they reach the model; compare the surrogate’s error with the solver’s own error in one budget.

Builds on Sampling the design space

Later lessons compare the surrogate with the solver and treat the solver as the truth. The solver is a numerical approximation of a physical model, which is itself an approximation of reality, so the runs need checking before training.

DefinitionVerification and validation

Verification asks whether the equations are solved accurately (code, mesh, time step, iterations); validation, how well the results match measurements.

Convergence of each run

Mesh independence. A few representative designs are run on three meshes, each refined by the same ratio, and the quantities of interest are tracked. If they still move between the medium and the fine mesh, the dataset will teach the surrogate a mesh error.

Richardson extrapolation estimates the mesh-independent value, and the grid convergence index (GCI, Roache 1994) turns the change into an error band for the fine mesh; Celik et al. 2008 give the three-mesh procedure of the Journal of Fluids Engineering. The band is most trustworthy when each change is smaller than the last, in the same direction, and the observed order of accuracy is close to the scheme’s; if not, that should be reported too. Celik et al. call a refinement ratio above 1.3 desirable, from experience; a ratio of 2 in 3D means eight times the cells at each level.

In LES (large-eddy simulation) the filter usually follows the mesh, so refining also changes the model: a mesh study does not carry over as it stands (Pope 2004). Crash models with element failure have a related limit: in LS-DYNA’s GISSMO, for example, failure strain is a function of element size, so the calibration has to cover every mesh in the study. Meshes for RANS (Reynolds-averaged Navier–Stokes, a common industrial CFD method, which models turbulence on average) with standard wall functions have one too: on every mesh the first cell should stay in the log layer they assume, usually y+y^+ (a scaled wall distance) of about 30 to 300.

Iterative convergence. For each run of a solver that iterates, the residuals (how far the solver’s equations still are from being satisfied) should have dropped far enough: usually several orders of magnitude in CFD, below the solver’s force tolerance in implicit FE. More importantly, the monitored forces should have stopped drifting. Runs that never settle may be physically unsteady (vortex shedding behind a flagpole, or buffet, the shaking from separated flow), and a steady-state value for them is an arbitrary snapshot.

Explicit and transient runs. Explicit crash solvers do not iterate within a step, so there are no residuals to read. The checks are the energy balance, and that the artificial terms stay small: Radioss guidance, for example, asks for hourglass energy under 10 % of total energy and added mass under 1 % per part. Transient CFD also needs a time-step check, and averages that drop the start-up and cover a long enough window.

Quiet failures

In a batch of hundreds of runs, a few often go wrong: a bad mesh, a diverged solution, a setup typo, a different solver version. Some crash; others finish normally and come out wrong. Outliers appear in a plot of each integrated quantity against each input, and in a comparison of every run with a smooth fit through all the others. A run far from its neighbours may be a real physical change, to understand; real scatter, such as a crash run that folds differently, to keep; or an error, to fix or drop.

Every run should use the same setup: the same turbulence model, boundary conditions (what is imposed at the inlet, outlet and walls), reference values and post-processing.

Example 2-4. Mesh independence and outliers, with NumPy
import numpy as np
from aircraft import load_runs

# Mesh independence: drag coefficient on three meshes,
# each refined by r = 2 in every direction.
f3, f2, f1 = 0.02910, 0.02840, 0.02820  # coarse, medium, fine
r = 2.0
# Observed order, Richardson extrapolation, and the GCI of
# the fine mesh. Most reliable if each change is smaller than
# the last, in the same direction, and p is close to the
# scheme's order.
p = np.log((f3 - f2) / (f2 - f1)) / np.log(r)1
f_exact = f1 + (f1 - f2) / (r ** p - 1)2
gci = 1.25 * abs((f2 - f1) / f1) / (r ** p - 1)3
print(f"order {p:.2f}, extrapolated CD {f_exact:.5f},"
      f" GCI {gci:.2%}")

# Outliers: compare each run's lift with a quadratic fit in
# alpha and sweep through all the others (leave one out),
# over the 44 runs of the Latin hypercube.
d = load_runs()
lhs = d["split"] < 2
a, s = d["alpha"][lhs], d["sweep"][lhs]
cl = d["CL"][lhs]
A = np.column_stack([np.ones_like(a), a, s,
                     a * a, a * s, s * s])
res = np.empty(len(cl))
for i in range(len(cl)):
    keep = np.arange(len(cl)) != i
    w = np.linalg.lstsq(A[keep], cl[keep], rcond=None)[0]4
    res[i] = cl[i] - A[i] @ w
# A robust spread: 1.4826 x the median absolute deviation.
sigma = 1.4826 * np.median(np.abs(res - np.median(res)))
print(f"spread {sigma:.4f}")
print("outliers:", np.flatnonzero(np.abs(res) > 5 * sigma))5
  1. The observed order of accuracy pp: with a constant ratio rr, successive changes shrink by rpr^p, so (f3−f2)/(f2−f1)=rp(f_3 - f_2)/(f_2 - f_1) = r^p.
  2. Richardson extrapolation: the fine-mesh value plus the change still expected as the cells shrink to zero.
  3. The GCI of the fine mesh, with the safety factor of 1.25 that Celik et al. use in their three-mesh procedure.
  4. Each run is compared with a quadratic fit in α\alpha and Λ\Lambda (six weights) through all the others, so an outlier cannot pull the fit towards itself. np.linalg.lstsq solves the least-squares problem directly.
  5. Runs more than five robust standard deviations from their fit are flagged.
order 1.81, extrapolated CD 0.02812, GCI 0.35%
spread 0.0008
outliers: [38]

For its three drag values, which are illustrative, Example 2-4 prints an observed order of 1.81 and a GCI of 0.35 % for the fine mesh. On the real runs it prints a spread of 0.0008 in CLC_L and one flagged run, 38. Run 38 sits in a corner of the box (α\alpha 7.8°, Λ\Lambda 35.8°), where the fit through the others has to extrapolate. A flag is a reason to look at the run, not to drop it.

The size of each error

The error that matters to the design has two parts: the surrogate’s error against the solver and the solver’s error against reality. Both should be quantified before tuning the surrogate. Solver-against-test error comes from validation cases (wind tunnel, rig or flight data); mesh error from the GCI; surrogate error from held-out runs (see measuring error).

An illustrative case: a RANS model gives the drag of a family of shapes about 5 % away from the wind tunnel. The surrogate adds its own error on top, say 1 % against the solver. For the absolute drag, next to the solver’s 5 %, halving the surrogate’s error to 0.5 % changes almost nothing; better physics, or calibrating against the tunnel, can. To compare similar designs the balance can reverse: part of the solver’s bias cancels in the difference, so the surrogate’s error must be small against that difference. Outside the training range the surrogate’s error is often the larger one anyway.

The course’s own solver (physical fields) has no iterations to converge, but it is inviscid and has no stall: every error quoted for its aircraft is against that idealised solver.