61e12f1Write the solver in MATLAB and compile it to WebGPUJeremy Magland 1% Brusselator reaction-diffusion on the unit sphere. Turing stripes and spots,
2% from a smaller diffusivity contrast than Schnakenberg but a stiffer reaction.
3%
4% du/dt = D1*lap(u) + A - (B+1)*u + u^2*v
5% dv/dt = D2*lap(v) + B*u - u^2*v
6%
7% Diffusion is implicit in spherical-harmonic space, where lap is diagonal with
8% eigenvalues -l(l+1); the reaction is explicit on the grid, giving one IMEX
9% Euler step. Provided by the caller: synth/analys (the transforms), lam =
10% l(l+1) per coefficient, noise (the seeded perturbation), and the parameters.
11% Grid fields are npts x 1; spectral fields are real 2 x nlm (row 1 real part,
12% row 2 imaginary), so no complex arithmetic is needed. Each function returns
13% the new spectral state followed by the grid fields to display.
15function [U, V, u, v] = init(noise, A, B)
16 U = analys(A + noise);
17 V = analys((B / A) * ones(numel(noise), 1));
18 u = synth(U);
19 v = synth(V);
20end
22function [Un, Vn, u, v] = step(U, V, lam, A, B, D1, D2, dt)
23 u = synth(U);
24 v = synth(V);
25 uuv = u .* u .* v;
26 Un = (U + dt * analys(A - (B + 1) * u + uuv)) ./ (1 + (dt * D1) * lam);
27 Vn = (V + dt * analys(B * u - uuv)) ./ (1 + (dt * D2) * lam);
28end