Solving the Two-Dimensional Poisson Equation by the Finite-Difference Method

(A comparative study of some simple methods in Python)

Authors

  • Altankhuu Bayarsaikhan Department of Physics, School of Arts and Sciences, National University of Mongolia
  • Gantumur Tsogtgerel Department of Mathematics and Statistics, McGill University

DOI:

https://doi.org/10.22353/physics.v39i631.10622

Keywords:

Poisson equation, computational fluid dynamics, finite-difference method, Neumann boundary condition, Python, numerical methods, differential equations, Discrete cosine transform

Abstract

Simulating incompressible lid-driven cavity flow requires solving the Navier–Stokes equations, where the pressure Poisson solve is often the dominant computational cost in pressure–velocity coupling schemes. This motivates Poisson solvers that are straightforward to implement, fast, and sufficiently accurate. In this work, we solve the two-dimensional Poisson equation on a
square grid using a second-order five-point finite-difference discretization with homogeneous Neumann boundary conditions. We benchmark representative direct methods (dense-matrix LU factorization, sparse-matrix LU factorization, and a discrete cosine transform (DCT) approach) against simple stationary iterative methods (Jacobi, Gauss–Seidel, and successive overrelaxation).
All solvers are implemented in Python 3.12 using NumPy, SciPy, and Numba in a Jupyter Notebook/Lab workflow on an Intel i7 quad-core laptop (4 CPUs, 8 threads, 2.3GHz base) with 16GB RAM under Windows. In our tests, the DCT-based solver is the fastest and most memory-efficient among the direct methods, followed by sparse LU. Among the iterative methods, Numba-accelerated SOR is the fastest when the relaxation parameter is chosen near its optimal value, but it remains slower and less accurate than the direct solvers considered here. The novelty of this work is a transparent, tool-specific benchmark of these standard methods on clearly documented commodity hardware, yielding concrete runtime and memory comparisons that can be reused in similar studies. Our focus is the practical selection of an easy-to-use Poisson solver that remains performant;
integrating the selected solver into full incompressible cavity-flow simulations is left for future work.

Downloads

Download data is not yet available.

References

Anderson, J. D. Computational Fluid Dynamics: The Basics with Applications. McGraw-Hill,

Ferziger, J. H., Peri´c, M., and Street R. L. Computational Methods for Fluid Dynamics (4th

ed.). Springer, 2020.

Schumann, U. and Sweet, R. A. A Direct Method for the Solution of Poisson’s Equation with

Neumann Boundary Conditions on a Staggered Grid of Arbitrary Size. Journal of Computational

Physics, 20(2):171–182, 1976.

Evans, L. C. Partial Differential Equations (2nd ed.). AMS, 2010.

Strauss, W. A. Partial Differential Equations: An Introduction (2nd ed.). Wiley, 2007.

Harris, C.R., Millman, K.J., and van der Walt, S.J. et al. Array Programming with Numpy.

Nature, 585:357–362, 2020.

Virtanen, P., Gommers, R., and Oliphant, T.E. et al. Scipy 1.0: fundamental algorithms for

scientific computing in Python. Nat Methods, 17(3):261–272, 2020.

Lam, Siu Kwan, Pitrou, Antoine, and Seibert, Stanley. Numba: a LLVM-based Python JIT

compiler. In Proceedings of the Second Workshop on the LLVM Compiler Infrastructure in

HPC, 2015.

Demmel, James W. Applied Numerical Linear Algebra. Society for Industrial and Applied

Mathematics, 1997.

Golub, G. H. and Van Loan, C. F. Matrix Computations (4th ed.). Johns Hopkins, 2013.

Hackbusch, W. Iterative Solution of Large Sparse Systems of Equations. Springer, 1994.

Strang, Gilbert. The discrete cosine transform. SIAM Review, 41(1):135–147, 1999.

Hockney, R.W. A Fast Direct Solution of Poisson Equation Using Fourier Analysis. Journal

of Alternative and Complementary Medicine, 12(1):95–113, 1965.

Swarztrauber, P. N. Cyclic Reduction, Fourier Analysis and FACR for Poisson. SIAM Review,

(3):490–501, 1977.

Trottenberg, U., Oosterlee, C. W., Sch¨uller, A. Multigrid. Academic Press, 2001.

Sauer, Timothy. Numerical Analysis (2nd ed.). Pearson, 2012.

Cassel, Kevin W. Matrix, Numerical, and Optimization Methods in Science and Engineering.

Cambridge University Press, 2021.

Young, D. M. Iterative Solution of Large Linear Systems. Academic Press, 1971.

Frankel, S. P. Convergence Rates of Iterative Treatments of PDEs. Math. Comp., 4:65–75,

Greenbaum, Anne. Iterative Methods for Solving Linear Systems. Society for Industrial and

Applied Mathematics, 1997.

Barrett, R., Berry, M., Chan, T. F. et al. Templates for the Solution of Linear Systems: Building

Blocks for Iterative Methods, 2nd Edition. Society for Industrial and Applied Mathematics,

Iserles, A. A First Course in the Numerical Analysis of Differential Equations. Cambridge

University Press, 1996.

Newman, Marc. Computational Physics. CreateSpace, 2012.

Parter, S. V. Estimates for Multigrid Based on Red–Black GS. Numer. Math., 52:701–723,

Numpy Reference Manual (stable), 2025.

Numba User Guide (stable), 2025.

Downloads

Published

2026-03-31