Skip to content
chrisluppPublic

Repository files navigation

Bora

Build and Tests

A Rust port of NeuralFoil, the physics-informed neural network surrogate of XFoil, with analytic gradients for gradient-based airfoil design optimization.

Given an airfoil shape in Kulfan (CST) parameterization and an operating condition (alpha, Re, n_crit, forced transition), Bora predicts:

  • Lift, drag, and moment coefficients (CL, CD, CM)
  • Transition locations on both surfaces
  • Boundary layer distributions (momentum thickness, shape factor, edge velocity) at 32 stations per surface
  • An analysis confidence measure (distance from the training distribution)

Every output can be differentiated analytically with respect to all 23 inputs (16 CST weights, leading edge weight, TE thickness, alpha, Re, n_crit, and forced transition locations), making Bora suitable both as a standalone optimization kernel and as a differentiable airfoil-analysis module inside larger aero tools. Outputs match Python NeuralFoil 0.3.3 to floating-point precision (verified by reference-value tests) and all eight upstream network sizes (xxsmall ... xxxlarge) are supported.

Bora also ports what AeroSandbox adds around the network, as analyze_corrected: a Mach number input with compressibility corrections (critical and drag-divergence Mach numbers, wave drag), a post-stall model for all 360 degrees of angle of attack, and control surface deflections, again with analytic gradients (including Mach number and deflection). Airfoils can be given as Kulfan parameters, as coordinates, or as a .dat file (FittedAirfoil).

Quick Start

use bora::{AeroInput, ModelSize, NeuralFoil, input_index};

fn main() -> bora::Result<()> {
    let mut input = AeroInput::default();
    input.kulfan.upper_weights = [0.24, 0.31, 0.25, 0.35, 0.24, 0.35, 0.28, 0.32];
    input.kulfan.lower_weights = [-0.12, -0.05, -0.13, 0.02, -0.08, 0.06, 0.02, 0.06];
    input.kulfan.te_thickness = 0.0025;
    input.alpha = 3.0; // deg
    input.re = 1e6;

    let model = NeuralFoil::new(ModelSize::XLarge)?;

    // Analysis only:
    let aero = model.analyze(&input);

    // Analysis with gradients of every output w.r.t. all inputs:
    let result = model.analyze_with_gradients(&input);
    let dcl_dalpha = result.gradient.cl[input_index::ALPHA];
    Ok(())
}

Add Bora to your project with:

cargo add bora-foil

The crate is published as bora-foil, but the library is still imported as bora (use bora::...).

See examples/example.rs for basic usage, examples/polar.rs for a lift curve and drag polar, examples/compressible.rs for a Mach sweep, a flap and the post-stall model, and examples/openmdao/optimize_daedalus.py for a multipoint airfoil optimization with OpenMDAO and IPOPT. The documentation covers the model, its validity limits, and the API.

Requirements

  • Rust 1.89+ (install via rustup)

That's it: the HDF5 weight files are read with the pure-Rust hdf5-pure crate, so no system HDF5 library is needed, and the network evaluation and its Jacobian are implemented directly in the crate with no linear algebra or ML runtime dependencies.

Building

# Build
cargo build --release

# Run tests (--all-features includes the Philote discipline)
cargo test --all-features

# Run examples
cargo run --release --example example
cargo run --release --example polar

# API documentation
cargo doc --open --all-features

The network kernels use fused multiply-add (FMA) instructions. On x86-64, a default build detects AVX2 and FMA at run time and uses them when the CPU has them (falling back to SSE2 otherwise); RUSTFLAGS="-C target-cpu=native" compiles them in statically instead, skipping the check. aarch64 always has FMA.

Cargo Features

Feature Default Description
philote off Philote discipline (bora::philote::BoraDiscipline) and the bora_server gRPC executable

Philote Discipline

With the philote feature, Bora exposes NeuralFoil function and analytic gradient evaluations to any Philote client (e.g. OpenMDAO via Philote-Python) over gRPC:

cargo run --release --features philote --bin bora_server [address]  # default localhost:50051

Or run the published Docker image (linux/amd64 and linux/arm64; latest is the newest release, next tracks develop), which needs no Rust toolchain:

docker run -d --rm --name bora -p 50051:50051 chrislupp/bora:latest

Options: model_size (str, default "xlarge"), data_directory (str), and include_boundary_layer (bool, default false).

examples/openmdao/optimize_daedalus.py is a complete client: OpenMDAO and IPOPT (via pyOptSparse) solve NeuralFoil's multipoint human-powered-aircraft airfoil case with Bora's analytic partials over Philote. It starts the server itself:

python3 examples/openmdao/optimize_daedalus.py

Network Weights

NeuralFoil's network weights live in data/ as HDF5 files converted from the upstream NeuralFoil .npz files (see scripts/convert_weights.py). At runtime the weight directory is resolved in this order:

  1. Explicit directory (NeuralFoil::with_data_dir)
  2. BORA_DATA_DIR environment variable
  3. The crate's source-tree data/ directory (baked in at build time)

Network::from_bytes / InputDistribution::from_bytes are available if you prefer to embed the .h5 file images into your own binary with include_bytes!.

Attribution

Bora is derived from NeuralFoil by Peter Sharpe: the network architecture, input/output processing, and analysis model are ported from NeuralFoil, and the network weights in data/ are converted from its weight files. The Kulfan (CST) geometry utilities and the compressibility, post-stall and control surface corrections follow AeroSandbox, also by Peter Sharpe. Both projects are MIT-licensed; their license notices are reproduced in NOTICE.

Citation

If you use Bora in academic work, please cite the NeuralFoil paper

@misc{neuralfoil_paper,
  title = {{NeuralFoil}: An Airfoil Aerodynamics Analysis Tool Using Physics-Informed Machine Learning},
  author = {Peter Sharpe and R. John Hansman},
  year = {2025},
  eprint = {2503.16323},
  archivePrefix = {arXiv},
  primaryClass = {physics.flu-dyn},
  url = {https://arxiv.org/abs/2503.16323},
}

and Peter Sharpe's PhD thesis, whose extended chapter on NeuralFoil is its primary long-form documentation:

@phdthesis{aerosandbox_phd_thesis,
   title = {Accelerating Practical Engineering Design Optimization with Computational Graph Transformations},
   author = {Sharpe, Peter D.},
   school = {Massachusetts Institute of Technology},
   year = {2024},
}

License

Licensed under the Apache License, Version 2.0 (LICENSE). See NOTICE for third-party attributions.

Public Release

This work has been cleared for public release, distribution unlimited, case number: AFRL-2026-2087.

The views expressed are those of the authors and do not reflect the official guidance or position of the United States Government, the Department of Defense or of the United States Air Force.

Statement from DoD: The Appearance of external hyperlinks does not constitute endorsement by the United States Department of Defense (DoD) of the linked websites, of the information, products, or services contained therein. The DoD does not exercise any editorial, security, or other control over the information you may find at these locations.

Releases

Packages

Contributors

Languages