A hands-on implementation of the numerical methods behind Computational Fluid Dynamics (CFD), progressing from one-dimensional convection equations to solving the incompressible Navier–Stokes equations.
This repository documents my journey of learning Computational Fluid Dynamics (CFD) by implementing numerical solvers entirely from scratch in Python.
Rather than relying on commercial CFD software, each exercise develops the governing equations, discretizes them using finite difference methods, and implements the solution using NumPy and Matplotlib.
The exercises begin with simple one-dimensional transport equations and gradually build toward solving the incompressible Navier–Stokes equations.
As an budding researcher in Computational Fluid Dynamics, Thermo-Fluids, and Scientific Machine Learning, I believe understanding the underlying numerical methods is just as important as using existing CFD software.
This repository serves as both:
-
a structured learning journal,
-
a portfolio of CFD implementations,
- Step 1 — Linear Convection
- Step 2 — Nonlinear Convection
- CFL Condition
- Step 3 — Diffusion
- Step 4 — Burgers' Equation
- Step 5 — Linear Convection
- Step 6 — Nonlinear Convection
- Step 7 — Diffusion
- Step 8 — Burgers' Equation
- Step 9 — Laplace Equation
- Step 10 — Poisson Equation
- Step 11 — Lid-Driven Cavity Flow
- Step 12 — Channel Flow
| Step | Problem | Dimension | Concepts |
|---|---|---|---|
| 1 | Linear Convection | 1D | Upwind Scheme |
| 2 | Nonlinear Convection | 1D | Nonlinear PDEs |
| 3 | Diffusion | 1D | FTCS Scheme |
| 4 | Burgers' Equation | 1D | Convection + Diffusion |
| 5 | Linear Convection | 2D | Finite Difference |
| 6 | Nonlinear Convection | 2D | Coupled PDEs |
| 7 | Diffusion | 2D | Explicit Time Marching |
| 8 | Burgers' Equation | 2D | Nonlinear Transport |
| 9 | Laplace Equation | 2D | Iterative Solvers |
| 10 | Poisson Equation | 2D | Source Terms |
| 11 | Lid-Driven Cavity | 2D | Incompressible Navier–Stokes |
| 12 | Channel Flow | 2D | Pressure-Driven Flow |
cfd-fundamentals-python/
│
├── README.md
├── LICENSE
├── requirements.txt
├── .gitignore
│
├── notebooks/
│ ├── Step01_Linear_Convection.ipynb
│ ├── Step02_Nonlinear_Convection.ipynb
│ ├── ...
│ └── Step12_Channel_Flow.ipynb
│
├── src/
│ ├── step01_linear_convection.py
│ ├── step02_nonlinear_convection.py
│ ├── ...
│ └── step12_channel_flow.py
│
└── reports/
Results from each step can be seen by opening the corresponding notebook
Clone the repository
git clone https://github.com/danielokene/cfd-fundamentals-python.gitMove into the project
cd cfd-fundamentals-pythonInstall dependencies
pip install -r requirements.txtExample:
python src/step01_linear_convection.pyor open the corresponding Jupyter notebook inside the notebooks/ folder.
Throughout this project I aim to develop a solid understanding of:
- Partial Differential Equations
- Finite Difference Methods
- Explicit Time Integration
- Numerical Stability
- CFL Condition
- Boundary Conditions
- Pressure Poisson Equation
- Incompressible Navier–Stokes Equations
- Scientific Programming with NumPy
After completing these twelve steps, I plan to explore:
- Finite Volume Method (FVM)
- Lattice Boltzmann Method (LBM)
- OpenFOAM
- Turbulence Modeling (RANS & LES)
- GPU-Accelerated CFD
- High-Performance Computing (MPI/OpenMP)
This repository is inspired by the excellent educational project CFD Python: The 12 Steps to Navier–Stokes developed by Prof. Lorena A. Barba and Gilbert F. Forsyth. While this repository contains my own implementations, notes, and learning progress, the learning pathway and pedagogical approach are based on their open educational materials. Please consider citing their work if you use or build upon the original lessons.
If you use the original educational material, please cite:
Barba, L. A., & Forsyth, G. F. (2018). CFD Python: the 12 steps to Navier–Stokes equations. Journal of Open Source Education, 1(9), 21. https://doi.org/10.21105/jose.00021
- Barba, L. A., & Forsyth, G. F. (2018). CFD Python: The 12 Steps to Navier–Stokes. Journal of Open Source Education.
- Anderson, J. D. Computational Fluid Dynamics: The Basics with Applications.
- Ferziger, J. H., & Perić, M. Computational Methods for Fluid Dynamics.
- Versteeg, H. K., & Malalasekera, W. An Introduction to Computational Fluid Dynamics: The Finite Volume Method.
⭐ If you find this repository useful, feel free to star it!