Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Solutions · 12. Diffuse interfaces and the linear theory of spinodal decomposition

School of Engineering, Nazarbayev University

Worked solutions to the three exercises of Lecture 12. Each solution is computed here and checked with assert statements against an exact identity or an independent calculation. The first code cell sets up the notebook and runs Demonstration 1 of the lecture without showing its output, because some of the solutions use its variables.

Exercise 1

Problem. On a periodic domain L=40.0L = 40.0 (N=256N = 256), construct a smooth two-interface slab c(x)=12[tanh⁡((x−10)/ℓw)−tanh⁡((x−30)/ℓw)]c(x) = \frac{1}{2}[\tanh((x - 10)/\ell_w) - \tanh((x - 30)/\ell_w)] for W=4.0,κ=0.5W = 4.0, \kappa = 0.5, evaluate phase_field.ginzburg_landau_free_energy_1d, and verify across three (W,κ)(W, \kappa) pairs that F[c]=2σ=2κW/18\mathcal{F}[c] = 2\sigma = 2\sqrt{\kappa W / 18} to within 10-5.


Exercise 1: Periodic Two-Interface Slab Free Energy F[c] == 2 * sqrt(kappa * W / 18)
====================================================================================
W=4.0, kappa=0.5 (l_w=0.500) | F_1d = 0.66666667 | 2*sigma = 0.66666667 | rel err = 6.22e-11
W=2.0, kappa=0.5 (l_w=0.707) | F_1d = 0.47140452 | 2*sigma = 0.47140452 | rel err = 2.36e-16
W=4.0, kappa=1.0 (l_w=0.707) | F_1d = 0.94280904 | 2*sigma = 0.94280904 | rel err = 2.36e-16

Explanation. On a periodic ring [0,L)[0, L), a precipitate domain (c≈1c \approx 1 on (10,30)(10, 30), c≈0c \approx 0 elsewhere) is bounded by two planar α/β\alpha/\beta interfaces at x=10x = 10 and x=30x = 30. Because f(0)=f(1)=0f(0) = f(1) = 0 in the bulk plateaus and L/2=20≫ℓwL/2 = 20 \gg \ell_w, the entire Ginzburg–Landau integral concentrates inside the two transition zones, yielding F[c]=2σ=2κW/18\mathcal{F}[c] = 2\sigma = 2\sqrt{\kappa W / 18}.


Exercise 2

Problem. Verify that equilibrium_interface_profile_1d raises ValueError when W <= 0 or kappa <= 0, and check numerically on cahn_hilliard_1d_fd (L=32,M=1,W=2,κ=0.5L = 32, M = 1, W = 2, \kappa = 0.5) that Δt=0.05\Delta t = 0.05 is stable at N=32N = 32 (Δx=1.0\Delta x = 1.0) yet blows up at N=64N = 64 (Δx=0.5\Delta x = 0.5) due to the Δx4\Delta x^4 biharmonic CFL penalty.


Exercise 2: Parameter Positivity Guard & 16x Biharmonic CFL Collapse Under 2x Grid Refinement
=============================================================================================
N=32 (dx=1.0, dt_crit ~ 0.2500): dt=0.05 stable = True, F_end = 1.9652
N=64 (dx=0.5, dt_crit ~ 0.0156): dt=0.05 blew up = True

Explanation. Whereas second-order Fickian diffusion has Δtcrit∝Δx2\Delta t_{\mathrm{crit}} \propto \Delta x^2 (4×4\times smaller when Δx\Delta x is halved), the fourth-order Cahn–Hilliard operator −Mκ∂x4c-M\kappa \partial_x^4 c scales as kNyq4∝Δx−4k_{\mathrm{Nyq}}^4 \propto \Delta x^{-4}, shrinking Δtcrit\Delta t_{\mathrm{crit}} by 24=16×2^4 = 16\times (from 0.25 down to 0.0156) and motivating semi-implicit spectral time stepping.


Exercise 3

Problem. Implement my_cahn_hilliard_1d_spectral(c_init, L, dt, n_steps, M=1.0, W=1.0, kappa=1.0) in pure NumPy using np.fft.fft and np.fft.ifft, verify its final composition profile matches phase_field.cahn_hilliard_1d_spectral to < 1e-13, and verify ∣cˉ(T)−cˉ(0)∣<10−14|\bar{c}(T) - \bar{c}(0)| < 10^{-14}.


Exercise 3: Implement It Yourself — 1-D Semi-Implicit Fourier Spectral Cahn-Hilliard Solver
===========================================================================================
Max |c_mine - c_lib| = 0.000e+00 | Conservation drift |<c(T)> - <c(0)>| = 5.551e-17

Summary. Diagonalizing the fourth-order operator ∂x4→k4\partial_x^4 \to k^4 via FFT reduces each semi-implicit Cahn–Hilliard step to two 1-D FFTs and pointwise division by 1+ΔtMκk41 + \Delta t M\kappa k^4, guaranteeing exact k=0k = 0 solute conservation and handling of biharmonic stiffness.