morphogen.models.tpms

Triply periodic minimal surface (TPMS) architectures.

class morphogen.models.tpms.TPMSStructure(domain, surface, variant, level, cell_size, **kwargs)[source]

Bases: Microstructure

Solid {phi <= level} (network) or {|phi| <= level} (sheet).

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**3 sub-samples per voxel).

level_set(shape=None, *, voxel_size=None, grid: Grid | None = None) → VoxelImage[source]

First-order signed distance (phi - t) / |grad phi| (negative in the solid).

contains(points) → ndarray[source]

Whether points lie in phase 1.

lipschitz: float = 1.5

The first-order distance is a distance near the surface; margin for its curvature

level_set_at(points, reach: float = inf) → ndarray[source]

(phi - t) / |grad phi| at the points, as level_set().

summary() → dict[source]

Counts and sizes describing the realization.

class morphogen.models.tpms.TPMS(surface: str = 'gyroid', cell_size: float | tuple = 1.0, variant: str = 'network', level: float | None = None, volume_fraction: float | None = None, *, anisotropy: Anisotropy | None = None)[source]

Bases: Model

TPMS lattice: gyroid, Schwarz P (primitive), Schwarz D (diamond) or Neovius.

network: solid {phi <= level}; sheet: solid {|phi| <= level} (walls around the minimal surface). Give the level or the target volume fraction (solid fraction), from which the level is computed on a fine sampling of the unit cell.

phases: ClassVar[dict[int, str]] = {0: 'void', 1: 'solid'}

Meaning of the phase indices of the voxel images.

count_label: ClassVar[str] = 'unit cells'

Objects counted by expected_count() (fibres, spheres, cells…).

property iso_level: float
solid_fraction() → float[source]

Volume fraction of the solid for the current level (numerical).

generate(domain: Domain, seed: int | SeedSequence | Generator | None = None) → TPMSStructure[source]

One realization of the model in domain.

expected_count(domain: Domain) → float[source]

Number of unit cells in the domain.

theory(domain: Domain | None = None) → dict[str, float][source]

Theoretical morphological characteristics known in closed form (may be empty).

Some values depend on the domain (e.g. the intensity implied by a number of cells).