Foundations to Frontier
Tests

Simulation data and its challenges

Most scientific ML models are trained on simulation output rather than measurements. Simulations are a convenient source of labelled data, but they bring their own problems. Each run can cost hours of supercomputer time, so data sets are small and the choice of which runs to do matters. The numerical method adds its own error, which a model trained on it inherits. The simulator's physics may differ from reality (the sim-to-real gap). Outputs are large, sit on meshes and come in specialised formats. This page covers the simulation-data pipeline: design of experiments (grids, random and Latin hypercube sampling), solver accuracy versus cost, storage and formats, public benchmark data sets (PDEBench, The Well, WeatherBench 2), and closing the sim-to-real gap with a few real measurements. In the exercises you build a projectile simulator with air drag, train a polynomial surrogate of its range, and measure three effects. Surrogates trained on 36 coarse Euler runs were off by 0.92 m, against 0.14 m for the same number of RK4 runs, which also cost fewer function evaluations than fine Euler. With only 16 runs, a 4 × 4 grid gave 1.06 m error, random sampling 0.36 m (worst 1.74 m) and a Latin hypercube 0.23 m (worst 0.34 m). When the simulator's drag was 23% too low, the surrogate was off by 4.1 m against reality, and a linear correction fitted to five real measurements cut this to 0.66 m.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Learning from a computer game of the world

If real experiments are expensive, we can run a computer simulation many times and let a model learn from the results. But the simulation is only a copy of the world. It takes small time steps and makes small errors each time, and its rules may leave things out, such as how strong the wind really is. A model trained on it learns those mistakes too. Each run also takes time, so we must choose the runs carefully, spread out over all the situations we care about. The demo shows how a simulation’s error depends on its step size.

Scientific ML lab
Fall with drag over 5 s in 50 steps: explicit Euler error 2.0e-1 m, RK4 error 1.1e-5 m. A surrogate trained on simulated data inherits this error; halving the step halves Euler's error (first order) but cuts RK4's by 16.
Why engineers care

Aircraft makers run thousands of computational fluid dynamics (CFD) simulations, each taking hours, to build the aerodynamic databases behind flight simulators, and still check them against wind-tunnel and flight-test data.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A model trained on simulation data inherits…
  2. 2. The difference between a simulator and the real world is called…
  3. 3. Because each simulation is expensive, we should…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Where the data come from: a solver (finite differences, finite volumes, finite elements, spectral methods, particle methods; A8) run over a set of input parameters, initial and boundary conditions. Labels are free, but runs are expensive and outputs large.
  • Errors in simulation data:
    • Discretisation error: from time steps and mesh size, of order hᵖ for a method of order p.
    • Model-form error: physics left out or simplified (turbulence closures, unknown drag), the main source of the sim-to-real gap.
    • Solver noise and non-convergence: iterative solvers stopped at a tolerance; chaotic systems amplify tiny differences.
  • Design of experiments: a full grid needs Lᵈ runs for L levels in d inputs and repeats each input value many times. Random sampling leaves gaps and clusters. Latin hypercube sampling (McKay, Beckman and Conover, 1979) puts exactly one point in each of n slices of every input; Sobol’ and Halton sequences are low-discrepancy alternatives.
  • Formats and scale: HDF5, NetCDF and Zarr for gridded arrays; VTK and Exodus for unstructured meshes. Benchmarks: PDEBench (Takamoto et al., 2022), The Well (Ohana et al., 2024, about 15 TB across 16 data sets), AirfRANS (Bonnet et al., 2022) for airfoils, WeatherBench 2 (Rasp et al., 2024).
  • Closing the gap: calibrate simulator parameters against measurements, correct the surrogate with a few real points, randomise uncertain parameters during training (domain randomisation), or combine fidelities (J5-5).
📝 Quick check (Level 1)
0/3 answered
  1. 1. Latin hypercube sampling guarantees…
  2. 2. Error from the time step or mesh size is…
  3. 3. A format for large gridded scientific arrays:

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Building a simulation data set

