https://github.com/kandil2001/lid-cavity-evolution
Lid Cavity Evolution is an open-source CFD suite for the lid-driven cavity problem, featuring MATLAB, Python, and parallel solvers with benchmark comparisons.
https://github.com/kandil2001/lid-cavity-evolution
benchmarking cfd cfd-simulation lid-driven-cavity matlab mpi numpy open-source openfoam openmp parallel-computing python scientific-computing simple-algorithm star-ccm
Last synced: 4 months ago
JSON representation
Lid Cavity Evolution is an open-source CFD suite for the lid-driven cavity problem, featuring MATLAB, Python, and parallel solvers with benchmark comparisons.
- Host: GitHub
- URL: https://github.com/kandil2001/lid-cavity-evolution
- Owner: Kandil2001
- License: mit
- Created: 2025-09-07T18:34:52.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-09-15T17:58:15.000Z (4 months ago)
- Last Synced: 2025-09-15T19:23:35.144Z (4 months ago)
- Topics: benchmarking, cfd, cfd-simulation, lid-driven-cavity, matlab, mpi, numpy, open-source, openfoam, openmp, parallel-computing, python, scientific-computing, simple-algorithm, star-ccm
- Homepage:
- Size: 646 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
π Lid Cavity Evolution
A benchmark suite for unsteady incompressible CFD: From MATLAB fundamentals to industrial applications
# Lid Cavity Evolution
_A benchmark suite for unsteady incompressible CFD: From MATLAB fundamentals to industrial applications_
## Table of Contents
- [Introduction](#introduction)
- [Features](#features)
- [Why the Lid-Driven Cavity?](#why-the-lid-driven-cavity)
- [Why the SIMPLE Algorithm?](#why-the-simple-algorithm)
- [Governing Equations](#governing-equations)
- [SIMPLE Algorithm Steps](#simple-algorithm-steps)
- [Numerical Methods & Boundary Conditions](#numerical-methods--boundary-conditions)
- [Project Roadmap](#project-roadmap)
- [Project Structure](#project-structure)
- [Benchmark Table](#benchmark-table)
- [Getting Started](#getting-started)
- [Contributing](#contributing)
- [Code of Conduct](#code-of-conduct)
- [Security](#security)
- [Support & Discussion](#support--discussion)
- [License](#license)
- [References](#references)
- [Citation](#citation)
- [Contact](#contact)
## Introduction
**Lid Cavity Evolution** is an open-source benchmark suite that chronicles the development of the classic lid-driven cavity CFD problemβfrom foundational MATLAB scripts to industrial-grade solvers. The project emphasizes accuracy, performance, and reproducibility for unsteady incompressible flow simulation.
## Why the Lid-Driven Cavity?
- **Standard Test Case:** Simple geometry, well-defined boundaries, and established reference solutions make it ideal for CFD code verification.
- **Rich Physics:** Captures vortex formation, boundary layers, and evolving flow structures.
- **Unsteady Simulation:** Tracks time evolution of flow fields, including transient and nonlinear phenomena.
## Why the SIMPLE Algorithm?
Simulating incompressible flows is numerically challenging due to tight coupling of velocity and pressure. The **SIMPLE (Semi-Implicit Method for Pressure-Linked Equations)** algorithm is widely used because it:
- Decouples momentum and continuity equations for robust convergence.
- Uses a staggered grid to prevent checkerboard pressure artifacts.
- Applies under-relaxation for improved stability and efficiency.
## Governing Equations
The solver models unsteady, incompressible, two-dimensional flow in a square cavity with a moving lid.
### 1. Continuity Equation (Incompressibility)
$\nabla \cdot \mathbf{u} = 0$
- $\mathbf{u}$: Velocity vector, $\mathbf{u} = (u, v)$
- $u$: velocity in $x$-direction
- $v$: velocity in $y$-direction
This equation enforces conservation of mass for incompressible flow: the net flow into any control volume is zero.
### 2. Momentum Equations (Navier-Stokes, Unsteady, 2D)
$\frac{\partial \mathbf{u}}{\partial t} + (\mathbf{u} \cdot \nabla)\mathbf{u} = -\nabla p + \frac{1}{Re}\nabla^2 \mathbf{u}$
Where each term means:
- $\frac{\partial \mathbf{u}}{\partial t}$: **Unsteady term** β Time rate of change of velocity.
- $(\mathbf{u} \cdot \nabla)\mathbf{u}$: **Convection term** β Transport of momentum by fluid motion.
- $- \nabla p$: **Pressure gradient term** β Acceleration caused by pressure differences.
- $\frac{1}{Re}\nabla^2 \mathbf{u}$: **Diffusion term** β Viscous spreading of momentum.
- $Re = \frac{UL}{\nu}$: **Reynolds number**
- $U$: Lid velocity
- $L$: Cavity length
- $\nu$: Kinematic viscosity
#### Expanded in 2D Components
- **x-Momentum:**
$\frac{\partial u}{\partial t} + u \frac{\partial u}{\partial x} + v \frac{\partial u}{\partial y} = -\frac{\partial p}{\partial x} + \frac{1}{Re} \left( \frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2} \right )$
- $\frac{\partial u}{\partial t}$: Time derivative of $u$
- $u \frac{\partial u}{\partial x}$: Convection of $u$ in $x$
- $v \frac{\partial u}{\partial y}$: Convection of $u$ in $y$
- $-\frac{\partial p}{\partial x}$: Pressure gradient in $x$
- $\frac{1}{Re} \frac{\partial^2 u}{\partial x^2}$: Viscous diffusion in $x$
- $\frac{1}{Re} \frac{\partial^2 u}{\partial y^2}$: Viscous diffusion in $y$
- **y-Momentum:**
$\frac{\partial v}{\partial t} + u \frac{\partial v}{\partial x} + v \frac{\partial v}{\partial y} = -\frac{\partial p}{\partial y} + \frac{1}{Re} \left( \frac{\partial^2 v}{\partial x^2} + \frac{\partial^2 v}{\partial y^2} \right )$
- $\frac{\partial v}{\partial t}$: Time derivative of $v$
- $u \frac{\partial v}{\partial x}$: Convection of $v$ in $x$
- $v \frac{\partial v}{\partial y}$: Convection of $v$ in $y$
- $-\frac{\partial p}{\partial y}$: Pressure gradient in $y$
- $\frac{1}{Re} \frac{\partial^2 v}{\partial x^2}$: Viscous diffusion in $x$
- $\frac{1}{Re} \frac{\partial^2 v}{\partial y^2}$: Viscous diffusion in $y$
## SIMPLE Algorithm Steps
The SIMPLE algorithm solves these equations with the following procedure:
1. **Predictor Step:**
- Solve momentum equations for an intermediate velocity $\mathbf{u}^*$ using the current pressure estimate.
2. **Pressure Correction:**
- Solve the pressure correction Poisson equation:
$\nabla^2 p' = \frac{1}{\Delta t} \nabla \cdot \mathbf{u}^*$
where $p'$ is the pressure correction and $\Delta t$ is the time step.
3. **Corrector Step:**
- Update velocities and pressure:
$\mathbf{u}^{n+1} = \mathbf{u}^* - \Delta t \nabla p'$
$p^{n+1} = p^{n} + \alpha p'$
where $\alpha$ is the under-relaxation factor ($0 < \alpha \leq 1$).
## Numerical Methods & Boundary Conditions
- **Spatial Discretization:** Second-order central differencing
- **Time Discretization:** First-order implicit Euler
- **Grid:** Staggered (pressure at cell centers, velocities at faces)
- **Boundary Conditions:**
- **Top lid:** $u = 1$, $v = 0$ (moving wall)
- **Other walls:** $u = v = 0$ (no-slip)
- **Pressure:** Neumann ($\frac{\partial p}{\partial n} = 0$) at boundaries
## Project Roadmap
| Phase | Description | Status |
|-------|-------------|--------|
| **Phase 1** | MATLAB loop-based SIMPLE solver | β
Complete |
| | Vectorized MATLAB implementation | β
Complete |
| **Phase 2** | Python/NumPy serial port | π§ In Progress |
| | Vectorized NumPy solver | π Planned |
| | Parallel Python (Numba/Dask) | π Planned |
| **Phase 3** | OpenFOAM case setup | π Planned |
| | STAR-CCM+ case setup | π Planned |
| **Phase 4** | Validation & analysis | π Planned |
## Project Structure
```
main/
βββ matlab/
β βββ iterative-solver/
β β βββ IterativeSolver.m
β β βββ README.md
β βββ vectorized-solver/
β β βββ VectorizedSolver.m
β β βββ README.md
β βββ README.md # MATLAB-specific overview
βββ python/
β βββ serial/
β β βββ iterative/
β β β βββ IterativeSolver.py
β β β βββ README.md
β β βββ vectorized/
β β β βββ VectorizedSolver.py
β β β βββ README.md
β β βββ README.md # Serial solvers overview
β βββ parallel/
β β βββ mpi/
β β β βββ MPISOlver.py
β β β βββ README.md
β β βββ openmp/
β β β βββ OpenMPSolver.py
β β β βββ README.md
β β βββ README.md # Parallel solvers overview
β βββ README.md # Python-specific overview
βββ logos/ # Technology logos
βββ assets/
βββ .github/ISSUE_TEMPLATE/ # GitHub issue templates
βββ CODE_OF_CONDUCT.md
βββ CONTRIBUTING.md
βββ LICENSE
βββ SECURITY.md
βββ README.md # Main project documentation
```
## Benchmark Table
| Solver | Language | Paradigm | Elapsed Time (s) | Speedup | Status |
|-------------------------------------------|--------------|-------------------------|------------------|---------|---------------|
| SIMPLE2D_LidDrivenCavity | MATLAB | Serial (Loops) | 36435 | 1x | β
Complete |
| _SimpleLidCavityVector_ | MATLAB | Serial (Vectorized) | TBD | TBD | π§ In Progress |
| _lid_cavity_serial.py_ | Python/NumPy | Serial (Loops) | TBD | TBD | π Planned |
| _lid_cavity_vectorized.py_ | Python/NumPy | Serial (Vectorized) | TBD | TBD | π Planned |
| _lid_cavity_parallel.py_ | Python | Parallel | TBD | TBD | π Planned |
| _OpenFOAM Case_ | OpenFOAM | Industrial CFD | TBD | TBD | π Planned |
| _STAR-CCM+ Case_ | STAR-CCM+ | Commercial CFD | TBD | TBD | π Planned |
_Hardware:
## Getting Started
### Prerequisites
- **MATLAB:** R2020a or later (for initial implementations)
- **Python:** 3.8+ (NumPy, planned)
- **OpenFOAM:** (planned)
- **STAR-CCM+:** (planned)
## Contributing
We welcome all contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on:
- Adding new solver implementations
- Improving code or documentation
- Adding validation cases
- Reporting issues or suggesting enhancements
Feel free to open an issue or submit a pull request!
## Code of Conduct
Please note that this project follows a [Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
## Security
If you discover a vulnerability, please see our [SECURITY.md](SECURITY.md) for instructions on reporting it.
## Support & Discussion
- For bug reports or feature requests, please use our [issue tracker](https://github.com/Kandil2001/Lid-Cavity-Evolution/issues).
- For general questions, open an issue or reach out via [email](mailto:kandil.ahmed.amr@gmail.com).
## License
This project is licensed under the MIT License.
See [LICENSE](LICENSE) for details.
## References
1. Ghia, U., Ghia, K. N., & Shin, C. T. (1982). _High-Re solutions for incompressible flow using the Navier-Stokes equations and a multigrid method_. J. Comput. Phys., 48(3), 387-411.
2. Patankar, S. V. (1980). _Numerical Heat Transfer and Fluid Flow_. Hemisphere Publishing.
3. Ferziger, J. H., PeriΔ, M., & Street, R. L. (2002). _Computational Methods for Fluid Dynamics_. Springer.
## Contact
For questions, suggestions, or collaboration inquiries, feel free to:
- Open an issue on [GitHub](https://github.com/Kandil2001/Lid-Cavity-Evolution/issues)
- Reach out via email: **kandil.ahmed.amr@gmail.com**
- Connect on [LinkedIn](https://www.linkedin.com/in/ahmed-kandil01)
> **Note:** This project is under active development. Check back for updates and new solver releases!