morphogen.automata.reaction¶
Reaction-diffusion on lattices (continuous-state automata): Gray-Scott model.
Two species u (substrate) and v (activator) react and diffuse (Pearson 1993):
du/dt = D_u lap(u) - u v^2 + F (1 - u) dv/dt = D_v lap(v) + u v^2 - (F + k) v
integrated with explicit Euler steps of unit time on unit cells (7-point Laplacian in
3D, 5-point in 2D), with periodic or zero-flux boundaries. Depending on the feed rate
F and the kill rate k, the activator settles into spots, worms, labyrinths or
holes of a characteristic size (Turing patterns); thresholding v gives two-phase
microstructures.
gray_scott_tiling() integrates the same system on the cells of any tiling
(morphogen.automata.tilings) with the finite-volume Laplacian of the tiling: the
flux through each face is its length or area over the distance between the centres,
divided by the cell’s area or volume (two-point fluxes; the 5- and 7-point Laplacians on
the square tiling). The free edges of finite patches have no flux.
- morphogen.automata.reaction.GRAY_SCOTT_PRESETS = {'holes': (0.039, 0.058), 'labyrinth': (0.037, 0.06), 'spots': (0.03, 0.062), 'worms': (0.046, 0.065)}¶
Feed and kill rates of a few pattern families (with D_u = 0.16, D_v = 0.08).
- morphogen.automata.reaction.gray_scott(shape, rng: Generator, *, feed: float = 0.037, kill: float = 0.06, du: float = 0.16, dv: float = 0.08, steps: int = 3000, seed_fraction: float = 0.1, seed_size: float = 2.0, periodic: bool = True, initial=None, callback=None) tuple[ndarray, ndarray][source]¶
Fields
(u, v)afterstepsexplicit steps from a perturbed uniform state.The initial state is
u = 1, v = 0except in random blobs (a fractionseed_fractionof the cells: the highest values of a noise smoothed overseed_sizecells) whereu = 1/2, v = 1/4, plus 1 % noise; isolated seed cells would vanish by diffusion.initial: the fields(u, v)to start from instead. Stability of the explicit scheme requiresD <= 1/6(3D) or1/4(2D).
- morphogen.automata.reaction.stable_substeps(tiling, du: float, dv: float) int[source]¶
Number of equal substeps of the unit time step that keep the explicit scheme stable on a tiling:
D dt max_i(sum_j w_ij / V_i) <= 1(the eigenvalues of the Laplacian lie within twice that rate, Gershgorin); 1 on the square tiling forD <= 1/(2d), as on the grid.
- morphogen.automata.reaction.gray_scott_tiling(tiling, rng: Generator, *, feed: float = 0.037, kill: float = 0.06, du: float = 0.16, dv: float = 0.08, steps: int = 3000, seed_fraction: float = 0.1, seed_size: float = 2.0, initial=None, callback=None) tuple[ndarray, ndarray][source]¶
Fields
(u, v)(one value per cell oftiling) afterstepstime steps of the Gray-Scott system with the finite-volume Laplacian of the tiling.Diffusion coefficients are in cell sizes squared per step, as on the grid; each unit step is split into
stable_substeps()explicit Euler substeps (one on the square tiling, where the scheme is the grid’s, to round-off). The initial blobs are the highest values of a white noise smoothed by the heat equation overseed_sizecell sizes (a heat kernel of standard deviationseed_size);initial: the fields(u, v)to start from instead.callback(step, u, v)after each step.