Exercise 1.

  • A vectorised projectile simulator with quadratic drag, explicit Euler or RK4, with landing-point interpolation.
  • Latin hypercube and grid designs.
  • The minimum pairwise distance of a design as a space-filling measure.

Practice.

  • Run a convergence study first: halve the step or refine the mesh until the quantity you will learn changes by much less than the accuracy you need.
  • Use space-filling designs (Latin hypercube, Sobol’) for the first batch; add runs where the surrogate is uncertain later (active learning, J5-1).
  • Log everything: solver version, mesh, tolerances, inputs, random seeds, run time and failures. Failed or non-converged runs are data too; do not silently drop them.
  • Store as chunked arrays (Zarr or HDF5) with metadata; keep the simulator’s own units and normalise in the data loader.
  • Keep a few real measurements for validation; a surrogate can only be as close to reality as its simulator.
  • Tools: scipy.stats.qmc (LatinHypercube, Sobol), SALib for sensitivity analysis, xarray with Zarr, h5py, meshio for mesh formats.
from scipy.stats import qmc
import numpy as np

sampler = qmc.LatinHypercube(d=2, seed=0)
U = sampler.random(n=64)                                  # 64 runs in [0, 1]^2
X = qmc.scale(U, l_bounds=[15, 10], u_bounds=[75, 40])    # angle (deg), speed (m/s)
print(qmc.discrepancy(U))                                 # lower = more uniform
# run the simulator on each row of X, store inputs and outputs with xarray.to_zarr(...)
🐍 Exercise 1: a simulator and two designs
Write a vectorised projectile simulator with drag (Euler or RK4), Latin hypercube and grid designs, and a space-filling measure; check the simulator against the drag-free range formula.
📝 Quick check (Level 2)
0/3 answered
  1. 1. scipy's module for Latin hypercube and Sobol' designs:
  2. 2. Before generating training data, run…
  3. 3. Failed simulation runs should be…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

The surrogate’s error budget. If the surrogate ŝ is trained on simulator outputs s_h (step h) of a reality r, then ‖ŝ − r‖ ≤ ‖ŝ − s_h‖ + ‖s_h − s‖ + ‖s − r‖: learning error, discretisation error O(hᵖ) and model-form error. Better learning cannot remove the last two. In the exercise, the coarse-Euler surrogate’s 0.92 m error was mostly the solver’s own bias, and against reality the 4.1 m model-form error dominated everything else.

Cost and order. For a fixed accuracy ε, a method of order p needs about ε^(−1/p) steps. RK4 costs four function evaluations per step but needs far fewer steps; in the exercise RK4 with h = 0.1 was both cheaper (216 against 268 evaluations) and more accurate than Euler with h = 0.02.

Why the grid failed. A 4 × 4 grid has only four distinct values of each input. A degree-4 polynomial needs five distinct values in each variable to determine its x⁴ term; with four, that term is confounded with lower powers and the fit depends on the regulariser. A Latin hypercube of the same size has sixteen distinct values per input. Grids also waste runs when some inputs barely matter, because each value of the important input is repeated.

Correcting a biased simulator. If reality is close to an affine function of the simulator, r ≈ a + b·s, a few real points fix a and b. Here the true drag was 30% higher, so ranges were about 15% shorter; the fitted slope was 0.865. The correction leaves the part of the gap that is not affine, 0.66 m. More flexible corrections need more real data, which is the idea behind multi-fidelity modelling (J5-5).

📝 Quick check (Level 3)
0/3 answered
  1. 1. Better learning cannot remove…
  2. 2. A degree-4 term in one input needs at least…
  3. 3. For accuracy ε, a method of order p needs about…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

Which matters most for a simulation-trained surrogate: the solver, the design or the simulator’s physics?

