// Other  ·  Computational

Computational Fluid Dynamics

Numerical Methods & CFD Solver Development — MATLAB

01 Lid-Driven Cavity Solver Fractional-step Navier-Stokes solver validated against Ghia et al. benchmark 02 2D PDE Solver Poisson & transient heat equation with mixed boundary conditions
// Project 01

Lid-Driven Cavity Flow Solver

Fractional-Step Navier-Stokes Solver — MATLAB — Validated Against Ghia et al. Benchmark

Year 2026
Category Computational Fluid Dynamics
Method Fractional-Step (Chorin-Temam)
Grid Staggered MAC  ·  64×64
Software MATLAB
Validation Ghia et al. Benchmark
Status Complete
// Overview

A 2D incompressible Navier-Stokes solver for the classic lid-driven cavity problem implemented in MATLAB. The solver uses a fractional-step method with second-order central differences on a staggered MAC grid, combining Adams-Bashforth 2 advection with Crank-Nicolson diffusion via a block LU decomposition.

The solver was validated against the benchmark data of Ghia, Ghia, and Shin for Reynolds numbers 100, 400, and 1000 on a 64×64 grid. Agreement with the benchmark is excellent at Re = 100 and 400, and remains good at Re = 1000 where the moderate grid begins to under-resolve the thin boundary layers near the walls.

Key Specs
Method Fractional-Step (Chorin-Temam)
Grid Staggered MAC  ·  64×64
Advection Adams-Bashforth 2 (AB2)
Diffusion Crank-Nicolson (CN)
Spatial Second-order central differences
Boundary Ghost-cell method
Solver Sparse LU factorization (precomputed)
Reynolds Numbers 100  ·  400  ·  1000
Convergence ε = 10&sup7; (Re 100, 400)  ·  5×10&sup7; (Re 1000)
// Methodology

Approach

01
Grid Setup

Staggered MAC grid with ghost cells: u velocity on (N+1)×(N+2) array, v velocity on (N+2)×(N+1) array, pressure on N×N array at cell centers. Wall boundary conditions imposed via ghost cells to ensure exact enforcement of no-slip.

02
Spatial Discretization

Second-order central differences for all derivatives. Discrete Laplacian modified at cells adjacent to walls to account for ghost-cell boundary conditions. Advection evaluated in conservative form with fluxes computed at appropriate staggered locations.

03
Fractional-Step Method

Block LU decomposition of the saddle-point system yields a three-step algorithm: intermediate velocity solve, pressure Poisson equation, velocity correction. Adams-Bashforth 2 extrapolation used for advection, Crank-Nicolson for diffusion.

04
Sparse Linear Solvers

Helmholtz and pressure Poisson systems assembled via Kronecker products of 1D tridiagonal matrices with modified boundary rows. Both systems solved using sparse LU factorization precomputed once at the beginning of the simulation, making each time step efficient.

05
Time Integration

Time step selected to satisfy both advective CFL condition and viscous stability limit. CFL = 0.30 for Re = 100 and 400, CFL = 0.20 for Re = 1000. Integration proceeds until steady-state criterion is met.

06
Validation

Centerline velocity profiles compared against Ghia et al. benchmark data for Re = 100, 400, 1000. Streamline topology, vorticity contours, velocity magnitude, and pressure distribution all examined for physical plausibility.

// Results

Key Findings

Benchmark Validation

Centerline velocity profiles show excellent agreement with Ghia et al. at Re = 100 and 400. At Re = 1000 the 64×64 grid begins to under-resolve thin boundary layers but captures the primary vortex shift and sharp centerline gradients qualitatively.

Streamline Topology

Primary recirculating vortex nearly centered at Re = 100, migrating toward the geometric center as inertia dominates at higher Re. Secondary counter-rotating eddies develop in the lower corners, growing in size and intensity with increasing Reynolds number.

Vorticity & Boundary Layers

Positive vorticity generated at the moving lid, transported downward by the primary vortex. Classical boundary-layer thinning observed with increasing Re — vorticity concentrates near walls while the cavity interior approaches near-uniform vorticity.

Pressure Field

Strong positive pressure in the upper-right corner where the lid-driven flow impinges on the right wall. Low-pressure region in the upper-left. Pressure minimum at the primary vortex center reflects centripetal acceleration. Gradients steepen and distribution becomes more asymmetric with increasing Re.

