Skip to content

GPU-accelerated Couette Flow solver using Chorin projection and GFDM (meshfree and meshgrid methods)

License

Notifications You must be signed in to change notification settings

nsreelekha/couette_flow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌀 Finite Pointset Method for Couette Flow (GPU-Accelerated)

This project solves the 2D Couette flow problem using both the Generalized Finite Difference Method (GFDM) — a meshfree approach — and a meshgrid-based method, with GPU acceleration via CuPy. The solution is computed using the Chorin projection scheme, and the results are validated against the analytical solution.


1. 📘 Governing Equations (Incompressible Navier-Stokes)

1.1 Lagrangian Formulation

$$ \begin{aligned} &\frac{d\vec{x}}{dt} = \vec{v} &\text{(Particle motion)} \\\ &\frac{D\vec{v}}{Dt} = -\nabla p + \nu \Delta \vec{v} + \vec{g} &\text{(Momentum)} \\\ &\nabla \cdot \vec{v} = 0 &\text{(Incompressibility)} \end{aligned} $$


2. 🧮 Core Numerical Steps (Chorin Projection + GFDM)

2.1 Particle Motion

$$ \vec{x}^{n+1} = \vec{x}^n + \Delta t \vec{v}^n $$

2.2 Intermediate Velocity

$$ \vec{v}^* = \vec{v}^n + \Delta t \left( \nu \Delta \vec{v}^n + \vec{g}^n \right) $$

2.3 Pressure Poisson Equation

$$ \Delta p^{n+1} = \frac{\nabla \cdot \vec{v}^*}{\Delta t}, \quad \frac{\partial p}{\partial n} = 0 \ (\text{BC}) $$

2.4 Velocity Correction

$$ \vec{v}^{n+1} = \vec{v}^* - \Delta t \nabla p^{n+1} $$


3. 🧠 Meshfree Derivative Approximation (GFDM - Least Squares)

For a particle at position $\vec{x}$ with neighbors $\vec{x}_i$:

$$ \begin{pmatrix} p \ p_x \ p_y \ p_{xx} \ p_{xy} \ p_{yy} \end{pmatrix} = (M^T W M)^{-1} (M^T W) \begin{pmatrix} p_1 \ \vdots \ p_m \end{pmatrix} $$

Weights (Gaussian Kernel)

$$ w_i = \exp\left(-6.25 \frac{|\vec{x}_i - \vec{x}|^2}{h^2}\right) $$


4. 📊 Analytical Solution for Couette Flow

The analytical steady-state velocity profile is:

$$ u(y) = \frac{U_0}{L} y $$

Time-dependent analytical solution:

$$ u(y, t) = u(y) + \frac{2U_0}{\pi} \sum_{n=1}^\infty \frac{(-1)^n}{n} \sin\left(\frac{n\pi y}{L}\right) e^{-\frac{n^2 \pi^2 \nu t}{L^2}} $$


5. 🧪 Results

  • ✅ Velocity field closely matches the analytical solution.
  • ✅ Pressure satisfies Neumann boundary conditions.
  • ⚡ Significant speedup observed with GPU (CuPy) over CPU (NumPy) implementation.

🚀 6. Project Setup & Usage

🔧 Requirements

  • Python 3.11+
  • CUDA-enabled GPU (with CUDA 12.x drivers)
  • Anaconda (recommended)

🧱 Step 1: Clone the repository

git clone https://github.com/nsreelekha/poisson_equation.git
cd poisson_equation

🧪 Step 2A: Create and activate the Conda environment

conda env create -f environment.yml
conda activate cupy129env

🧪 Step 2B: (Alternative) Use pip + virtualenv

python -m venv venv
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate

pip install -r requirements.txt

🚀 Running the Code

You can run the notebooks using Jupyter.

▶️ Step 3: Launch Jupyter Notebook

jupyter notebook

Then open:

📘 couette_flow.ipynb — Simulates shear-driven flow between parallel plates using meshfree and meshgrid-based methods.

The notebook will:

  • ✅ Generate a meshfree particle distribution (or structured grid)

  • ✅ Assemble the GFDM operators using weighted least squares

  • ✅ Apply boundary conditions for Couette flow

  • ✅ Solve the incompressible Navier–Stokes equations using the Chorin projection method

  • ✅ Visualize velocity and pressure fields using Matplotlib

📦 Dependencies

All dependencies are managed via Conda or requirements.txt

Key packages include:

  • cupy-cuda12x — GPU array library (NumPy-compatible)
  • numpy, scipy, matplotlib
  • pycuda (optional)
  • Python 3.11

Install automatically via:

conda env create -f environment.yml

🛠️ Troubleshooting

  • 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

📜 License

This project is licensed under the MIT License.

👤 Author

Sreelekha Nampally
🎓 B.Tech in Mathematics and Computing, NIT Mizoram
🛠️ Project developed as part of Summer Internship at IIT Tirupati
🌐 LinkedIn | GitHub

About

GPU-accelerated Couette Flow solver using Chorin projection and GFDM (meshfree and meshgrid methods)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published