Skip to main content
Version: 0.1.0

XFOIL Aerodynamic Analysis

The XfoilDiscipline wraps the XFOIL panel-method airfoil solver as a Philote discipline. It computes aerodynamic coefficients (Cl, Cd, Cm) for a given airfoil geometry at specified flight conditions.

Overview

XFOIL is a well-established interactive program for the design and analysis of subsonic isolated airfoils. The XfoilDiscipline automates XFOIL's batch mode:

  1. Writes the airfoil geometry to a file in XFOIL format.
  2. Generates a command script for the analysis (LOAD, OPER, etc.).
  3. Executes XFOIL as a subprocess with a timeout.
  4. Parses the output polar file for the aerodynamic coefficients.

Each compute() call runs in an isolated temporary directory, ensuring clean execution when called many times during an optimization.

Environment Setup

The XfoilDiscipline requires the XFOIL_PATH environment variable to be set:

# Linux / macOS
export XFOIL_PATH=/path/to/xfoil

# Windows
set XFOIL_PATH=C:\path\to\xfoil.exe

The discipline validates this path during setup() and raises a ValueError if it is unset or points to a nonexistent file.

Viscous vs. Inviscid Modes

The discipline supports two analysis modes controlled by the viscous option:

Viscous mode (default)

Enables the boundary-layer solver. Requires reynolds and mach inputs in addition to alpha and the airfoil geometry. Returns physically meaningful drag coefficients.

Inviscid mode

Runs a potential-flow panel solution without a boundary layer. Omits the reynolds and mach inputs entirely. Cd will be exactly 0.0 since there is no viscous drag model.

The mode is set via the viscous option on the client side:

# Viscous (default)
RemoteExplicitComponent(channel=channel)

# Inviscid
RemoteExplicitComponent(channel=channel, viscous=False)

Inputs and Outputs

Inputs

NameShapeUnitsViscousInviscidDescription
alpha(1,)degYesYesAngle of attack
reynolds(1,)--YesNoReynolds number
mach(1,)--YesNoMach number
airfoil_x(n_points,)--YesYesAirfoil x-coordinates
airfoil_y(n_points,)--YesYesAirfoil y-coordinates

Outputs

NameShapeUnitsDescription
cl(1,)--Lift coefficient
cd(1,)--Drag coefficient
cm(1,)--Moment coefficient

The Wrapper Module

The low-level XFOIL interaction is delegated to a separate wrapper.py module with four standalone functions:

FunctionPurpose
write_airfoil_fileWrite x/y coordinates to XFOIL's airfoil format
write_command_fileGenerate the XFOIL batch script (LOAD, OPER, etc.)
run_xfoilExecute XFOIL via subprocess.run with a timeout
parse_output_fileRead the polar output file and return a dict of floats

This separation keeps the discipline class focused on the Philote interface and makes the file-handling logic independently testable.

Example Usage

from philote_examples.xfoil import XfoilDiscipline
from philote_mdo.general import run_server

# Create the discipline for 100-point airfoil geometries
discipline = XfoilDiscipline(n_points=100)

# Start the gRPC server on port 50052
run_server(discipline, port=50052)