61e12f1Write the solver in MATLAB and compile it to WebGPUJeremy Magland 1% Allen-Cahn on the unit sphere. One species: interfaces form and then coarsen
2% until one domain swallows the sphere.
3%
4% du/dt = eps2*lap(u) + u - u^3
5%
6% Diffusion is implicit in spherical-harmonic space, where lap is diagonal with
7% eigenvalues -l(l+1); the reaction is explicit on the grid, giving one IMEX
8% Euler step. Provided by the caller: synth/analys (the transforms), lam =
9% l(l+1) per coefficient, noise (the seeded perturbation), and the parameters.
10% Grid fields are npts x 1; spectral fields are real 2 x nlm (row 1 real part,
11% row 2 imaginary), so no complex arithmetic is needed. Each function returns
12% the new spectral state followed by the grid fields to display.
14function [U, u] = init(noise)
15 U = analys(noise);
16 u = synth(U);
17end
19function [Un, u] = step(U, lam, eps2, dt)
20 u = synth(U);
21 Un = (U + dt * analys(u - u.^3)) ./ (1 + (dt * eps2) * lam);
22end