Skip to main content
Version: 0.2.0

Inputs and outputs

An analysis maps one AeroInput to one AeroOutput. This page lists every field, its units and its sensible range.

Inputs​

pub struct AeroInput {
pub kulfan: KulfanParameters,
pub alpha: f64,
pub re: f64,
pub n_crit: f64,
pub xtr_upper: f64,
pub xtr_lower: f64,
}
FieldMeaningUnitsDefault
kulfanAirfoil shape, see Airfoil geometrychord lengthsall zero
alphaAngle of attackdegrees0
reReynolds number based on chordnone10⁶
n_critCritical amplification factor of the eNe^N transition modelnone9
xtr_upperForced transition location, upper surfacefraction of chord1
xtr_lowerForced transition location, lower surfacefraction of chord1

AeroInput::default() gives the defaults in the last column. The default shape is a flat plate of zero thickness, which is not a useful airfoil, so always set kulfan.

Transition. n_crit has the meaning it has in XFoil: 9 is a clean wind tunnel or free flight, lower values model a more turbulent freestream and trip the boundary layer earlier. A forced transition location of 1 means free transition; any smaller value trips the boundary layer no later than that station, as a transition strip would.

Mach number. There is no Mach input. The model is incompressible.

The range the model knows​

NeuralFoil was trained on XFoil runs drawn from the distributions below (Sharpe and Hansman, 2025). Inside them the network interpolates; outside them it extrapolates, and the analysis confidence falls.

InputTraining distribution
Angle of attackMiddle 95% between −17° and +18°; extremes near ±28°
Reynolds numberMiddle 95% between about 2 × 10³ and 3 × 10⁸; median 3 × 10⁵
n_critUniform between 0 and 18
Forced transitionFree in 80% of cases; otherwise uniform between 0 and 1
ShapeBlends of about 2,000 existing airfoils, with thickness scaling and random perturbation

Outputs​

pub struct AeroOutput {
pub analysis_confidence: f64,
pub cl: f64,
pub cd: f64,
pub cm: f64,
pub top_xtr: f64,
pub bot_xtr: f64,
pub upper: BoundaryLayerData,
pub lower: BoundaryLayerData,
}
FieldMeaningRange
clLift coefficient
cdDrag coefficientAlways positive
cmMoment coefficient about the quarter chord, nose-up positive
top_xtr, bot_xtrTransition location on the upper and lower surface0 to 1; 1 means laminar to the trailing edge
analysis_confidenceThe model's confidence in this result0 to 1
upper, lowerBoundary-layer distributionsSee below

Boundary layer​

Each surface carries three distributions sampled at NUM_BL_POINTS = 32 stations:

pub struct BoundaryLayerData {
pub theta: [f64; 32], // momentum thickness / chord
pub h: [f64; 32], // shape factor
pub ue_over_vinf: [f64; 32], // edge velocity / freestream velocity
}

The stations are the midpoints of 32 equal intervals of chord, so the first is at x/c=1/64x/c = 1/64 and the last at 63/6463/64. bl_x_points() returns them:

use bora::{NUM_BL_POINTS, bl_x_points};

let aero = model.analyze(&input);
let x = bl_x_points();
for i in (0..NUM_BL_POINTS).step_by(8) {
println!(
"x/c = {:.3} theta = {:.6} H = {:.3} ue/Vinf = {:.3}",
x[i], aero.upper.theta[i], aero.upper.h[i], aero.upper.ue_over_vinf[i]
);
}

For the quickstart airfoil at 3° and a Reynolds number of 10⁶ this prints

x/c = 0.016 theta = 0.000077 H = 2.400 ue/Vinf = 1.315
x/c = 0.266 theta = 0.000312 H = 2.792 ue/Vinf = 1.471
x/c = 0.516 theta = 0.000541 H = 2.427 ue/Vinf = 1.340
x/c = 0.766 theta = 0.001387 H = 1.475 ue/Vinf = 1.179

The shape factor falls from laminar values above 2.4 to a turbulent value near 1.5 between the third and fourth rows, just behind the reported upper-surface transition at 49% of chord.

The edge velocity gives the surface pressure coefficient through Bernoulli's relation for incompressible flow, Cp=1−(ue/V∞)2C_p = 1 - (u_e/V_\infty)^2.

The analysis calls​

CallReturnsCost relative to analyze (xlarge)
analyze(&input)AeroOutput1
analyze_scalars(&input)AeroScalars0.8
analyze_with_tangent(&input, &direction)AeroTangent2.0
analyze_scalars_with_gradients(&input)AeroScalarResult2.6
analyze_with_gradients(&input)AeroResult12

AeroScalars holds the six scalar fields of AeroOutput under the same names, without the boundary layer. Its values are bitwise identical to those from analyze. The derivative calls are described in Gradients, and the batched forms of analyze and analyze_scalars under Many inputs at once.

None of these calls can fail or mutate the model. Out-of-range inputs produce a low confidence, not an error. One input is worth guarding in your own code: re must be positive, because the model takes its logarithm.

Many inputs at once​

Python NeuralFoil evaluates arrays of operating points in one vectorized call. Bora's equivalent is analyze_batch, which takes a slice of AeroInputs, any mix of airfoils and operating points, and returns one AeroOutput per input, in order:

use bora::{AeroInput, AeroOutput, BatchWorkspace, ModelSize, NeuralFoil};

let model = NeuralFoil::new(ModelSize::XLarge)?;
let inputs: Vec<AeroInput> = (0..64)
.map(|i| AeroInput { alpha: -4.0 + 0.25 * i as f64, ..input })
.collect();
let outputs = model.analyze_batch(&inputs);

// In a solver loop, keep the output buffer and the workspace between
// iterations so that repeated calls do not allocate.
let mut results = vec![AeroOutput::default(); inputs.len()];
let mut workspace = BatchWorkspace::default();
model.analyze_batch_into(&inputs, &mut results, &mut workspace);

// Scalar outputs only, as `AeroScalars`.
let scalars = model.analyze_scalars_batch(&inputs);

analyze_scalars_batch_into is the allocation-free form of the last call. A BatchWorkspace grows on first use and can be shared between network sizes.

The batched calls push blocks of eight network evaluations (four inputs and their mirror images) through each weight matrix together, instead of reading the weights once per input. A batch of 64 is about twice as fast per input as a loop over the single-input calls.

Time per input in microseconds for a batch of 64 (Apple M1 Pro, one thread).

ModelSizeanalyzeanalyze_batchSpeedupanalyze_scalarsanalyze_scalars_batchSpeedup
XXSmall4.92.51.9×2.21.12.1×
XSmall5.92.92.0×3.11.52.1×
Small7.63.82.0×4.32.02.1×
Medium9.24.42.1×5.92.62.3×
Large22.99.92.3×16.87.02.4×
XLarge27.211.82.3×21.68.92.4×
XXLarge84342.5×72.529.02.5×
XXXLarge3571472.4×3311342.5×

Small batches gain less: two inputs are about 1.1 to 1.2 times faster per input, three about 1.5 to 1.9 times, and a single input costs the same as analyze. Results agree with the single-input calls to within a few units in the last place, because the batched kernel sums in a different order and uses its own vectorizable exponential, and an input's result does not depend on its position in the batch or on the other inputs. There are no batched gradient calls.

Symmetry​

Mirroring an airfoil top to bottom and negating the angle of attack must negate the lift and moment and leave the drag unchanged. Bora's results obey this exactly, to the last bit, because of how the network is evaluated (see How NeuralFoil works). A symmetric section at zero angle of attack returns a lift and moment coefficient of exactly zero and equal transition locations on both surfaces.