morphogen.models.lattice_field¶
Microstructures defined cell by cell on a regular lattice.
Cellular automata and lattice growth processes (nucleation and growth, aggregation) produce a phase per cell, and sometimes a label per cell (grains). Such a realization is resolution-independent like the other microstructures:
on its own lattice, it voxelizes to its cells exactly;
elsewhere, the indicator of phase 1 (or a continuous field, such as a concentration, when the process has one) is interpolated trilinearly, after an optional Gaussian smoothing of
smoothingcells, and thresholded; labels are taken from the nearest cell;its level set is smooth across the interface, so that conforming meshes (MMG) follow the cells’ boundaries, rounded at the corners.
- class morphogen.models.lattice_field.LatticeField(domain: Domain, phases, *, labels=None, orientations=None, smoothing: float = 0.0, field=None, threshold: float = 0.0, attributes: dict | None = None, **kwargs)[source]¶
Bases:
MicrostructureA phase (and optionally a label) per cell of a regular lattice of the domain.
- Parameters:
phases –
uint8array(nx, ny, nz)(nz = 1for 2D structures, extruded through the thickness of the domain).labels – Optional
int32array of the same shape: grain index per cell (-1: none, e.g. untransformed matrix).orientations – Optional crystal orientations of the labels (Bunge Euler angles, degrees).
smoothing – Gaussian smoothing, in cells, of the indicator of phase 1 before interpolation (0: plain trilinear interpolation, which keeps one-cell features).
field – Optional continuous field per cell (e.g. a concentration) whose excursion
field > thresholdis phase 1: it is interpolated instead of the indicator, which gives smoother interfaces.threshold – Optional continuous field per cell (e.g. a concentration) whose excursion
field > thresholdis phase 1: it is interpolated instead of the indicator, which gives smoother interfaces.attributes – Per-label arrays (e.g. nucleation times) and other JSON-able data.
- property shape: tuple[int, int, int]¶
- property cell_size: ndarray¶
- property binary: bool¶
- property has_labels: bool¶
Whether
labels(...)gives an image of cell indices (cells, grains).
- property lipschitz: float¶
The largest slope of the trilinear interpolant of the lattice values.
- level_set_at(points, reach: float = inf) ndarray[source]¶
level_at(): the level set of the lattice interpolated at the points.
- voxelize(shape=None, *, voxel_size=None, grid: Grid | None = None, supersampling=1)[source]¶
Phase image (uint8), or partial volume fractions of phase 1 (float32) when
supersampling > 1(supersampling**3sub-samples per voxel).
- level_set(shape=None, *, voxel_size=None, grid: Grid | None = None) VoxelImage[source]¶
Interpolated level set, negative in phase 1:
threshold - fieldfor structures with a continuous field, otherwise(1/2 - indicator) * scale, about the signed distance to the interface near it (scaleis the cell size, timessqrt(2 pi)times the smoothing when it exceeds one cell).
- labels(shape=None, *, voxel_size=None, grid: Grid | None = None) VoxelImage[source]¶
Image of the cell labels (int32 grain indices; -1: no grain), sampled from the nearest cell.