ML Surrogate Model for XFLR5

Replace a CFD solver with a neural network that runs 1000× faster

Advanced Aerodynamics 5–8 weeks
Last reviewed: March 2026

Overview

High-fidelity aerodynamic simulation is accurate but slow. An XFLR5 analysis of a single airfoil at multiple angles of attack takes seconds to minutes — and design optimization requires thousands of evaluations. Surrogate modeling replaces the expensive simulator with a fast ML approximation trained on simulation data, enabling optimization workflows that would otherwise be computationally intractable.

In this project, you'll parameterize airfoil geometry using NACA four-digit series and B-spline control points, run a systematic design-of-experiments sweep through XFLR5 (scripted via Python's subprocess module), and train a neural network to map geometry parameters and flight conditions directly to lift coefficient (CL), drag coefficient (CD), and moment coefficient (CM).

This workflow — high-fidelity simulation → dataset generation → surrogate training → optimization — is used throughout the aerospace industry for everything from airfoil design to full aircraft MDO (multidisciplinary design optimization). Companies like Boeing, Airbus, and NASA use surrogate models to make optimization tractable at every scale.

What You'll Learn

  • Parameterize airfoil geometry systematically using NACA series and B-spline representations
  • Script XFLR5 runs from Python to generate large simulation datasets automatically
  • Design and execute a space-filling design-of-experiments (Latin Hypercube Sampling)
  • Train and validate neural network surrogate models for aerodynamic coefficients
  • Quantify surrogate accuracy and identify regions of the design space requiring more data

Step-by-Step Guide

1

Define the Parameterization

Choose a geometry parameterization that covers a useful design space. Start with NACA 4-digit series: maximum camber (m: 0–9%), camber position (p: 1–9), and thickness (t: 6–24%). This gives a 3-parameter space covering most practical subsonic airfoils.

Generate airfoil coordinate files programmatically using the NACA 4-digit analytic equations. Write a Python function naca4(m, p, t, n_points=200) that returns (x, y) coordinate arrays — you'll call this thousands of times.

2

Design the Experiment

Use Latin Hypercube Sampling (scipy.stats.qmc.LatinHypercube) to generate 2,000 design points spanning the parameter space. LHS ensures better coverage than random sampling — each parameter's range is uniformly covered with no clustering.

Add flight condition parameters: Reynolds number (Re: 100k–1M) and angle of attack (α: -5° to 15°). Your full input vector is [m, p, t, Re, α] → [CL, CD, CM]. Plan for roughly 10,000 total XFLR5 runs (2,000 geometries × 5 angles each).

3

Automate XFLR5 Batch Runs

XFLR5 supports batch operation through its XML project file format. Write a Python script that: generates the airfoil coordinate file, creates an XFLR5 batch analysis XML, calls XFLR5 from the command line, waits for completion, and parses the output polar file to extract CL, CD, CM.

Run at overnight scale — 10,000 analyses at ~2 seconds each takes roughly 6 hours. Use Python's multiprocessing module to parallelize across CPU cores and cut this to 1–2 hours.

4

Clean and Explore the Dataset

XFLR5 simulations sometimes fail to converge, especially at high angles of attack or very thin airfoils. Remove failed runs (missing output files, NaN values, or physically unreasonable results: CL/CD > 200). Typical failure rate is 5–15% of runs.

Explore the dataset: plot CL vs. α colored by thickness, CD vs. Re, and the CL/CD ratio surface across the design space. These plots reveal the structure the surrogate must learn.

5

Train the Surrogate Model

Split the dataset 80/10/10 (train/validation/test). Train a fully-connected neural network with 5 inputs, 3 outputs, and 4–6 hidden layers of 128–256 neurons. Use ReLU activations and Adam optimizer. Predict CL, CD, CM simultaneously with a single multi-output network.

Monitor validation loss carefully — aerodynamic data has smooth structure, so overfitting is uncommon, but convergence is sensitive to learning rate. Try a cosine annealing schedule. Target R² > 0.99 for CL and > 0.97 for CD on the test set.

6

Validate and Deploy for Optimization

Validate the surrogate on held-out test points and on a set of known reference airfoils (NACA 2412, 4415, 0012). Plot predicted vs. actual polar curves — the surrogate should accurately reproduce the shape of CL vs. α, including the linear region and stall onset.

Finally, use the surrogate in an optimization loop: use scipy.optimize to maximize CL/CD at a target CL = 0.8 and Re = 500,000. The surrogate evaluates in microseconds — you can run 100,000 optimization evaluations in seconds, finding optimal geometries that would take weeks with the full XFLR5 solver.

Go Further

Extend this project toward research publication:

  • Active learning — instead of a fixed LHS dataset, iteratively add new simulations in regions where the surrogate uncertainty is highest, achieving the same accuracy with 5–10× fewer simulations
  • Gaussian Process surrogate — replace the neural network with a GP, which provides uncertainty quantification (error bars on predictions) that is essential for robust optimization
  • Full wing surrogate — extend from 2D airfoil to 3D wing by adding span, taper ratio, and sweep parameters; use XFLR5's 3D vortex lattice solver
  • Publish — surrogate-based aerodynamic optimization papers are well-received at AIAA Aviation and ASC conferences