PDDO-MultiPhysics Examples Reaction, diffusion and electrochemistry

Gray-Scott pattern formation

Two reacting and diffusing species in a periodic box: a seeded cube grows into a self-replicating three-dimensional pattern.

07_gray_scott_periodic.yaml 110,592 nodes imex-euler, 9 min

1The Problem

In the Gray-Scott model, species v consumes species u autocatalytically while u is fed and v removed. With these feed and kill rates a small perturbation does not die out or fill the box uniformly; it splits and replicates into a pattern that spreads through the whole domain.

$$\frac{\partial u}{\partial t} = D_u\,\nabla^2 u - u v^2 + F(1 - u), \qquad \frac{\partial v}{\partial t} = D_v\,\nabla^2 v + u v^2 - (F + k)\,v$$

2The Problem File

Two scalar fields and two equations, with diffusion marked imp() and the reactions explicit. The initial condition is a cube in the centre of the box, written with heaviside and max(abs(...)), plus a little noise.

The complete problem file, examples/07_gray_scott_periodic.yaml
# Gray–Scott reaction–diffusion (pattern formation), periodic box.
#   dt(u) = Du lap(u) - u v^2 + F (1 - u)
#   dt(v) = Dv lap(v) + u v^2 - (F + k) v
# Diffusion implicit, reactions explicit (IMEX). A perturbed cube in the centre seeds the
# pattern.
"k">name: gray_scott_periodic
"k">domain:
  "k">size: [64, 64, 64]
  "k">n: [48, 48, 48]
  "k">periodic: [true, true, true]
"k">parameters:
  "k">Du: 0.16
  "k">Dv: 0.08
  "k">F: 0.035
  "k">k: 0.065
"k">fields:
  "k">u: scalar
  "k">v: scalar
"k">equations:
  "k">u: "dt(u) = imp(Du*lap(u)) - u*v**2 + F*(1 - u)"
  "k">v: "dt(v) = imp(Dv*lap(v)) + u*v**2 - (F + k)*v"
"k">initial_conditions:
  "k">u: "1 - 0.5*heaviside(8 - max(abs(x - 32), abs(y - 32), abs(z - 32))) + 0.02*(rand() - 0.5)"
  "k">v: "0.25*heaviside(8 - max(abs(x - 32), abs(y - 32), abs(z - 32))) + 0.02*(rand() - 0.5)"
"k">seed: 3
"k">time:
  "k">end: 2000
  "k">dt: 1.0
  "k">scheme: imex-euler
"k">output:
  "k">every: 100
"k">monitors:
  "k">v_mean: "mean(v)"
  "k">v_max: "max(v)"
The model in the GUI: the Model Builder tree on the left, the settings of the selected node in the middle, the graphics window on the right.
Figure 1. The model in the GUI: the Model Builder tree on the left, the settings of the selected node in the middle, the graphics window on the right.
The two reaction-diffusion equations, diffusion implicit.
Figure 2. The two reaction-diffusion equations, diffusion implicit.
Initial values: a perturbed cube in the centre of the box.
Figure 3. Initial values: a perturbed cube in the centre of the box.

3Results

Nodes
48×48×48 = 110,592
Periodic
xyz
PDDO order
2, horizon 2.015 Δx
Time scheme
imex-euler
Steps
2,000 × Δt = 1
Newton iterations
2,000
Factorizations
0
Run time
9 min

The seeded cube breaks up into lobes that split and replicate outward; by t = 2000 the pattern fills the middle of the box and is still spreading, so the mean of v keeps rising, from 0.0040 to 0.0415, while the largest value stays near 0.443.

An isosurface of v at t = 2000: the 3D pattern.
Figure 4. An isosurface of v at t = 2000: the 3D pattern.
v on three slices through the box.
Figure 5. v on three slices through the box.
Mean and largest v against time.
Figure 6. Mean and largest v against time.

4Run It Yourself

The problem file ships with PDDO-MultiPhysics. Open it in the graphical interface and press Compute, or run it from the command line:

python -m pddo_mp gui examples/07_gray_scott_periodic.yaml
python -m pddo_mp run examples/07_gray_scott_periodic.yaml

Results go to results/gray_scott_periodic/ next to the problem file: a ParaView time series (.pvd), the monitors as CSV, and the final state. Any entry can be changed on the command line, for example --set time.end=1000 for a run to half the end time. The user manual describes every part of the problem file and of the interface.

Have a coupled problem of your own?

Send us the physics and the geometry — we will write the problem file with you, or build the model you need.