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.
Approach
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).
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.
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.
Formed the linear system αLu = -κ - αb_bc and solved directly using MATLAB's backslash operator, which employs UMFPACK sparse direct factorization.
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.
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.
Key Findings
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.
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.
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.
Skills Demonstrated
- Finite Difference Discretization
- Sparse Matrix Assembly
- Crank-Nicolson Time Stepping
- L² Error Convergence Criteria
- Ghost Cell Boundary Treatment
- MATLAB
- Sparse Linear Systems
- UMFPACK Direct Factorization
- Backslash Operator
- LaTeX Report Writing
- 2D Heat Transfer Modeling
- Mixed Boundary Conditions
- Mesh Independence Study
- Steady-State vs. Transient Analysis
- PDE Formulation