projects / proj-math-015
Next task →
Projects/Foundations/Finite-difference Poisson solver on a 2D grid — controlled synthetic benchmark
Level 2 · foundational · ~8 h

Finite-difference Poisson solver on a 2D grid — controlled synthetic benchmark

Solve the Poisson equation with Dirichlet boundary conditions using Jacobi, Gauss-Seidel and multigrid V-cycles, and compare convergence rates. Use a fixed seed, a controlled ground truth, and an ablation grid over the key hyperparameter.
Add to portfolio →

Problem statement

  • 01Solve the Poisson equation with Dirichlet boundary conditions using Jacobi, Gauss-Seidel and multigrid V-cycles, and compare convergence rates. Use a fixed seed, a controlled ground truth, and an ablation grid over the key hyperparameter.

Real-world motivation

  • 01The discrete Laplacian is the bridge between calculus and iterative linear solvers; multigrid shows why local smoothing is not enough. The controlled synthetic benchmark setting forces concrete choices about data, scale and evaluation.

Learning objectives

  • 01Discretize the Laplacian
  • 02Implement three solvers
  • 03Verify the discrete maximum principle
  • 04Report relative error against the analytic ground truth alongside the baseline metrics.

Technical architecture

  • 01five-point stencil
  • 02red-black Gauss-Seidel ordering
  • 03geometric multigrid with bilinear restriction

Mathematical foundations

  • 01$\frac{u_{i+1,j}-2u_{ij}+u_{i-1,j}}{h^2}+\frac{u_{i,j+1}-2u_{ij}+u_{i,j-1}}{h^2}=f_{ij}$
  • 02Jacobi spectral radius $\cos(\pi h)$

Dataset and sources

  • 01synthetic matrices generated with numpy.random.default_rng(42)
  • 02condition numbers 1, 10, 100, 1000

Step-by-step tasks

  • 01Frame the task and freeze the controlled synthetic benchmark evaluation protocol with a fixed random seed.
  • 02Implementation 1: Vectorize stencil updates with numpy slices
  • 03Implementation 2: Implement V-cycle with restriction and prolongation
  • 04Implementation 3: Use the manufactured solution u=sin(pi x)sin(pi y)
  • 05Verification 1: Check discrete residual decreases
  • 06Verification 2: Verify max principle for f=0
  • 07Run the ablation grid and report relative error against the analytic ground truth over three independent trials.

Implementation requirements

  • 01Vectorize stencil updates with numpy slices
  • 02Implement V-cycle with restriction and prolongation
  • 03Use the manufactured solution u=sin(pi x)sin(pi y)
  • 04Log all hyperparameters and the random seed for the controlled synthetic benchmark run.

Testing requirements

  • 01Check discrete residual decreases
  • 02Verify max principle for f=0
  • 03Measure relative error against the analytic ground truth over at least three seeds.

Evaluation metrics

  • 01discrete L2 error
  • 02iterations to 1e-8 residual
  • 03grid convergence order
  • 04relative error against the analytic ground truth

Expected outputs

  • 01solution heatmap
  • 02convergence-by-grid plot

Common failure modes

  • 01Jacobi stalls on fine grids
  • 02red-black ordering breaks naive vectorization
  • 03ill-conditioning above 1e3 makes double precision futile

Stretch goals

  • 01add SOR with optimal omega
  • 02implement conjugate gradient preconditioned by multigrid
  • 03repeat in float32 and quantify the extra error floor

Research extensions

  • 01derive multigrid convergence factor
  • 02study stencil extensions to anisotropic media

GitHub submission requirements

  • 01A repository whose README states the controlled synthetic benchmark protocol and the exact command to reproduce it.
  • 02Source for the scratch implementation, a test file, and a results table with uncertainty estimates.
  • 03A two-page report explaining failures on synthetic matrices generated with numpy.random.default_rng(42) and what the ablation revealed.

Completion rubric

  • 01stencil correct
  • 02three solvers correct
  • 03grid convergence order measured
  • 04Extra credit: repeat in float32 and quantify the extra error floor

Submit when every rubric item is satisfied and your repository contains runnable code plus a reproduction command.