# Phase-Field

2D periodic order-parameter dynamics for Cahn-Hilliard (conserved) and Allen-Cahn (non-conserved) gradient flows. The double-well potential `f(φ) = (1/4)(φ²-1)²` favors pure phases `φ = ±1`; the gradient term `ε²/2 |∇φ|²` penalizes sharp interfaces.

## Equations

Free energy: `F[φ] = ∫ [f(φ) + ε²/2 |∇φ|²] dV`
Chemical potential: `μ = δF/δφ = f'(φ) - ε² ∇²φ`

- **Allen-Cahn** (non-conserved): `∂φ/∂t = -M μ`
- **Cahn-Hilliard** (conserved): `∂φ/∂t = M ∇²μ`

Forward Euler time stepping. The biharmonic operator in CH is stiff: stable dt scales like `~ h⁴ / (π⁴ ε² M)`. Reduce `dt` or increase `ε` if the run diverges.

## Validation

- **Mass conservation (CH):** mean φ stays bounded to round-off across a run; the discretized Laplacian-of-μ is anti-symmetric so mass drift is structural-zero on a periodic grid.
- **Gradient flow descent (AC):** free energy `F[φ]` monotonically decreases (circle bubble init shrinks under curvature; energy drops accordingly).
- **Coarsening exponent (CH):** at late times the characteristic length `L(t) ∝ t^{1/3}` per the Lifshitz-Slyozov-Wagner law. The engine fits a power-law slope on the late 70% of the run.

## Substrate framing

2D phase-field cells live on a planar slice of the toroidal pentagon mesh. The natural extension to 3D substrate-resolved dynamics is to map φ over each pentagon's attachment surface and run the same RK time stepper per pentagon — at which point the GMDBS substrate provides multigrid acceleration of the biharmonic operator for free.

## Parameters

| Field | Meaning | Default |
|-------|---------|---------|
| nx, ny | grid dimensions | 64 |
| box_length | physical L | 1.0 |
| n_steps | forward-Euler steps | 2000 |
| dt | time step (mind biharmonic CFL) | 1e-4 |
| mobility M | gradient-flow rate constant | 1.0 |
| eps | interface width parameter | 0.02 |
| model | `cahn_hilliard` or `allen_cahn` | cahn_hilliard |
| init | `random_spinodal` / `tanh_strip` / `circle` | random_spinodal |
