Advanced maths

Periodic Cahn Hilliard equation calculator with mass conservation checks

Evolve the periodic one-dimensional Cahn–Hilliard equation with conserved mean and checked discrete-energy decrease.

Your numbers

Use x on the periodic unit interval. Example: 0.2*cos(2*pi*x).
Enter finite values within the stated bounds; coordinate rows may use commas.
Enter finite values within the stated bounds; coordinate rows may use commas.
Enter finite values within the stated bounds; coordinate rows may use commas.
Enter finite values within the stated bounds; coordinate rows may use commas.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Evolve the periodic one-dimensional Cahn–Hilliard equation with conserved mean and checked discrete-energy decrease.

THE FORMULAut=M Δμ; μ=u³−u−κ Δu; E=∫[(u²−1)²/4+κ ux²/2]dx.

A worked example

The default0.2cos(2πx) profile on the unit interval evolves to time0.01 with mobility1,kappa0.01; its mean stays near zero and its discrete energy decreases.

Good to know

Periodic unit interval,8/16/32coarse nodes and doubled fine grid;0<T≤0.05,0<M≤2,0.0001≤κ≤0.1. Initial sampled values within±1.5; bounded time-step cap. Stabilized semi-implicit finite-difference evolution, energy-monitored step halving, mesh difference not a rigorous error bound.

A conserved phase-separation equation

Cahn–Hilliard evolution combines a double-well free energy with a penalty on spatial gradients. Its chemical potential drives redistribution through a Laplacian, producing a fourth-order equation in the original field. It is not ordinary heat diffusion or viscous advection with another parameter name.

The page models a one-dimensional periodic unit interval with constant positive mobility. Its field is an abstract phase variable, not an automatically calibrated concentration in a particular material. The choice of double-well energy, mobility and gradient coefficient defines the mathematical model being evolved.

Conserved periodic evolutionPeriodic unit intervalInitial: grayFinal: blue, T = 0.01Mean conserved
Scroll across to see the full diagram.
The default cosine keeps zero mean while its discrete free energy decreases.

Compare this with the Viscous Burgers equation calculator on a periodic unit interval. Evolve a conserved fourth-order phase-separation PDE rather than a second-order viscous advection equation.

Initial profile and periodic domain

Enter a smooth expression in x whose values at zero and one agree. The first and last physical locations are identified by periodicity, so adding a separate fixed endpoint condition would change the problem. Coarse node choices are doubled for the displayed fine-grid solution.

The initial field is sampled at periodic nodes and must stay within the supported amplitude range. A function can agree at its endpoints yet have an incompatible derivative or unresolved fine-scale oscillations, so smooth periodic input remains a stated assumption rather than something inferred from two equal endpoint values.

The cosine worked example

The default initial profile is zero-point-two times cosine of two pi x. Its periodic mean is zero. With mobility one and gradient coefficient zero-point-zero-one, the low spatial mode is in a regime where phase separation can initially amplify its shape rather than simply flatten it like heat diffusion.

The calculation evolves this profile to time zero-point-zero-one. It reports the final sampled field, its mean residual and the discrete energy history. The final energy should not exceed the initial energy under the implemented acceptance check, while the preserved mean should remain at floating rounding scale.

Discretizing the chemical potential

The spatial Laplacian is the centered periodic finite-difference operator. Its Fourier eigenvalues are known explicitly, allowing the stiff linear terms to be solved mode by mode. The nonlinear cubic term is evaluated at the current nodal field, not analytically truncated to a single Fourier mode.

A stabilization term is added and subtracted between time levels, giving a semi-implicit update with a positive diagonal mode denominator. The stabilization strength reflects the current amplitude. This is a numerical time discretization of the stated semidiscrete equation, not an exact closed-form solution of the original PDE.

Mass and energy diagnostics

The zero Fourier mode has zero Laplacian eigenvalue, so the update preserves the discrete mean apart from floating arithmetic. The mass residual compares the final and initial means. It is an absolute diagnostic of the discrete computation, not a measured mass balance for a physical specimen.

Energy is computed from the nodal double-well term and nearest-neighbor gradient penalty. Any attempted step that increases it beyond tolerance is halved and retried. A strict step cap bounds runtime, and failure to resolve acceptable evolution produces no successful trajectory claim.

Refinement is evidence rather than proof

The calculator runs a coarse discretization and a doubled spatial grid with a finer initial time partition. Their values are compared at common nodes. A small difference is useful evidence of resolution, but two discretizations can share a bias or miss an inadequately sampled initial feature.

The energy monitor is also not an unconditional theorem for every possible future state. It checks each accepted numerical update in this bounded run. Keep the distinction between a monitored discrete inequality and a proof of global convergence or an exact continuous free-energy law.

Interpreting a successful run

Inspect the field, mean residual, energy history and refinement difference together. A near-zero mean residual alone cannot establish an accurate spatial profile, and a decreasing energy alone cannot establish a sufficiently small time error. Repeating with more nodes and a shorter time horizon helps assess numerical sensitivity.

For quantitative phase-field research, specify material scaling, boundary conditions, mobility laws and a dedicated convergence study. This educational calculator deliberately excludes arbitrary domains, variable mobility and coupled fluid motion. It exposes a small conserved fourth-order evolution with diagnostics rather than replacing a general PDE solver.

A few questions, answered

Does the equation preserve the mean?

Yes in the periodic model; the calculator reports the numerical mean residual as a check.

Is it the same as the heat equation?

No. Its chemical potential includes a cubic term and a gradient penalty, producing conserved fourth-order dynamics.

Is the mesh difference a certified error bound?

No. It compares two finite computations and is a refinement diagnostic only.

What if energy rises?

The attempted time step is reduced; unresolved energy behavior or the runtime cap causes rejection.

Find your calculator

Start typing to explore the library.