This project solves the classic 2D lid-driven cavity flow problem using a structured mesh-based solver. The velocity field is computed using the Chorin projection scheme, with both GPU acceleration via CuPy and CPU implementation via NumPy Results are compared with expected flow patterns and validated against benchmark characteristics.
-
Domain:
$\Omega = [0,1] \times [0,1]$ -
Velocity BCs:
-
Top wall (
$y=1$ ):u(x,1) = 16x^2(1-x)^2, \quad v(x,1) = 0
(Parabolic horizontal velocity profile for a smooth inlet-like behavior)
-
Other walls:
u = v = 0 \quad \text{(No-slip)}
-
-
Pressure BC:
$\frac{\partial p}{\partial n} = 0$ on all walls
The incompressible Navier–Stokes equations:
Parameter | Value | Description |
---|---|---|
Re | 1000 | Reynolds number (implied via ν) |
L, K | 1.0 | Domain height and width |
Nx × Ny | 41 × 41 | Grid resolution (structured grid) |
Δx, Δy | 0.025 | Grid spacing (uniform) |
Δt | 0.0005 | Time step |
Final Time | 5.1 s | Total simulation duration |
Stencil Size | 9 | Number of neighbors for GFDM |
Tracer Points | 41² | For visualization of advection |
ν | 0.001 | Kinematic viscosity (Re=1000) |
This solver uses Generalized Finite Difference Method (GFDM) to approximate derivatives without a mesh:
-
Grid Generation
- Structured 2D mesh (41 × 41)
- Boundary vs interior nodes identified
-
Precompute GFDM Weights
w_dx
,w_dy
,w_lap
(derivative operators)
-
Initialize Fields
$$\begin{cases} u(x,y) = 0 \\\ v(x,y) = 0 \\\ p(x,y) = 0 \\\ u(x,1) = 16x^2(1-x)^2 \quad \text{(top wall)} \end{cases}$$ -
Time Integration
- Intermediate velocity:
$$\vec{u}^* = \vec{u}^n + \Delta t \left(-\vec{u}^n \cdot \nabla \vec{u}^n + \nu \nabla^2 \vec{u}^n\right)$$ - Pressure solve:
$$\nabla^2 p^{n+1} = \frac{\rho}{\Delta t} \nabla \cdot \vec{u}^*$$ - Velocity correction:
$$\vec{u}^{n+1} = \vec{u}^* - \frac{\Delta t}{\rho} \nabla p^{n+1}$$ - Enforce boundary conditions
-
Particle Advection
- Tracers evolve using interpolated velocity fields
- Snapshots stored at ( t = 1.0 ) and ( t = 5.0 )
Output Field | Description |
---|---|
Tracer Positions | Scatter plot at selected time steps |
Velocity | Used for interpolating tracers |
Pressure | Implicit via correction |
- Primary vortex: Position near (0.5, 0.75)
- Secondary vortices: Weak recirculation zones in corners
- Bottom-left corner vortex
- Bottom-right corner vortex
- Divergence-free condition:
$$\max|\nabla \cdot \vec{v}| < 10^{-4}$$ - Steady-state convergence:
$$\frac{\|\vec{v}^{n+1} - \vec{v}^n\|}{\|\vec{v}^n\|} < 10^{-6}$$ - Benchmark comparison:
- Primary vortex center position vs. Ghia et al. (1982)
- Velocity profiles along centerlines
📊 Performance: - GPU acceleration (CuPy) resulted in a 6× speedup vs NumPy baseline
- Python 3.11+
- CUDA-enabled GPU (with CUDA 12.x drivers)
- Anaconda (recommended)
git clone https://github.com/nsreelekha/poisson_equation.git
cd poisson_equation
conda env create -f environment.yml
conda activate cupy129env
python -m venv venv
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
pip install -r requirements.txt
All dependencies are managed via Conda or requirements.txt
- cupy-cuda12x — GPU array library (NumPy-compatible)
- numpy, scipy, matplotlib
- pycuda (optional)
- Python 3.11
Install automatically via:
conda env create -f environment.yml
- No GPU? Replace:
import cupy as cp
with:
import numpy as cp
- Environment errors? Re-create the environment:
conda env remove -n cupy129env
conda env create -f environment.yml
- CuPy errors or crashes?
Ensure that:
- CUDA 12.x is correctly installed
- Your GPU is compatible
- cupy-cuda12x matches your CUDA version
- Simulation unstable? Try reducing Δt or increasing Nx, Ny
This project is licensed under the MIT License.
Sreelekha Nampally
🎓 B.Tech in Mathematics and Computing, NIT Mizoram
🛠️ Project developed as part of Summer Internship at IIT Tirupati
🌐 LinkedIn | GitHub