morphogen.design.tiles

Tile sets for combinatorial design: cubic building blocks with labelled faces.

A tile is a cubic block of k^3 voxels (its geometry) whose six faces carry integer labels. Two tiles can be neighbours along an axis when the labels of the faces in contact match: equal labels (match="equal", Wang tiles), or opposite labels (match="opposite": a face that moves out against a face that moves in). An assembly is an array of tile indices; it is compatible when every pair of neighbouring tiles matches. Faces are numbered -x, +x, -y, +y, -z, +z (face 2 a is the lower face along axis a, 2 a + 1 the upper one). Planar tile sets (dims=2) ignore the z faces: their assemblies have one tile through the thickness.

Built-in sets:

polarized_blocks

The building blocks of combinatorial mechanical metamaterials (after Coulais et al. 2016): each block has a single deformation mode in which it elongates along its axis and shrinks along the two others, or the reverse. Its faces move out or in accordingly; neighbouring blocks are compatible when their common face moves the same way (out of one block, into the other). Six tiles: three axes, two signs.

pipe_tiles

Nodes with channels (or struts) towards some of their faces; compatible assemblies are networks without dead ends at the tile boundaries, with controlled node degrees.

class morphogen.design.tiles.TileSet(faces: ndarray, match: str = 'equal', voxels: ndarray | None = None, weights: ndarray | None = None, names: tuple[str, ...] | None = None, dims: int = 3)[source]

Bases: object

Tiles with labelled faces, their geometry and their weights.

Parameters:
  • faces (numpy.ndarray) – Integer labels (n, 6) of the faces -x, +x, -y, +y, -z, +z.

  • match (str) – equal or opposite: rule for the labels of faces in contact.

  • voxels (numpy.ndarray | None) – Optional geometry (n, k, k, k) ((n, k, k, 1) for planar sets): phase of each voxel of each tile.

  • weights (numpy.ndarray | None) – Relative frequencies of the tiles in random choices (default: equal).

  • names (tuple[str, ...] | None) – Tile names.

  • dims (int) – 3, or 2 for planar tile sets (z faces ignored).

property n_tiles: int
property tile_size: int | None

Voxels per tile edge (None without geometry).

label_matches(upper, lower)[source]

Whether an upper face label (of the lower tile) matches a lower face label.

compatibility() → ndarray[source]

Boolean array (3, n, n): [a, A, B] when tile B may follow tile A along axis a (planar sets: every pair along z).

boundary_tiles(axis: int, side: int, label: int) → ndarray[source]

Tiles whose face (axis, side) matches a boundary of the given label.

mismatches(assembly, periodic: bool = True) → int[source]

Number of incompatible pairs of neighbouring tiles.

is_compatible(assembly, periodic: bool = True) → bool[source]
assemble(assembly) → ndarray[source]

Voxels of an assembly: the blocks of its tiles side by side.

subset(keep) → TileSet[source]

The tiles selected by a boolean mask or an index list.

with_rotations() → TileSet[source]

The set closed under the rotations of the cube (about z for planar sets), without duplicates; rotated tiles keep the weight of their original.

morphogen.design.tiles.polarized_blocks(size: int = 8, channel: float = 0.25, dims: int = 3) → TileSet[source]

Blocks with one deformation mode: elongation along their axis and contraction along the others (sign +), or the reverse (sign -).

The faces normal to the axis carry the sign of the mode, the others its opposite (+1: the face moves out); faces in contact must move the same way, hence opposite labels (match="opposite"). Along every line of blocks, the strain along the line alternates in sign. The geometry is a solid block pierced along its axis by a channel of radius channel (in block edges), which draws the orientation of the block; replace it with the geometry of an actual building block if needed.

morphogen.design.tiles.pipe_tiles(size: int = 8, radius: float = 0.2, dims: int = 3, *, open_probability: float = 0.5, degrees=None) → TileSet[source]

Nodes joined to some of their faces by straight pipes (phase 1).

One tile per subset of open faces (64 in 3D, 16 in 2D); open faces carry the label 1 and must face open faces (match="equal"). Each open face independently has probability open_probability (tile weights p^m (1 - p)^(2 d - m) for m open faces); degrees restricts the numbers of open faces allowed (e.g. no 1 to forbid dead ends).