morphogen.coupling.diffusion

Transient diffusion in voxel images: moisture, oxygen, solvents.

The activity u of the mobile species (relative humidity, oxygen pressure over its value outside) is continuous across interfaces; each phase holds the concentration c = S u (S its solubility, the concentration at equilibrium with the outside) and lets it through with the permeability P = D S (D its diffusivity):

S du/dt = div(P grad u) - k S u

(k an optional first-order consumption). Finite volumes on the voxels: the flux between two neighbours goes through the harmonic mean of their permeabilities (exact for layers in series), the exposed faces hold u (a value or a function of time) half a voxel from the centres of their voxels, the other faces are impermeable or, in periodic images, periodic; implicit Euler steps. The analytic solutions of a slab (Crank 1975, eq. 4.17 and 4.18) check it.

morphogen.coupling.diffusion.DIRECT_LIMIT = 4096

Voxels up to which the steps are solved by sparse LU (one factorization per time step length); preconditioned conjugate gradients beyond.

class morphogen.coupling.diffusion.DiffusionResult(times: ndarray, fields: list[ndarray], uptake: ndarray, saturation: float)[source]

Bases: object

Concentrations c = S u at the requested times and the uptake: the mean concentration over the image at each time, and at equilibrium (saturation).

property relative_uptake: ndarray

M(t) / M_inf.

morphogen.coupling.diffusion.transient_diffusion(image, diffusivity, times, *, solubility=None, exposed=('x-', 'x+'), boundary: float | Callable[[float], float] = 1.0, initial: float = 0.0, consumption=None, steps: int = 40, periodic=None) → DiffusionResult[source]

Diffusion of a species into the phases of image from its exposed faces, held at the activity boundary (a number or a function of time), from a uniform initial activity initial.

diffusivity, solubility (default 1) and consumption (first-order rate, default 0): one number, or a mapping phase -> value. times: the output times, each interval split into steps implicit Euler steps (the first one into steps growing geometrically, for the sqrt(t) start). Axes without exposed faces are periodic in periodic images, impermeable otherwise.

morphogen.coupling.diffusion.slab_uptake(t, thickness: float, diffusivity: float, terms: int = 400) → ndarray[source]

M(t) / M_inf of a slab exposed on both faces (Crank 1975, eq. 4.18): 1 - sum 8 / ((2n + 1)^2 pi^2) exp(-D (2n + 1)^2 pi^2 t / L^2).

morphogen.coupling.diffusion.slab_profile(z, t: float, thickness: float, diffusivity: float, terms: int = 400) → ndarray[source]

c / c_s at the distance z from the middle of the slab (Crank 1975, eq. 4.17).