API Overview
Bora is a Rust crate. The full public API is re-exported from the crate root,
so a single use bora::{...} covers everything. This page is an overview; for
the complete rustdoc reference (including the Philote discipline), run:
cargo doc --open --all-features
Core Types
NeuralFoil— The analysis model. Construct withNeuralFoil::new(size),NeuralFoil::with_data_dir(size, dir), orNeuralFoil::from_parts(network, distribution)(all returnbora::Result<NeuralFoil>), then callanalyze(&input)oranalyze_with_gradients(&input).model_size()reports the loaded size. Immutable and safe to share across threads after construction.Network/Layer— Low-level MLP container: loads HDF5 (.h5) weight files withNetwork::load(path)orNetwork::from_bytes(data)and evaluates the raw network (evaluate) with optional forward-mode Jacobian propagation (evaluate_with_jacobian).InputDistribution— Training-distribution statistics used for the Mahalanobis-based analysis confidence;InputDistribution::load(path)orInputDistribution::from_bytes(data).
The from_bytes loaders make it possible to embed weights in the binary so no
data directory is needed at runtime. Copy the needed files from Bora's data/
directory (nn-<size>.h5 and scaled_input_distribution.h5) into your
project; include_bytes! paths are relative to the source file:
use bora::{InputDistribution, NeuralFoil, Network};
fn embedded_model() -> bora::Result<NeuralFoil> {
let network = Network::from_bytes(include_bytes!("../data/nn-xlarge.h5"))?;
let distribution =
InputDistribution::from_bytes(include_bytes!("../data/scaled_input_distribution.h5"))?;
NeuralFoil::from_parts(network, distribution)
}
Data Types
KulfanParameters— CST shape description:upper_weights,lower_weights([f64; 8]each),leading_edge_weight,te_thickness.AeroInput— Shape plus operating condition:kulfan,alpha,re,n_crit,xtr_upper,xtr_lower.Defaultgivesre = 1e6,n_crit = 9.0, and free transition (xtr_upper = xtr_lower = 1.0).AeroOutput—cl,cd,cm,top_xtr,bot_xtr,analysis_confidence, and boundary layer distributionsupper/lower.BoundaryLayerData—theta,h,ue_over_vinfatNUM_BL_POINTSstations.AeroGradients/BoundaryLayerGradients— Gradients of every output with respect to the 23 inputs, mirroring the output layout.AeroResult— Bundlesoutput: AeroOutputandgradient: AeroGradients.Gradient—[f64; NUM_INPUTS]; indices named inbora::input_index(UPPER_WEIGHTS,LOWER_WEIGHTS,LEADING_EDGE_WEIGHT,TE_THICKNESS,ALPHA,RE,N_CRIT,XTR_UPPER,XTR_LOWER).ModelSize—XXSmall,XSmall,Small,Medium,Large,XLarge(default),XXLarge,XXXLarge.ModelSize::ALLlists all sizes;as_str(),Display, andFromStrconvert to and from names like"xlarge".Point2—[f64; 2]airfoil coordinate.
Constants
NUM_INPUTS(23) — Differentiable user-facing inputs.NUM_CST_WEIGHTS_PER_SIDE(8) — CST weights per surface.NUM_BL_POINTS(32) — Boundary layer stations per surface.NUM_LATENT_INPUTS(25),NUM_LATENT_OUTPUTS(198) — Network input and output dimensions.
Utilities
generate_kulfan_coordinates(¶ms, n_points_per_side)— CST parameters → Selig-format coordinates (Result<Vec<Point2>>).fit_kulfan_parameters(&coordinates)— Least-squares CST fit from Selig-format coordinates (Result<KulfanParameters>).bl_x_points()— Chordwise stations of the boundary layer outputs.version()— Crate version string.
Errors
Error— Enum of load and argument errors:Open,Format,DataDirNotFound,DimensionMismatch,InvalidArgument,SingularFit. Implementsstd::error::Error.Result<T>— Alias forstd::result::Result<T, bora::Error>.
Constructors, loaders, and the Kulfan utilities return Result; analysis calls
are infallible.
Philote Discipline
With the philote feature enabled, bora::philote::BoraDiscipline wraps
NeuralFoil as an explicit discipline for the Philote MDO standard (built on
the philote-mdo crate), so
any Philote client can evaluate airfoil aerodynamics and analytic partials over
gRPC. Variable names follow upstream NeuralFoil's capitalization (CL, Re,
...). Partials are row-major [output_size x input_size] blocks with singleton
dimensions dropped.
- Inputs:
upper_weights[8],lower_weights[8],leading_edge_weight,TE_thickness,alpha,Re,n_crit,xtr_upper,xtr_lower. - Outputs:
CL,CD,CM,Top_Xtr,Bot_Xtr,analysis_confidence, and optionally the boundary layer distributionsupper_theta,upper_H,upper_ue_over_vinf,lower_theta,lower_H,lower_ue_over_vinf. - Options:
| Option | Type | Description |
|---|---|---|
model_size | str | Network size name, e.g. "xlarge" (default) |
data_directory | str | Directory with the .h5 weight files; empty uses the standard resolution order |
include_boundary_layer | bool | Expose boundary layer outputs and their partials (default false) |
The bora_server binary serves the discipline:
# Default address is localhost:50051
cargo run --release --features philote --bin bora_server [address]