Differentiable Airfoil Optimization with JAX
Use automatic differentiation to find the optimal airfoil shape via gradient descent
Last reviewed: March 2026Overview
Differentiable programming is transforming computational engineering. When every operation in a simulation is differentiable, automatic differentiation can compute exact gradients of any output quantity (lift, drag, structural weight) with respect to any design parameter (airfoil shape, wing twist, spar thickness) — without finite differences. This makes gradient-based optimization dramatically more powerful and efficient.
In this project, you'll implement a differentiable panel method solver in JAX — a Python framework from Google that combines NumPy-compatible arrays with automatic differentiation and JIT compilation. The solver computes the pressure distribution and integrated aerodynamic coefficients for an arbitrary airfoil shape represented by B-spline control points. JAX's grad() function then computes the full gradient of CL/CD with respect to all shape parameters in a single backward pass.
This project sits at the frontier of differentiable CFD — a field that is attracting major investment from Boeing, Airbus, and NASA as it enables end-to-end differentiable aircraft design workflows where ML and physics tightly couple. It requires solid understanding of both aerodynamics (panel methods, potential flow) and modern ML frameworks.
What You'll Learn
- ✓ Implement a 2D panel method (vortex panel or source-vortex) aerodynamics solver from scratch in pure NumPy, then JAX
- ✓ Understand JAX automatic differentiation: forward mode, reverse mode, and when to use each
- ✓ Parameterize airfoil geometry with B-spline control points for smooth, differentiable shape representation
- ✓ Perform gradient-based shape optimization using JAX gradients and scipy/optax optimizers
- ✓ Validate optimized airfoils against XFLR5 and published benchmark solutions
Step-by-Step Guide
Implement the Panel Method in NumPy
Start with a classical vortex panel method in plain NumPy before converting to JAX. Implement: panel geometry setup (normal vectors, control points), influence coefficient matrix assembly (Biot-Savart integrals), Kutta condition enforcement, and integration of surface pressures to get CL and CD.
Validate against XFoil results for NACA 0012 and NACA 2412 at multiple angles of attack. Your panel method won't be as accurate as XFoil (which uses a coupled inviscid/boundary-layer formulation), but should agree within 5% for CL and 20% for CD at low angles of attack.
Convert to JAX
Translate your NumPy solver to JAX: replace np with jnp, replace loops with JAX's vectorized operations (jax.vmap), and decorate the solver with @jax.jit for JIT compilation. The key constraint: all operations must be JAX-compatible (no Python control flow that depends on array values).
Verify that the JAX solver produces identical outputs to your NumPy reference. Then verify that JAX can differentiate through it: call jax.grad(solve_CL)(control_points) and check that the gradient is finite and physically reasonable.
B-Spline Geometry Parameterization
Represent the airfoil shape as a B-spline with ~20 control points. The B-spline evaluation (de Boor's algorithm) must also be implemented in JAX to maintain differentiability through the geometry generation step. The full computation graph is: control points → B-spline evaluation → panel geometry → aerodynamic solve → CL, CD.
Initialize the control points to match a NACA 2412 baseline. Verify that perturbing control points changes the airfoil shape smoothly — the B-spline parameterization prevents jagged, non-physical geometries.
Compute Shape Gradients
Use jax.grad to compute d(CL/CD) / d(control_points) — the gradient of lift-to-drag ratio with respect to all 20 B-spline control points simultaneously. This reverse-mode automatic differentiation computes all 20 gradients in roughly the same time as two forward evaluations, regardless of the number of design variables.
Visualize the gradients as arrows on the airfoil shape: each arrow shows which direction to move a control point to increase L/D. Does the gradient pattern make aerodynamic intuition sense? (More camber in the forward section typically increases CL.)
Run Gradient-Based Optimization
Use the computed gradients in an optimization loop. Try both gradient descent with Adam (using Optax, the JAX optimizer library) and L-BFGS-B via scipy (wrapping the JAX gradient function). Optimize for maximum CL/CD at a fixed angle of attack and Reynolds number.
Add constraints: minimum thickness at 30% chord (structural requirement), smooth leading-edge radius, and Kutta condition. Implement constraints as penalty terms added to the objective. Run for 500–2,000 iterations and plot the convergence history.
Analyze the Optimized Airfoil
Compare the optimized airfoil against the NACA 2412 baseline: plot both shapes, compare their polar curves (CL vs. CD), and calculate the percent improvement in L/D. Export the optimized airfoil coordinates and validate in XFLR5 to check that the panel method optimization translates to the higher-fidelity tool.
Discuss the limitations: the panel method is inviscid and ignores boundary layer effects, so the optimized shape may have unrealistically sharp features that viscous effects would penalize. This motivates connecting to higher-fidelity solvers for the final refinement stage.
Career Connection
See how this project connects to real aerospace careers.
Aerospace Engineer →
Differentiable aerodynamics and adjoint-based optimization are the frontier of aircraft design MDO — Boeing and Airbus use adjoint solvers for every major aircraft program
Space Operations →
Differentiable trajectory optimization is an active area for launch vehicle design and satellite maneuver planning, using the same JAX-based autodiff approach
Aerospace Manufacturing →
Differentiable process simulation enables gradient-based optimization of manufacturing parameters (cure cycles, layup sequences) that are otherwise tuned by trial and error
Astronaut →
Reentry vehicle shape optimization for aerocapture and precision landing uses differentiable aerodynamic solvers to find heat-shield shapes that balance drag and heating
Go Further
Extend toward research-grade differentiable CFD:
- Viscous correction — couple the inviscid panel method to an integral boundary-layer method (also implemented in JAX) to capture viscous drag and stall behavior in the optimization
- 3D adjoint — extend from 2D airfoil to 3D wing using a JAX-based vortex lattice method with gradient computation for span load and induced drag optimization
- Multi-point optimization — optimize for a weighted combination of L/D at multiple flight conditions (cruise + climb + approach) to avoid designs that are optimal at only one point
- Combine with PINN — replace the panel method with a physics-informed neural network flow solver that is both differentiable and more accurate than classical panel methods