// Full Report
Complete project report including derivations, implementation details, and validation results — compiled in LaTeX
Download Full Report →
// Project 02
// Project 02

2D PDE Solver

Poisson Equation & Transient Heat Equation

Year 2024
Category Computational Fluid Dynamics
Software MATLAB
Course ME 793 — Computational Fluid Dynamics
Institution University of Nevada, Reno
Status Complete
// Overview

A numerical methods project implementing two PDE solvers in MATLAB for a 2D domain. The first solver targets the steady-state Poisson equation using a sparse Laplacian matrix and MATLAB's backslash operator. The second extends this to the transient heat equation using Crank-Nicolson time integration. Both solvers share the same Laplacian matrix and boundary vector, ensuring consistency between formulations.

The domain features mixed boundary conditions: a sinusoidal Dirichlet temperature profile on the left and top boundaries, a Neumann flux condition on the bottom, and a zero-flux condition on the right. A Gaussian heat source is centered near (0.7, 0.6) in the domain.

Key Specs
Grid Size 25 × 25 interior nodes (625 total)
Solver MATLAB backslash (UMFPACK sparse direct)
Time Step Δt = 5.0
Settling Time t* = 420.0 (~84 time steps)
Convergence L² error < 10&sup4;
Grids Tested 21×21  ·  25×25  ·  31×31
Report LaTeX  ·  Overleaf
// Methodology

Approach

01
Problem Formulation

Defined the 2D Poisson and heat equations on a unit domain with mixed Dirichlet and Neumann boundary conditions. Gaussian heat source centered at (0.7, 0.6).

02
Spatial Discretization

Applied second-order central finite differences on an Nx × Ny interior grid. Assembled a sparse Laplacian matrix L with at most five nonzeros per row — symmetric negative semi-definite.

03
Boundary Conditions

Dirichlet conditions enforced directly. Neumann and flux conditions handled via ghost cells — bottom boundary ghost cell adds flux contribution 2(0.3)/hy to the right-hand side.

04
Poisson Solver

Formed the linear system αLu = -κ - αb_bc and solved directly using MATLAB's backslash operator, which employs UMFPACK sparse direct factorization.

05
Crank-Nicolson

Advanced the heat equation using the unconditionally stable Crank-Nicolson scheme with Δt = 5.0. Reused the same L matrix and boundary vector from the Poisson solver for consistency.

06
Grid Sensitivity

Verified mesh independence on 21×21, 25×25, and 31×31 grids. Confirmed transient solution converges to Poisson steady state at t* = 420.0, validating both implementations.

// Results

Key Findings

Poisson Steady-State Solution

Solution ranges from 0.14 to 1.24, with peak values concentrated in the lower-right region. High values result from the combined influence of the Gaussian heat source, the upward flux at the bottom boundary, and zero-flux accumulation at the right boundary. The left and top boundaries impose sinusoidal profiles creating a characteristic saddle-like structure near y = 1.

Transient Heat Equation Convergence

Starting from a uniform zero initial condition, the Crank-Nicolson scheme converges at t* = 420.0 after approximately 84 time steps. The relative L² deviation from the Poisson steady state drops below 10&sup4;, and the transient solution is visually indistinguishable from the steady state — confirming both solvers are consistent and correctly implemented.

Mesh Independence

Solution structure and maximum values remained consistent across all three grid resolutions (21×21, 25×25, 31×31), confirming the results are mesh-independent and the discretization is correctly converged.

Your browser does not support embedded PDFs. Use the download button below to view the report.
// Full Report Complete project report including derivations, implementation details, and results — compiled in LaTeX
Download PDF →
// Skills

Skills Demonstrated

Numerical Methods
  • Fractional-Step Method (Chorin-Temam)
  • Finite Difference Discretization
  • Staggered MAC Grids
  • Sparse LU Factorization
  • Crank-Nicolson Time Stepping
  • Adams-Bashforth 2 Advection
  • Ghost-Cell Boundary Treatment
Software & Implementation
  • MATLAB
  • Sparse Linear Systems
  • Kronecker Product Assembly
  • LaTeX Report Writing
  • Benchmark Validation
Engineering Analysis
  • Incompressible Navier-Stokes
  • 2D Heat Transfer Modeling
  • Boundary Layer Analysis
  • Reynolds Number Scaling
  • Mesh Independence Studies
  • PDE Formulation
Back ← Portfolio