History.

  • M. McKay, R. Beckman and W. Conover (1979) introduced Latin hypercube sampling for computer experiments; J. Sacks, W. Welch, T. Mitchell and H. Wynn (1989), “Design and analysis of computer experiments”, started the field of surrogate modelling with Gaussian processes.
  • M. Kennedy and A. O’Hagan (2001), “Bayesian calibration of computer models”, introduced the model-discrepancy term for the sim-to-real gap.
  • Domain randomisation (Tobin et al., 2017) made training on randomised simulators standard in robotics.
  • Large public data sets for SciML appeared from 2022: PDEBench (Takamoto et al., 2022), AirfRANS (Bonnet et al., 2022), WeatherBench 2 (Rasp et al., 2024) and The Well (Ohana et al., 2024).

Exercise 2. Range of a projectile with quadratic drag (k = 0.01 per metre in the simulator) for launch angles 15–75° and speeds 10–40 m/s; the surrogate is a degree-4 polynomial in the two inputs (15 terms) fitted by ridge regression; error is RMSE in metres on 300 test points against a fine RK4 reference.

36 Latin-hypercube runs from… surrogate RMSE (m) evaluations per run
Euler, h = 0.1 s 0.92 54
Euler, h = 0.02 s 0.242 268
RK4, h = 0.1 s 0.142 216
16 runs placed by… median RMSE worst of 10
4 × 4 grid 1.057 1.057
random 0.361 1.741
Latin hypercube 0.225 0.343
simulator drag 0.010, reality 0.013 RMSE (m)
surrogate against the simulator 0.111
surrogate against reality 4.144
after an affine correction from 5 real runs (slope 0.865) 0.66
  • A surrogate is never better than its data. Coarse Euler data limited the surrogate to 0.92 m error; RK4 data at a fifth of Euler’s fine-step cost reached 0.14 m.
  • Placement matters as much as count. The grid was the worst design: only four distinct values per input cannot pin down a degree-4 model. Random designs were sometimes good and sometimes bad; the Latin hypercube was good every time.
  • The sim-to-real gap dominated. A 30% error in one physical constant made the surrogate 37 times worse against reality than against its own simulator. Five real measurements fixed most of it but not all.
  • Seeds 1 and 2: RK4-data surrogate 0.092 and 0.115 m; Latin hypercube worst case 1.406 and 0.596 m (one bad draw on seed 1, still better than random’s 1.813 and 1.829); corrected error against reality 0.799 and 0.692 m.
🐍 Exercise 2 (research): which matters most for a simulation-trained surrogate: the solver, the design or the simulator's physics?
Train polynomial surrogates of a drag-affected projectile's range on data from different solvers, different 16-run designs and a simulator with the wrong drag, and measure each effect on the error.

Simulation data in AI, robotics and aerospace

  • Aerodynamic databases: CFD runs over Mach, angle of attack and sideslip, chosen by design-of-experiments methods and corrected with wind-tunnel data, feed flight simulators and control design.
  • Robot learning: policies trained in simulators (Isaac Lab, MuJoCo) with randomised friction, mass and latency transfer to real robots; the remaining gap is closed with a little real data.
  • Earth system models: reanalyses such as ERA5 are themselves model output constrained by observations; learned weather models inherit their biases (J8).
  • Spacecraft thermal and structural design: surrogates of finite-element models speed up trade studies, with test campaigns as the real data.

References

  1. M. D. McKay, R. J. Beckman and W. J. Conover (1979). “A comparison of three methods for selecting values of input variables in the analysis of output from a computer code.” Technometrics.
  2. J. Sacks, W. J. Welch, T. J. Mitchell and H. P. Wynn (1989). “Design and analysis of computer experiments.” Statistical Science.
  3. M. C. Kennedy and A. O’Hagan (2001). “Bayesian calibration of computer models.” JRSS B.
  4. M. Takamoto et al. (2022). “PDEBench: an extensive benchmark for scientific machine learning.” NeurIPS Datasets and Benchmarks.
  5. R. Ohana et al. (2024). “The Well: a large-scale collection of diverse physics simulations for machine learning.” NeurIPS Datasets and Benchmarks.
  6. J. Tobin et al. (2017). “Domain randomization for transferring deep neural networks from simulation to the real world.” IROS.