Finite Difference Method Using 5-Point Stencil for Laplace Equation on Rectangular Domains

Resource Overview

Iterative Solution of Laplace Equation on Rectangular Domains Using Finite Difference 5-Point Stencil Method

Detailed Documentation

The Laplace equation is a fundamental partial differential equation commonly encountered in mathematical physics with wide applications across engineering and scientific fields. Solving the Laplace equation using finite difference methods represents a classical numerical approach, where the 5-point stencil method serves as one of the most prevalent discretization schemes. For Laplace equations defined on rectangular domains, the core concept of the 5-point stencil iterative method involves discretizing the continuous domain into grid points. At each interior grid point, central difference approximations are employed to estimate second-order derivatives, thereby transforming the partial differential equation into a system of difference equations. Specifically, the function value at each interior point can be expressed as the arithmetic average of values from its four adjacent grid points (top, bottom, left, right). In code implementation, this corresponds to creating a 2D grid matrix where each interior point (i,j) is updated using the formula: u_new[i,j] = 0.25*(u[i-1,j] + u[i+1,j] + u[i,j-1] + u[i,j+1]). The iterative solution process typically employs either Jacobi or Gauss-Seidel iteration methods. The Jacobi method requires simultaneous updating of all grid points using values from the previous iteration, which can be implemented using double buffering technique where old and new grid arrays alternate between iterations. The Gauss-Seidel method, conversely, utilizes immediately updated neighboring values during the iteration process, typically achieving faster convergence through sequential in-place updates that leverage the most recent computational results. To ensure iterative convergence, specific stability conditions must be satisfied, which are closely related to the selection of discretization step sizes. In programming practice, this often involves setting appropriate relaxation factors and convergence thresholds. In practical computations, boundary condition discretization requires careful handling. For Dirichlet boundary conditions, boundary point values are directly prescribed as fixed constants in the code. For Neumann boundary conditions, virtual grid points (ghost points) need to be introduced and specially processed through difference approximations of boundary derivatives. Through multiple iterations, when the difference between successive iteration results falls below a predefined tolerance threshold (e.g., measuring the maximum absolute difference or root mean square error across all grid points), the numerical solution is considered converged.