Compressing fields: POD

A field is often a few dominant shapes plus small corrections: predict the shapes’ weights instead of every value.

Outcome: Build a snapshot matrix and find its modes with PCA (POD); read the energy captured by each mode; predict a whole field by regressing a few mode coefficients.

Builds on Gaussian processes, From runs to arrays

A pressure field has thousands of values, but across a family of designs they tend to move together. The field of each training run, on a shared mesh, is one row of a snapshot matrix of shape (runs × points), as in from runs to arrays, from which the mean field is subtracted.

Proper orthogonal decomposition (POD; Taira et al. 2017 give an overview for fluid flows) then finds the modes.

DefinitionModes

The shapes that best describe how the runs differ from the mean. The first mode captures as much of the variation as any single shape can, the second as much of the rest, and so on. The variation a mode captures is its energy, usually quoted as a share of the total.

The computation is the singular value decomposition; statistics calls the same result principal component analysis (PCA).

Each field is then approximated by the mean field plus a weighted sum of a few modes.

y(x)≈yˉ(x)+∑k=1Kak ϕk(x)y(x) \approx \bar{y}(x) + \sum_{k=1}^{K} a_k \, \phi_k(x)
(3-5)
xx: here a point of the surface, not a design. yˉ\bar{y}: the mean field. ϕk\phi_k: the kk-th of KK modes, a field (in regression, ϕ\phi was the list of features). aka_k: one number per run, its coefficient.

Figure 3-3 shows the chordwise pressure distributions at 40 % span of the site’s 36 training runs, decomposed in the browser.

-10100.51x/c (chord)−Cp, modes × typical size
mean of 36 training runsmode 1mode 2

The mean chordwise pressure and the first two POD modes, each scaled to a typical size.

-101200.51x/c (chord)−Cp
solvermean + 1 mode−Cp vs x/c, 40% span

A test design rebuilt from the mean plus the modes kept, using its true coefficients. 1 mode captures 97.1 % of the variation of the training runs: 1 number per design instead of 67, relative L2 error 8.8 %.

Figure 3-3. POD of the chordwise CpC_p at 40 % span of the 36 training runs, and a test design rebuilt from a few modes.

The first mode captures 97.1 % of the variation and follows the angle of attack: it is mostly the suction peak growing and shrinking. With the second mode the total reaches 100.0 %, and two modes rebuild each test design almost exactly.

That is a property of this solver, which takes each wing section’s pressure from one 2D table indexed by the local lift. RANS fields with separation or shocks usually need many more modes for the same accuracy.

From modes to a surrogate

Each run is now KK coefficients instead of thousands of values. A POD surrogate regresses those KK coefficients on the design inputs, with a Gaussian process or a polynomial, then rebuilds the field from them. It is a non-intrusive reduced-order model: it does not project the governing equations onto the modes, as Galerkin models do. Field prediction becomes a handful of scalar predictions.

Requirements of POD

Every snapshot must sit on the same points in the same order, so a new mesh is interpolated first; the graph and transformer models of later units avoid this.

On a non-uniform mesh, each column of the snapshot matrix is multiplied by ai\sqrt{a_i}, where aia_i is the area or volume point ii stands for (the weight of Equation 3-3, not a mode coefficient), before the modes are found. Every field rebuilt from them is divided by ai\sqrt{a_i} to return to physical units (the modes too, for plotting). Otherwise the refined regions dominate the modes, as in measuring error. Example 3-5 leaves this weighting out and finds the modes of the plain snapshots, although the aircraft’s point areas span about three orders of magnitude.

POD is also linear: a feature that moves from run to run, such as a shock or a separation line, needs many modes. Learned nonlinear compressions aim to address this. They are the latent spaces of later units, with POD as their linear ancestor.

Example 3-5 builds a POD surrogate of the aircraft’s surface CpC_p: four modes of the 36 training fields, and a GP on their coefficients. It goes into aircraft.py as pod_baseline, a baseline for the models of later units.

Example 3-5. A POD surrogate of the surface pressure: modes, then a GP on their coefficients, with scikit-learn
# Add to aircraft.py, with its other imports at the top:
from sklearn.decomposition import PCA
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.gaussian_process.kernels import RBF, WhiteKernel

def pod_baseline(d, train, n_modes=4):
    """POD of the training fields, then a GP on the mode
    coefficients: a predicted Cp field for every run."""
    X = np.column_stack([d["alpha"], d["sweep"]])
    Y = d["cp"][train]
    pca = PCA(n_components=n_modes, svd_solver="full").fit(Y)1
    kernel = RBF([3.0, 10.0]) + WhiteKernel(1e-4)
    gp = GaussianProcessRegressor(kernel=kernel,
                                  normalize_y=True)
    gp.fit(X[train], pca.transform(Y))2
    Z = gp.predict(X).reshape(len(X), n_modes)
    return pca.inverse_transform(Z), pca3

# Then, in a script:
from aircraft import load_runs, pod_baseline, scores, split_runs

d = load_runs()
train, val, test, in_box = split_runs(d)
pred, pca = pod_baseline(d, train)
# Energy captured by the first 1, 2, 3 and 4 modes.
print(pca.explained_variance_ratio_.cumsum().round(5))4
s = scores(pred[val], d, val)
print(f"relative L2 on validation runs: {s['rel_L2']:.1%}")
  1. PCA subtracts the mean field yˉ\bar{y} of the training runs itself, then finds the modes ϕk\phi_k of Equation 3-5 with a singular value decomposition, from the training runs only. svd_solver="full" asks for the exact decomposition; on a matrix this size the default picks a randomized one, whose last digits change from run to run.
  2. transform projects each centred training field onto the modes: the coefficients aka_k, four per run. scikit-learn fits them with one GP and one shared kernel.
  3. reshape keeps two axes even with a single mode; inverse_transform rebuilds yˉ+∑kakϕk\bar{y} + \sum_k a_k \phi_k from the predicted coefficients, for every run.
  4. explained_variance_ratio_ is each mode’s energy as a share of the total; the cumulative sum is the share captured by the first 1, 2, 3 and 4 modes.

Example 3-5 prints the cumulative shares of the energy, [0.97381 0.99879 0.99996 0.99999] and a relative L2 error of 0.2 % on the 8 validation runs, against 21 % for the mean field of Example 3-3. A first surrogate, end to end compares it with a neural network.