Partial Differential Equations in 2D
Gierer-Meinhardt and Gray-Scott
This session builds directly on the 1D PDE workflow. We move from a line to a rectangular grid, keep the same vectorized finite-difference and explicit Euler ideas, compare zero-flux, Dirichlet, and periodic boundary conditions, and then switch to the Gray-Scott model for richer two-dimensional pattern formation (Gray and Scott 1984; Pearson 1993).
From PDEs in 1D to PDEs in 2D
In the previous session on PDEs in 1D, you built a solver on an interval and used Turing instability to predict which spatial modes should grow.
In this session we keep the same logic, but the geometry becomes richer:
- A 1D field becomes a 2D grid.
- The second derivative becomes a 5-point Laplacian stencil.
- Single mode numbers become mode pairs on a rectangle.
- Static solvers become full 2D simulations and interactive experiments.
The main idea does not change. Local interaction still creates global structure. The difference is that the geometry now allows spots, stripes, fronts, and labyrinths.
Case Studies
We continue the Gierer-Meinhardt story by extending the solver to two spatial dimensions.
Then we switch reaction terms and build the Gray-Scott model, which is the main simulator for this session. Numerically, the workflow is almost unchanged. Conceptually, the main difference is that periodic boundaries become the natural default.
After that, we turn the simulation into an interactive experiment with drawing, pause-resume, and sliders.
When all the ingredients are in place, you will combine them in the assignment.
Learning Goals
- Implement a 2D Laplacian with
np.roll(). - Implement Neumann, Dirichlet, and periodic boundary conditions on a rectangular grid.
- Connect domain geometry with unstable spatial modes.
- Simulate reaction-diffusion systems on a rectangular grid.
- Build a Gray-Scott simulator with periodic boundary conditions.
- Add basic interaction with drawing, pause-resume, and sliders.
Flow of This Session
- Extend the 1D workflow to a 2D rectangular grid.
- Compare the predicted unstable modes with 2D Gierer-Meinhardt patterns.
- Build the Gray-Scott model, keep the same solver, and switch to periodic boundaries.
- Add interaction so the PDE becomes a live experiment.
- Complete the assignment.
Numerical Workflow
Every page in this session follows the same numerical loop:
- Create a spatial grid.
- Approximate the Laplacian with vectorized finite differences.
- Evaluate the reaction terms.
- Update the fields with Euler’s method.
- Enforce or exploit the boundary conditions.
- Plot, animate, or interact with the result.
What Do We Need?
numpy
We store spatial fields in NumPy arrays and use np.roll() to access neighboring grid points.
matplotlib.pyplot
We initialize figures, axes, labels, and static plot elements.
matplotlib.animation
We update images frame by frame to animate the PDE dynamics.
matplotlib.backend_bases
We handle mouse clicks and key presses for interactive experiments.
matplotlib.widgets
We use sliders on the Gray-Scott interaction page.
Why not use scipy.solve_ivp here?
The key numerical work is still spatial discretization plus explicit updates at every grid point. In two dimensions, that bookkeeping becomes even more central, so we keep using direct Euler loops.
If your 1D solver still feels shaky, revisit the previous session first. The 2D code is much easier once the 1D stencil and Euler update are routine.
Explicit Euler is simple and transparent, but it is only conditionally stable. If a simulation explodes immediately, reduce dt, increase dx, or test on a smaller grid first.