0af3386Reaction-diffusion on spherical-harmonic surfacesJeremy Magland 1% Schnakenberg reaction-diffusion on a closed surface.
2%
3% du/dt = D1*lap_g(u) + a - u + u^2*v
4% dv/dt = D2*lap_g(v) + b - u^2*v
5%
62e6cc4Simplify UI text and built-in .m script commentsJeremy Magland 6% Explicit reaction, implicit diffusion (IMEX Euler). The implicit solve
7% splits lap_g = lap_s + dlap: the round-sphere part lap_s is diagonal in
8% spherical-harmonic space (eigenvalues -lam), and the loop iterates the
9% geometric correction dlap from that exact solve. Grid fields are npts x 1;
10% spectral fields are real 2 x nlm.
0af3386Reaction-diffusion on spherical-harmonic surfacesJeremy Magland 11
12function [U, V, u, v] = init(noise, a, b)
13 us = a + b;
14 vs = b / (us * us);
15 U = analys(us + noise);
16 V = analys(vs * ones(numel(noise), 1));
17 u = synth(U);
18 v = synth(V);
19end
21function [Un, Vn, u, v] = step(U, V, lam, gx, gy, gz, a, b, D1, D2, dt, niter)
22 u = synth(U);
23 v = synth(V);
24 uuv = u .* u .* v;
62e6cc4Simplify UI text and built-in .m script commentsJeremy Magland 26 % Right-hand side of the implicit solve (I - dt*D*lap_g) Unew = B.
0af3386Reaction-diffusion on spherical-harmonic surfacesJeremy Magland 27 Bu = U + dt * analys(a - u + uuv);
28 Bv = V + dt * analys(b - uuv);
62e6cc4Simplify UI text and built-in .m script commentsJeremy Magland 30 % Round-sphere solve, then iterate the geometric correction.
0af3386Reaction-diffusion on spherical-harmonic surfacesJeremy Magland 31 Un = Bu ./ (1 + (dt * D1) * lam);
32 Vn = Bv ./ (1 + (dt * D2) * lam);
34 for k = 1:niter
62e6cc4Simplify UI text and built-in .m script commentsJeremy Magland 35 % Placeholder: dlap = lap_g - lap_s is still identically zero, so this
36 % is exactly the round-sphere solver and the geometry is only drawn.
37 % See the README.
39 dLv = 0 * Vn;
40 Un = (Bu + (dt * D1) * dLu) ./ (1 + (dt * D1) * lam);
41 Vn = (Bv + (dt * D2) * dLv) ./ (1 + (dt * D2) * lam);
42 end
43end