/ concept-collection / turing-sphere
Sign in
concept-collection / turing-sphere
29 lines · 1.1 KBBlameHistoryRaw
1% Schnakenberg reaction-diffusion on the unit sphere.
2%
3% du/dt = D1*lap(u) + a - u + u^2*v
4% dv/dt = D2*lap(v) + b - u^2*v
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, V, u, v] = init(noise, a, b)
15 us = a + b;
16 vs = b / (us * us);
17 U = analys(us + noise);
18 V = analys(vs * ones(numel(noise), 1));
19 u = synth(U);
20 v = synth(V);
21end
23function [Un, Vn, u, v] = step(U, V, lam, a, b, D1, D2, dt)
24 u = synth(U);
25 v = synth(V);
26 uuv = u .* u .* v;
27 Un = (U + dt * analys(a - u + uuv)) ./ (1 + (dt * D1) * lam);
28 Vn = (V + dt * analys(b - uuv)) ./ (1 + (dt * D2) * lam);
29end
moveopenescclose