FLUID FLOW THROUGH A POROUS MEDIUM USING MATLAB
Porous media flow governs a remarkably wide range of physical phenomena from groundwater migration through aquifers and oil recovery from petroleum reservoirs, to fluid transport in biological tissues and filtration in industrial systems. At the heart of all these processes lies a deceptively simple empirical relationship: Darcy's Law. This project implements a 2D numerical solver for incompressible fluid flow through a porous reservoir, grounding the physics in the continuity equation coupled with Darcy's Law and solving the resulting pressure equation using the Two-Point Flux Approximation (TPFA) method, a simplified finite volume scheme well-suited to reservoir simulation.
The governing system reduces to an elliptic PDE for pressure, which is discretized on a uniform Cartesian grid. The TPFA scheme approximates inter-cell fluxes using a distance-weighted harmonic average of cell permeabilities, assembles a sparse symmetric linear system, and solves it efficiently using MATLAB's built-in sparse solvers. Once the pressure field is known, the velocity flux components in the x and y directions are recovered directly from Darcy's Law.
Two simulation cases are presented. The first uses a coarse 8×8 grid with homogeneous, isotropic permeability, modeling the classic quarter-five-spot problem, with an injection well at one corner, driving flow toward a production well at the opposite corner, with no-flow boundary conditions on the remaining sides. Since the permeability is uniform, the flux field is smooth, and the pressure decays monotonically from the source to the sink. The second case refines the grid to 32×32 and introduces a spatially heterogeneous permeability field drawn from a log-normal distribution, with three-point smoothing applied to regularize sharp discontinuities. Here, the flux contours reveal localized channeling effects: flow preferentially concentrates where permeability is high and is impeded where it is low, while the overall pressure gradient from injector to producer is preserved.
The MATLAB implementation is compact and modular, making it straightforward to extend to different grid sizes, permeability fields, and well configurations, offering a clean entry point into the numerics of subsurface flow modeling.