morphogen.domain

Simulation domains (boxes) and the voxel grids that discretize them.

Conventions used throughout morphoGen:

  • a domain is the axis-aligned box [origin, origin + size);

  • a voxel grid of shape (nx, ny, nz) splits the domain into equal voxels, voxel (i, j, k) being centred at origin + (i + 1/2, j + 1/2, k + 1/2) * spacing;

  • arrays are indexed [i, j, k] along (x, y, z); file writers convert to the x-fastest order used by VTK, MetaImage and FFT codes.

class morphogen.domain.Domain(size: tuple[float, float, float], origin: tuple[float, float, float] = (0.0, 0.0, 0.0), periodic: bool = True, unit: str = '')[source]

Bases: object

Axis-aligned box in which microstructures are generated.

Parameters:
  • size (tuple[float, float, float]) – Edge lengths (a single value for a cube), in the length unit of the study.

  • origin (tuple[float, float, float]) – Lower corner of the box.

  • periodic (bool) – If true the box is a torus: grains, fibres and cells wrap around the faces so that the sample tiles space (periodic boundary conditions, FFT solvers). If false the sample is an unbiased window cut from the infinite random medium.

  • unit (str) – Name of the length unit (metadata only, e.g. "um").

classmethod cube(length: float, *, periodic: bool = True, origin=(0.0, 0.0, 0.0), unit: str = '')[source]

Cubic domain of edge length.

property lower: ndarray
property upper: ndarray
property center: ndarray
property lengths: ndarray
property volume: float
property surface_area: float
property diagonal: float
dilated(margin: float) → Domain[source]

Non-periodic box enlarged by margin on every side.

contains(points) → ndarray[source]

Boolean mask of the points lying in [lower, upper).

wrap(points) → ndarray[source]

Bring points back into the box by periodicity.

distance_to_box(points) → ndarray[source]

Euclidean distance from points to the box (0 inside).

grid(shape=None, *, voxel_size=None) → Grid[source]

Voxel grid covering the domain.

Give either shape (an integer is the number of voxels along the longest edge, voxels being as cubic as possible; or three integers) or voxel_size.

to_dict() → dict[source]
class morphogen.domain.Grid(domain: Domain, shape: tuple[int, int, int])[source]

Bases: object

Regular voxel grid over a domain (see the module docstring for conventions).

property spacing: ndarray
property origin: ndarray
property n_voxels: int
property voxel_volume: float
centers(axis: int) → ndarray[source]

Coordinates of the voxel centres along axis.

center_points(k_start: int = 0, k_stop: int | None = None) → ndarray[source]

Voxel centres of the slab k_start <= k < k_stop as an (n, 3) array.

Points are ordered like array[:, :, k_start:k_stop].ravel() (C order).