Skip to main content
Version: 0.2.0

Airfoil geometry

Bora does not take airfoil coordinates. It takes 18 numbers that describe the shape, a Kulfan parameterization, also called CST for class-shape transformation (Kulfan, 2008). This is the shape description NeuralFoil's networks were trained on, so it is the only one they accept (Sharpe and Hansman, 2025).

pub struct KulfanParameters {
pub upper_weights: [f64; 8],
pub lower_weights: [f64; 8],
pub leading_edge_weight: f64,
pub te_thickness: f64,
}

The parameterization​

Each surface is a smooth curve from the leading edge at x=0x = 0 to the trailing edge at x=1x = 1. The upper surface is

yu(x)=x (1−x)⏟class function∑k=07wu,k Bk(x)  +  wLE  x (1−x)8.5  +  tTE2 x,y_u(x) = \underbrace{\sqrt{x}\,(1 - x)}_{\text{class function}} \sum_{k=0}^{7} w_{u,k}\, B_k(x) \;+\; w_{LE}\; x\,(1 - x)^{8.5} \;+\; \frac{t_{TE}}{2}\, x ,

and the lower surface yl(x)y_l(x) has the same form with its own weights wl,kw_{l,k} and the trailing-edge term subtracted instead of added. The BkB_k are the Bernstein polynomials of degree 7,

Bk(x)=(7k) xk(1−x)7−k.B_k(x) = \binom{7}{k}\, x^k (1 - x)^{7-k} .

Reading the terms from left to right:

  • The class function x(1−x)\sqrt{x}(1-x) gives every shape a round nose and a closed trailing edge.
  • The eight weights per surface scale eight overlapping bumps. Weight 0 acts near the leading edge and weight 7 near the trailing edge; the weight at the nose sets the leading-edge radius. Lower-surface weights are negative for a conventional section, and a symmetric section has wl,k=−wu,kw_{l,k} = -w_{u,k}.
  • The leading-edge weight wLEw_{LE} adds a mode concentrated in the first few percent of chord, which sharpens the fit near the nose. It applies to both surfaces with the same sign, so it shifts the nose up or down.
  • The trailing-edge thickness tTEt_{TE} is the gap between the surfaces at x=1x = 1, in chord lengths.
00.20.40.60.81.000.050.100.15x/cy/c for unit weight01234567leading-edge mode
The shape modes of one surface. Each solid curve is the surface that results from setting a single weight to one, numbered by weight; the dashed curve is the leading-edge mode. An airfoil surface is a weighted sum of these nine curves plus a linear trailing-edge thickness term.

Two properties make this a good basis for a surrogate. It is compact: studies of parameterization methods find that aerodynamic prediction error falls off sharply at about this many parameters (Masters et al., 2017). And it is linear in the weights, so fitting it to coordinates is a linear least-squares problem.

From coordinates to parameters​

fit_kulfan_parameters fits the 18 parameters to a list of points:

use bora::{Point2, fit_kulfan_parameters};

/// Reads a Selig-format coordinate file: an optional name line, then one
/// "x y" pair per line.
fn read_selig_dat(path: &str) -> std::io::Result<Vec<Point2>> {
let text = std::fs::read_to_string(path)?;
Ok(text
.lines()
.filter_map(|line| {
let mut fields = line.split_whitespace().map(str::parse::<f64>);
match (fields.next(), fields.next(), fields.next()) {
(Some(Ok(x)), Some(Ok(y)), None) => Some([x, y]),
_ => None, // name line or blank line
}
})
.collect())
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
let coordinates = read_selig_dat("my_airfoil.dat")?;
let kulfan = fit_kulfan_parameters(&coordinates)?;
println!("{kulfan:#?}");
Ok(())
}

The fit makes three assumptions about its input. It does not check them, and a violation gives a poor fit rather than an error.

  1. Selig ordering. Points run from the upper-surface trailing edge, forward around the leading edge, and back along the lower surface.
  2. Normalized chord. The leading edge is at (0,0)(0, 0) and the trailing edge at x=1x = 1. Bora does not translate, rotate or scale the points. This differs from AeroSandbox, which normalizes first, so normalize before calling if your coordinates are not already in this form.
  3. Enough points. At least 18 are required; real coordinate files have far more.

If the least-squares solution has a negative trailing-edge thickness, the fit is repeated with the thickness fixed at zero. The function returns Error::InvalidArgument for too few points and Error::SingularFit if the problem is degenerate.

:::warning Check the fit An 18-parameter curve cannot follow every shape. Sections with flat segments, sharp corners, cusps or deflected flaps are reproduced only approximately, and the network then analyzes the fitted shape, not yours. Regenerate coordinates from the fitted parameters and compare them with the originals before relying on the result. :::

From parameters to coordinates​

generate_kulfan_coordinates goes the other way, for plotting or for export to another tool:

use bora::generate_kulfan_coordinates;

// 100 points per surface, cosine-spaced, in Selig order: 199 points in all.
let coordinates = generate_kulfan_coordinates(&kulfan, 100)?;
for [x, y] in &coordinates {
println!("{x:.6} {y:.6}");
}

It returns 2 n - 1 points for n points per side, because the two surfaces share the leading-edge point. Both functions follow the corresponding routines in AeroSandbox (Sharpe, 2021), so parameters are interchangeable between Bora, NeuralFoil and AeroSandbox.