"The airplane stays up because it doesn't have the time to fall." - Orville Wright
This is a Computational Fluid Dynamics (CFD) engine built from scratch in Python. It simulates aerodynamic flow over any NACA 4-digit airfoil using the Linear Strength Vortex Panel Method.
Unlike simple ballistic simulators, this engine solves the discretized flow field equations using linear algebra to determine lift, pressure distribution (
Core Capabilities:
Procedural Geometry: Generates NACA 4-digit airfoils (e.g., 2412, 0015) using cosine spacing for high-resolution leading edges. Physics Engine: Solves the system of linear equations
$A\mathbf{x} = \mathbf{b}$ to satisfy the Kutta Condition and flow tangency. Visualization: Renders full flow field streamlines and pressure coefficient heatmaps.
The simulator assumes inviscid, incompressible, irrotational flow (Potential Flow).
-
Geometry Discretization The airfoil surface is discretized into
$N$ panels. To capture the extreme curvature of the leading edge, we use the cosine transformation:$$x = \frac{c}{2} (1 - \cos(\beta))$$ -
Vortex Panel Method We place a vortex sheet of strength
$\gamma(s)$ on the airfoil surface. The induced velocity potential$\phi$ must satisfy the Laplace equation:$$\nabla^2 \phi = 0$$ To enforce the No-Penetration Boundary Condition (air cannot flow through the wing), the normal velocity component$V_n$ at every control point must be zero:$$V_{n, \text{induced}} + V_{\infty} \cdot \mathbf{n} = 0$$ -
The Influence Matrix This creates a system of
$N+1$ linear equations, where$A_{ij}$ represents the aerodynamic influence of panel$j$ on panel$i$ :$$[A] \cdot [\Gamma] = [RHS]$$ Solving this matrix yields the vortex strength$\Gamma$ for each panel, which is integrated to find the Coefficient of Pressure ($C_p$ ) and Lift ($C_l$ ). Note: Due to d'Alembert's paradox for inviscid flow, induced drag is theoretically zero.
-
Clone the repository: git clone https://github.com/YOUR_USERNAME/airfoil-flow-sim.git
-
Install dependencies pip install -r requirements.txt
Run the main simulation controller: python main.py
Follow the CLI prompts to input your flight parameters, including:
NACA number (e.g., 2412 for a cambered Cessna wing, 0012 for a symmetrical stabilizer) Angle of Attack: (e.g., 5.0 degrees) Chord Length: Scale the wing geometry.
A fully interactive web version is available with real-time particle animation and instant parameter feedback.
- Navigate to the
webdirectory:cd web - Start a local server:
python3 -m http.server 8080
- Open your browser and go to: http://localhost:8080
Web Features:
- Real-time Controls: Adjust Camber, Thickness, and Angle of Attack on the fly.
- Particle Animation: Visualize airflow dynamics with animated streamlines.
-
Modern UI: Dark-themed interface with live lift coefficient (
$C_l$ ) updates.
The engine produces one primary output:
Flow Field Heatmap: A full Navier-Stokes stlye visual showing velocity streamlines and pressure gradients (Coefficient of Pressure)