Skip to content

SwiftHohenberg

Systems / ODEs / Spatial fields

The prototype pattern-forming PDE — stripes and hexagons from a single scalar field near a finite-wavelength instability.

continuous · ODE1024 dimensionspatterns

Start here

Python
import tsdynamics as ts

system = ts.systems.SwiftHohenberg()
traj = system.run(final_time=50.0, dt=0.1, seed=0)
ts.plot(traj)

traj.t contains the sample times and traj.y the state array; system.info shows the defaults. In a notebook the last line displays the plot. In a Python script, call .show() on it to open a window, or .save("trajectory.svg") to export it.

With an adaptive ODE solver, dt sets the output spacing; rtol and atol control local integration error. For a fixed-step solver, reduce dt to check numerical convergence.

Illustration: N=64 · r=0.4 · simulation window: 30–100 · forward/reverse playback

Evolving spatial field — press play to follow the snapshots

This finite simulation illustrates one initial condition and view. The diagnostics below report their own inputs and observation windows.

Dynamics at the default parameters

Lyapunov exponents measure separation rates along an orbit. The Kaplan–Yorke dimension is derived from those rates, not a direct geometric measurement. Finite runs depend on the initial condition, transient and observation window; a value near zero needs a convergence check.

Lyapunov spectrum
Not computed: The default spatial discretisation has 1024 states. Its tangent spectrum is outside this catalogue computation budget; choose a grid and k explicitly.
Kaplan–Yorke dimension
Not computed: A numerical Lyapunov spectrum is required.
Divergence ∇·f
Symbolic summary
$1024 r - 1024 + \frac{8388608.0}{L^{2}} - \frac{21474836480.0}{L^{4}}$ (constant part of $\nabla\!\cdot f$)
+ per-cell nonlinear terms (over the 1024-cell field)
Method and evidence

+ per-cell nonlinear terms (over the 1024-cell field)

Equilibria / fixed points
Not computed: A 1024-state multistart root search is outside this catalogue budget.
Recorded parameters and software
{
  "parameters": {
    "N": 32,
    "L": 40.0,
    "r": 0.3
  },
  "parameter_expressions": {},
  "state_dimension": 1024,
  "explicit_time": false,
  "library_version": "6.0.3",
  "python": "3.14.8",
  "numpy": "2.4.4",
  "scipy": "1.17.1",
  "protocol_version": 1
}

Definition

Python
@staticmethod
def _equations(Y, t, *, N, L, r):
    h = L / N
    inv_h2 = 1.0 / (h * h)
    inv_h4 = inv_h2 * inv_h2

    def idx(rr, cc):
        return (rr % N) * N + (cc % N)

    rhs = []
    for rr in range(N):
        for cc in range(N):

            def u(dr, dc, rr=rr, cc=cc):
                return Y(idx(rr + dr, cc + dc))

            u0 = u(0, 0)
            lap = (u(1, 0) + u(-1, 0) + u(0, 1) + u(0, -1) - 4 * u0) * inv_h2
            # Compact 13-point biharmonic (∇⁴) stencil on a periodic grid.
            bih = (
                20 * u0
                - 8 * (u(1, 0) + u(-1, 0) + u(0, 1) + u(0, -1))
                + 2 * (u(1, 1) + u(1, -1) + u(-1, 1) + u(-1, -1))
                + (u(2, 0) + u(-2, 0) + u(0, 2) + u(0, -2))
            ) * inv_h4
            # u_t = r u - (1 + ∇²)² u - u³ = r u - (u + 2 ∇²u + ∇⁴u) - u³
            rhs.append(r * u0 - (u0 + 2.0 * lap + bih) - u0 * u0 * u0)
    return rhs

Parameters

Symbol Default Role
N 32 grid points per side (structural — changing it recompiles)
L 40 domain length per side
r 0.3 linear growth control (unstable bandwidth)

Explore further

Reference

Swift & Hohenberg (1977), Phys. Rev. A 15, 319-328
doi:10.1103/physreva.15.319

BibTeX
BibTeX
@misc{swifthohenberg,
  title = {SwiftHohenberg system},
  note = {Swift & Hohenberg (1977), Phys. Rev. A 15, 319-328},
  doi = {10.1103/physreva.15.319}
}