Notes, runnable Python scripts, tool guides, and curated references for learning computational fluid dynamics. The material connects the physics of fluid flow with the numerical methods used to simulate it, the software used in practice, and data-driven techniques such as reduced-order models and machine learning.
Quick start • Learning paths • Notes • Practice • Scripts • References • Contributing
| Content | Count | Location |
|---|---|---|
| Theory notes | 134 | notes/ |
| Notes with exercises | 134 | notes/ |
| Practice guides | 14 | practice/ |
| Algorithm scripts | 7 | scripts/algorithms/ |
| Plot scripts | 35 | scripts/plots/ |
| Simulations | 15 | scripts/simulations/ |
Every script runs headless in CI, and every relative link in the repository is checked. Topics that are planned but not written yet are tracked in the roadmap.
git clone https://github.com/djeada/Computational-Fluid-Dynamics-CFD-Resources.git
cd Computational-Fluid-Dynamics-CFD-Resources
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cd scripts/simulations/lid_driven_cavity
python main.py # interactive window
python main.py --no-show --output figures # save the figure insteadEvery script accepts --no-show and --output DIR. Time-stepping and interactive scripts also accept --steps N. Each script folder has a README explaining the maths, the implementation, and the output.
Each path is a suggested reading order through material that exists in this repository.
Prerequisites: calculus, basic physics, some Python.
- Introduction to fluid mechanics and dimensional analysis
- Navier–Stokes equations
- Why CFD is needed and the strategy of CFD
- Finite difference method, then run the 1D heat and wave equations
- Numerical stability
- Run the lid-driven cavity and read the lid-driven cavity tutorial
Prerequisites: path 1, linear algebra.
- Finite-difference discretization
- Finite volume method and finite-volume discretization
- Finite element method and weak formulations
- Dealing with nonlinearity, direct and iterative solvers, and iterative convergence
- Lattice Boltzmann method, then run the lattice Boltzmann cylinder flow
Prerequisites: an engineering background.
- Boundary layers and turbulence
- Turbulence modeling in CFD
- Mesh quality and boundary-layer meshing
- Gmsh, OpenFOAM, and ParaView
- Flow over a cylinder end to end
- Solver comparison and workflow automation
Prerequisites: linear algebra, Python, CFD basics.
- Proper orthogonal decomposition, POD and the SVD, and snapshot POD, with the POD and snapshot POD scripts
- Reduced-order modeling and POD–Galerkin projection
- Surrogate models, kriging, and radial basis functions, with the kriging and RBF scripts
- Machine learning for CFD, neural networks in aerodynamics, and machine learning on meshes
Theory notes are grouped by subject. Most notes end with exercises (with worked answers) and references.
| Topic | Notes |
|---|---|
| Fundamentals | Force systems, moments and couples, free body diagrams, vector analysis |
| Statics | Particle and rigid-body equilibrium, structural analysis, trusses and frames, friction, centroids |
| Dynamics | Kinematics and kinetics of particles and rigid bodies, work–energy, impulse–momentum, vibrations |
| Strength of materials | Stress and strain, material properties, axial loading, torsion, bending, shear and moment diagrams, combined loading, buckling |
| Fluid loading | Pressure forces, wind loading, wave loading, flow-induced vibrations, hydroelasticity |
| Control systems | System modeling, stability analysis, feedback control, PID controllers |
| Mechanical systems | Mechanisms, gears, bearings, rotating machinery, hydraulics and pneumatics |
| Transportation | Airplanes (airfoils, stability, inertial navigation, Reynolds number, design process) and cars |
Guides for the tools used in day-to-day CFD work. See the practice overview for a suggested order.
Each script lives in its own folder with a main.py and a README covering the mathematical background, the implementation, and the output. The index below is generated from those READMEs by tools/generate_index.py.
| Script | Description |
|---|---|
| Condition Number of the Correlation Matrix | This script plots how the condition number of a kriging correlation matrix changes with the correlation parameter |
| Correlation Functions | This script plots four correlation functions used in kriging surrogate models (linear, exponential, Gaussian and cubic spline) for several values of the correlation parameter |
| Image Compression Using SVD | This script compresses a grayscale image by keeping only its |
| Kriging Interpolation | This script interpolates 11 samples of |
| Proper Orthogonal Decomposition (POD) | This script performs Proper Orthogonal Decomposition on a synthetic spatio-temporal field by taking the singular value decomposition of the mean-subtracted snapshot matrix. |
| Radial Basis Functions | This script fits a multiquadric radial basis function (RBF) interpolant through 11 data points on Rbf class and plots it on a fine grid. |
| Snapshot Proper Orthogonal Decomposition (Snapshot POD) | This script computes POD modes of a synthetic spatio-temporal field with the snapshot method, which solves an eigenvalue problem for the |
| Script | Description |
|---|---|
| Airfoil Angle of Attack | This script draws a NACA 2412 airfoil pitched nose-up about its leading edge to several angles of attack, |
| NACA 4-Digit Airfoil Profile | This script draws an annotated NACA 4-digit airfoil profile (NACA 4412 by default) from its four-digit designation, labelling the leading edge, trailing edge, chord line and mean camber line. |
| Archimedes' Principle Visualisation | This script draws a block in a tank of fluid with its weight and buoyant force shown as arrows, and states whether the block floats or sinks according to Archimedes' principle. |
| Generating Synthetic Data for Boundary Layer Simulation | This script generates noisy synthetic velocity samples across a boundary layer from a simple square-root profile, saves them to a CSV file and plots them against the wall-normal distance. |
| Turbulent Boundary Layer Velocity Profile | This script plots the one-seventh power-law velocity profile of a turbulent boundary layer in normalised form, |
| Grid Convergence Comparison | This script illustrates grid convergence by plotting the model numerical solutions |
| Compressible vs. Incompressible Duct Flow | This script draws prescribed incompressible and compressible velocity fields in a 2D duct side by side, so the constant downstream profile of the first can be compared with the accelerating profile of the second. |
| Design Space Distribution via Sobol Sequences | This script draws a four-dimensional scrambled Sobol design of 512 geometry variants and plots two 2D projections of it, showing how evenly a low-discrepancy sequence covers a design space. |
| Drag Coefficient Prediction | This script compares two synthetic drag-coefficient predictors with reference values in a predicted-vs-reference plot, adding a regression line and |
| Eigenvector Projection of Velocity Fluctuations | This script finds the principal directions of correlated 2D velocity fluctuations from the eigenvectors of their covariance matrix and projects the data onto them. |
| Eulerian and Lagrangian Flow Descriptions | This script contrasts the Eulerian and Lagrangian descriptions of fluid motion using the time-dependent Double Gyre flow. |
| Flow Rate Through a Circular Pipe | This script computes the volumetric flow rate |
| Flow Separation in a Boundary Layer | This script draws a schematic of boundary-layer separation: an attached layer that thickens downstream, a separation point, and a recirculation region under the separated shear layer. |
| Froude Number vs. Flow Velocity | This script plots the length-based Froude number |
| Laminar vs. Turbulent Boundary Layer Profiles | This script plots normalised laminar and turbulent boundary-layer velocity profiles on the same axes to show how much fuller the turbulent profile is. |
| Laminar vs Turbulent Pipe Flow | This script plots laminar and turbulent radial velocity profiles of pipe flow in side-by-side panels to show how much flatter the turbulent profile is. |
| Longitudinal Velocity Fluctuations and Projections | This script plots synthetic two-point velocity fluctuations as time traces, as a scatter cloud, and projected onto a unit vector, which are the first steps of the two-point POD example. |
| Mean Pressure Coefficient Along Vehicle Centreline | This script plots a mock validation figure of mean pressure coefficient |
| Mean Velocity Magnitude: Experiment vs CFD Comparison | This script plots a mock experimental profile and a mock CFD scale-resolving simulation (SRS) profile of the normalised mean velocity magnitude |
| Meniscus Behavior | This script sketches the meniscus of water and of mercury in a glass tube, showing how wetting determines whether the free surface curves up or down at the wall. |
| Microscopic vs. Macroscopic View of a Fluid | This script draws two side-by-side panels that contrast the microscopic (molecular) and macroscopic (continuum) views of a fluid. |
| Converging-Diverging Nozzle Flow | This script plots quasi-one-dimensional isentropic flow through a converging-diverging (de Laval) nozzle, with streamlines coloured by Mach number. |
| Numerical vs. Exact Solution Comparison | This script solves |
| POD Analysis for Flow Fields | This script performs Proper Orthogonal Decomposition (POD) on a synthetic 100 × 50 snapshot matrix with the singular value decomposition (SVD) and plots the eigenvalue spectrum with the share of turbulent kinetic energy (TKE) in each mode. |
| POD Modes of a Two-Point Velocity Signal | This script applies Proper Orthogonal Decomposition to velocity signals measured at two points, a and b, and plots how much each of the two POD modes contributes to each signal. |
| POD Spatial Modes and Temporal Coefficients | This script extracts the first three POD spatial modes and their temporal coefficients from a synthetic two-dimensional, time-dependent field and plots them. |
| Pressure Difference Across a Spherical Droplet | This script draws an annotated schematic of the Young-Laplace pressure jump across the surface of a spherical droplet. |
| Pressure Variation with Depth | This script plots how hydrostatic pressure increases linearly with depth below the free surface of a fluid at rest. |
| Maxwell-Boltzmann Speed Distribution of N₂ Molecules | This script plots the Maxwell-Boltzmann speed distribution of nitrogen (N₂) molecules at 300 K, 600 K, 900 K and 1200 K, and marks the most probable, mean and root-mean-square speed on each curve. |
| Ship Hull in Water | This script draws a side-view sketch of a ship hull sitting in a sinusoidal free-surface wave and annotates it with the Froude number |
| Time-Averaged Velocity Field | This script generates a synthetic noisy longitudinal velocity field on a 200 × 60 grid and compares it with its mean field, the first step of a Reynolds decomposition. |
| Turbulent Flow: Reynolds Decomposition | This script splits a synthetic velocity signal into its time mean and fluctuation, following the Reynolds decomposition used in turbulence modelling. |
| Variation of Residual with Iteration | This script solves the 1D Laplace equation with Gauss-Seidel iteration on a 100-point grid and plots the normalised residual against iteration number on a logarithmic scale. |
| Velocity Layers and Viscosity | This script draws a schematic of three stacked fluid layers moving at different speeds to illustrate Newton's law of viscosity, |
| Wall Shear in Pipe Cross-Section | This script sketches fully developed laminar (Hagen-Poiseuille) flow in a circular pipe, with velocity arrows whose lengths follow the parabolic profile |
| Script | Description |
|---|---|
| 1D Heat and Wave Equation Simulations | This script solves the 1D heat equation with the implicit Crank–Nicolson scheme and the 1D wave equation with the explicit leapfrog scheme, animating both from the same initial Gaussian pulse. |
| 2D Wave Equation Simulation | This script solves the 2D scalar wave equation on a square domain with an explicit leapfrog finite difference scheme and animates the result as a 3D surface. |
| Backward-Facing Step Flow (SIMPLE Algorithm) | This script solves steady 2D laminar incompressible flow over a backward-facing step with the finite volume method and the SIMPLE pressure–velocity coupling algorithm. |
| Bak–Tang–Wiesenfeld Sandpile Model (3D) | This script simulates the two-dimensional Bak–Tang–Wiesenfeld (BTW) sandpile on a 20×20 lattice and animates its height field as a 3D surface. |
| Charged Particle Dynamics in a Magnetic Field | This script integrates the motion of a charged particle in a uniform magnetic field with the classical fourth-order Runge–Kutta (RK4) method and animates the resulting helical trajectory in 3D. |
| Eulerian Cylinder Flow | This script simulates 2D incompressible, inviscid flow past a circular cylinder on a fixed Eulerian grid and renders a dye tracer in real time with Pygame. |
| Ising Model Simulation | This script simulates the two-dimensional Ising model with the Metropolis Monte Carlo algorithm and animates the spin lattice together with its magnetization and energy. |
| Kelvin-Helmholtz Instability Simulation | This script simulates the Kelvin-Helmholtz instability, the rolling-up of a shear layer between fluid streams moving in opposite directions, in a periodic 2D incompressible flow drawn in real time with Pygame. |
| Laplace Equation Maze Solver | This script solves a randomly generated maze by computing a potential that satisfies Laplace's equation in the maze passages and then following the potential uphill from the entrance to the exit. |
| Lattice Boltzmann Cylinder Flow Simulation | This script simulates 2D flow past a circular cylinder with the lattice Boltzmann method (D2Q9 lattice, BGK collision operator) and animates the velocity magnitude with Matplotlib. |
| Lid-Driven Cavity Flow Simulation | This script solves the 2D incompressible Navier-Stokes equations for flow in a square cavity driven by a moving lid at a Reynolds number of 100 and animates the velocity field. |
| Rayleigh-Bénard Convection Simulation | This script simulates Rayleigh-Bénard convection, the buoyancy-driven flow in a fluid layer heated from below and cooled from above, and draws the temperature field in real time with Pygame. |
| 2D Schrödinger Equation Simulation | This script solves the time-dependent Schrödinger equation for a free particle in two dimensions with the split-step Fourier method and animates the probability density of the spreading wavepacket as a 3D surface. |
| Simplified Real-Time Fluid Dynamics Simulator | This script is an interactive 2D smoke simulation that uses Jos Stam's Stable Fluids algorithm (1999) to approximate the incompressible Navier-Stokes equations fast enough to run in real time in a Pygame window. |
| Steady and Unsteady Pathlines Around a Cylinder with Vortex Shedding | This script compares streamlines and particle pathlines for steady potential flow past a cylinder with circulation and for an unsteady version of the same flow with a kinematic vortex-shedding model. |
My simulation diverges. What should I check?
Common causes, roughly in order of frequency:
- Time step too large for the stability limit (reduce it and retry)
- Boundary conditions that are incorrect or conflicting
- Initial conditions far from the solution
- Poor mesh quality (high skewness or aspect ratio)
- A numerical scheme unsuited to the problem
See numerical stability and iterative convergence.
How do I know if my mesh is fine enough?
Run a mesh independence study: solve on at least three systematically refined meshes, compare the quantities you care about (drag, pressure drop, reattachment length), and estimate the discretization error, for example with Richardson extrapolation. Also check mesh quality metrics. See mesh quality and the grid convergence script.
What is the difference between DNS, LES, and RANS?
- DNS resolves all turbulent scales. It is accurate but its cost grows steeply with Reynolds number, so it is mainly a research tool.
- LES resolves the large eddies and models the smaller ones. It gives unsteady detail at considerably higher cost than RANS.
- RANS solves time-averaged equations and models all turbulence through a closure. It is the workhorse of industrial CFD.
See turbulence modeling.
What is y+ and why does it matter?
-
$y^+ \lesssim 1$ : the viscous sublayer is resolved (low-Reynolds-number models) -
$30 \lesssim y^+ \lesssim 300$ : wall functions bridge the log layer -
$5 < y^+ < 30$ : the buffer layer, where neither approach is accurate
See RANS equations and boundary-layer meshing.
- CFD Python: 12 Steps to Navier-Stokes by Lorena Barba: a hands-on introduction to CFD in Python, built up in small steps
- CFD General Principles by CFD Direct: fundamental concepts from the maintainers of OpenFOAM
- Scientific Computing (Chasnov): Computational Fluid Dynamics: governing equations and numerical methods
- National Committee for Fluid Mechanics Films: classic educational films on fluid phenomena
- NASA Turbulence Modeling Resource: verification and validation cases for turbulence models
- Wall-Modeled LES Resource: WMLES database and guidelines
- Airfoil Tools: airfoil geometry and performance data
- NWTF Experimental Database: Airbus wind tunnel dataset for the RAE2822 transonic aerofoil
- DepositOnce (TU Berlin): research data repository
| Book | Authors | Best for | Level |
|---|---|---|---|
| Computational Fluid Dynamics: The Basics with Applications | John D. Anderson | Introduction with an aerospace emphasis | Beginner–intermediate |
| An Introduction to Computational Fluid Dynamics: The Finite Volume Method | H. K. Versteeg & W. Malalasekera | Clear introduction to the finite volume method | Beginner–intermediate |
| Computational Methods for Fluid Dynamics | J. H. Ferziger, M. Perić & R. L. Street | Comprehensive graduate-level treatment | Advanced |
| Numerical Heat Transfer and Fluid Flow | Suhas V. Patankar | The classic text on the SIMPLE algorithm | Intermediate |
| Computational Fluid Dynamics: Principles and Applications | J. Blazek | Practical guidance for industrial CFD codes | Intermediate–advanced |
| Data-Driven Science and Engineering | S. L. Brunton & J. N. Kutz | Machine learning for dynamical systems, POD, DMD | Intermediate–advanced |
| Machine Learning Control | T. Duriez, S. L. Brunton & B. R. Noack | Machine learning for flow control | Advanced |
- Machine Learning for Fluid Mechanics (Brunton, Noack & Koumoutsakos): review of machine learning in fluid mechanics
- Machine Learning-Based CFD Simulations: A Review: models, open problems, and future directions (2022)
- Physics-Informed Neural Networks (Raissi, Perdikaris & Karniadakis): the original PINN paper
- Machine Learning in CFD: Recent Advances (2023)
- Nature Reviews article from the Karniadakis group: review of physics-informed computational methods
- CFD of the Future: Year 2025 and Beyond: perspectives on AI, HPC, and uncertainty quantification
- Pratt & Whitney: The Aircraft Engine and Its Operation (1949): historical engineering reference
- Machine Learning and Simulation by Ceyron: ML techniques combined with physics simulations
- NVIDIA Modulus airfoil optimisation: GPU-accelerated physics-informed ML, including a 2D lid-driven cavity example
- Introductory Finite Elements (EAFIT): FEM course material with Python implementations
- DOLFINx tutorial: finite elements with FEniCSx
- David Penner's CFD projects: portfolio of applied CFD projects
- AeroCFD lecture series: university-level CFD lectures
- Computational Fluid Dynamics, ME615, IIT Mandi: a complete university CFD course
- Qiqi Wang's CFD lectures: numerical analysis for CFD
- The Perić lectures on CFD: an industry perspective
- Numerical methods by hand: algorithms worked through manually
- Mechanics problems solved by hand
- Postcard Professor: step-by-step mechanics problem solving
- Additional worked solutions
- Theoretical mechanics and numerical methods
- Data-Driven Methods for Science and Engineering seminar
- Gentle introduction to fluid concepts
Corrections, new notes, and new scripts are welcome. Read CONTRIBUTING.md for the conventions and the checks to run, and see the roadmap for topics that still need writing. Bug reports and suggestions go in issues; open-ended ideas can go in discussions.
Released under the MIT License.
