morphogen.automata.tilings

Tilings of the plane and of space: lattices of cellular automata beyond the square grid.

A Tiling is a set of cells (convex polygons in 2D, convex polyhedra in 3D) with their centres, areas or volumes, shapes and adjacency: the CSR lists of the cells sharing a face (an edge in 2D), an edge or a vertex with each cell.

square

squares (cubes in 3D): the grid of morphogen.automata.lattice, as a tiling;

triangular

equilateral triangles: 3 edge and 12 vertex neighbours;

hexagonal

regular hexagons (honeycomb cells): 6 neighbours, each sharing an edge;

penrose

the thick and thin rhombi of Penrose’s quasi-periodic tiling, by de Bruijn’s pentagrid method: 4 edge neighbours, 7 to 11 vertex neighbours; finite patches only;

ammann_beenker

the squares and 45-degree rhombi of the octagonal Ammann-Beenker tiling, by the same method on four grids (the cut-and-project of Z^4): 4 edge neighbours; finite patches;

bcc, fcc (3D)

the Voronoi cells of the body- and face-centred cubic lattices: truncated octahedra (14 faces: 8 hexagons towards the nearest neighbours, 6 squares towards the second ones) and rhombic dodecahedra (12 faces; 18 vertex neighbours);

icosahedral (3D)

the prolate and oblate golden rhombohedra of the icosahedral tiling (Ammann, Kramer & Neri), by the dual method on six grids of planes normal to the fivefold axes of the icosahedron (the cut-and-project of Z^6): 6 face neighbours; finite patches only. Its 24 vertex stars (Tiling.vertex_stars()) have the frequencies of ICOSAHEDRAL_STARS, the shares of its acceptance window (window_stars()).

In 3D, the planar tilings are stacked in layers of prisms (hexagonal: hexagonal prisms, 8 face and 20 vertex neighbours; square: cubes). Cells have the area cell_size**2 (planar tilings; the mean area for quasi-periodic tilings) or the volume cell_size**3, and prisms are cell_size high: every lattice has about as many cells as the square grid of the same cell size.

Periodic tilings fill a box with a whole number of unit cells, scaled along each axis to fit it exactly (the cells are then slightly distorted, like the cells of the square grid of a box whose edges are not multiples of the cell size): the tiling is the affine image of a reference tiling, the Voronoi tessellation of its centres (the triangles are the Voronoi cells of the honeycomb of their centroids), in which points are located by their nearest centre. Quasi-periodic tilings have no period: they cover boxes as finite patches whose cells at the edges have fewer neighbours (free boundaries). Their periodic approximants (approximant: an order k) fill periodic boxes with the same tiles: the rational approximants of the cut-and-project (a phason strain), whose grids replace the golden mean τ by F_{k+1}/F_k (Fibonacci numbers; Penrose rhombi, golden rhombohedra: the cubic approximants 1/1, 2/1, 3/2…) or the silver mean 1 + √2 by P_{k+1}/P_k (Pell numbers; Ammann-Beenker tiles), periodic in a rectangle or a cube (approximant_period()) of which the box holds a whole number, fitted to it like the unit cells of the periodic tilings.

Tiling.diffusion_weights() gives the finite-volume Laplacian of every tiling (the flux through each face: its length or area over the distance between the centres), on which morphogen.automata.reaction.gray_scott_tiling() runs reaction-diffusion.

morphogen.automata.tilings.LATTICES = ('square', 'triangular', 'hexagonal', 'penrose', 'ammann_beenker', 'bcc', 'fcc', 'icosahedral')

the planar tilings (prisms in 3D), then the 3D lattices.

Type:

Lattices of cells

morphogen.automata.tilings.QUASIPERIODIC = ('penrose', 'ammann_beenker', 'icosahedral')

finite patches, never periodic boxes.

Type:

Quasi-periodic tilings

morphogen.automata.tilings.MULTIGRIDS = {'ammann_beenker': (4, 0.7853981633974483), 'penrose': (5, 1.2566370614359172)}

their number and the angle between consecutive ones (unit vectors e_j at angles j * step).

Type:

Grids of lines of the planar quasi-periodic tilings (de Bruijn)

morphogen.automata.tilings.GOLDEN_RHOMBOHEDRA = (0.7608452130361228, 0.4702282018339785)

Volumes of the prolate and oblate golden rhombohedra of unit edge (in the ratio τ).

morphogen.automata.tilings.ICOSAHEDRAL_STARS = {((0, 2, 2, 0), (3, 3, 3, 3)): 0.23606797749978967, ((0, 4, 1, 1), (3, 3, 4, 4, 4)): 0.23606797749978967, ((0, 6, 0, 2), (3, 3, 4, 4, 5, 5)): 0.23606797749978967, ((1, 3, 1, 3), (3, 3, 4, 4, 5, 5)): 0.0557280900008412, ((1, 5, 0, 4), (3, 3, 4, 4, 5, 5, 6)): 0.0557280900008412, ((2, 4, 0, 6), (3, 3, 4, 4, 5, 5, 5, 7)): 0.06888370749726604, ((3, 3, 0, 8), (3, 3, 3, 4, 5, 5, 5, 6, 8)): 0.02631123499284967, ((4, 2, 0, 10), (3, 3, 3, 3, 5, 5, 5, 5, 7, 9)): 0.006211240030283715, ((5, 3, 0, 6), (3, 4, 4, 4, 4, 5, 5, 6, 7)): 0.016261237511566693, ((6, 0, 0, 14), (3, 3, 3, 3, 3, 3, 5, 5, 7, 7, 8, 10)): 0.0038387574509992617, ((6, 2, 0, 8), (3, 3, 4, 4, 4, 5, 5, 5, 7, 8)): 0.0038387574509992617, ((8, 0, 0, 12), (3, 3, 3, 3, 3, 4, 5, 6, 6, 7, 7, 10)): 0.0031056200151418573, ((8, 0, 0, 12), (3, 3, 3, 3, 4, 4, 4, 5, 7, 7, 8, 9)): 0.002372482579284453, ((8, 2, 0, 6), (4, 4, 4, 4, 4, 4, 5, 5, 7, 7)): 0.0031056200151418573, ((10, 0, 0, 10), (3, 3, 3, 3, 3, 5, 6, 6, 6, 6, 6, 10)): 0.0031056200151418573, ((10, 0, 0, 10), (3, 3, 3, 4, 4, 4, 4, 6, 6, 7, 7, 9)): 0.0031056200151418573, ((10, 0, 0, 10), (3, 3, 4, 4, 4, 4, 4, 4, 7, 7, 8, 8)): 0.006944377466141119, ((12, 0, 0, 8), (3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 6, 9)): 0.0007331374358574044, ((12, 0, 0, 8), (3, 4, 4, 4, 4, 4, 4, 5, 6, 7, 7, 8)): 0.0038387574509992617, ((14, 0, 0, 6), (3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 8)): 0.002372482579284453, ((14, 0, 0, 6), (4, 4, 4, 4, 4, 4, 5, 5, 5, 7, 7, 7)): 0.006211240030283715, ((16, 0, 0, 4), (4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 7)): 0.0038387574509992617, ((18, 0, 0, 2), (4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6)): 0.0031056200151418573, ((20, 0, 0, 0), (5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5)): 0.013155617496424835}

The 24 vertex stars of the icosahedral tiling (the kinds of Tiling.vertex_stars()) and their frequencies in the infinite tiling: the shares of its acceptance window, the rhombic triacontahedron, in which the images of the vertices of each star fall (measured there by window_stars(); these expressions of the golden mean sum to 1 and give the mean coordination 6 exactly).

morphogen.automata.tilings.tile_edge(name: str, cell_size: float = 1.0) → float[source]

Edge of the tiles of the quasi-periodic tiling name whose mean area (volume for icosahedral) is cell_size**2 (**3): Penrose’s thick and thin rhombi (areas sin 72° and sin 36° times the squared edge, in the ratio of the golden mean τ), Ammann-Beenker’s squares and 45° rhombi (areas 1 and 1/√2, in the ratio 1 : √2), the prolate and oblate golden rhombohedra (in the ratio τ).

morphogen.automata.tilings.penrose_edge(cell_size: float = 1.0) → float[source]

Edge of the Penrose rhombi whose mean area is cell_size**2 (thick and thin rhombi, of areas sin 72° and sin 36° times the squared edge, in the ratio of the golden mean).

morphogen.automata.tilings.REACH = {'ammann_beenker': 2.030103530256435, 'bcc': 1.2599210498948732, 'fcc': 1.5874010519681994, 'hexagonal': 1.074569931823542, 'icosahedral': 2.7523114397842137, 'penrose': 2.1104656968656057, 'square': 1.0, 'triangular': 1.7547653506033234}

Largest distance between the centres of two cells sharing a vertex, in cell sizes: the reach of one step of a radius-1 neighbourhood (along an axis for the grid). Rhombi and rhombohedra: twice their largest half-diagonal (the thin Penrose rhombus, the 45° rhombus, the prolate rhombohedron along its threefold axis).

morphogen.automata.tilings.approximant_grid(name: str, order) → ndarray[source]

Integer grid vectors g_j (rows, one per grid) of the periodic approximant of order order (one, or one per axis) of the quasi-periodic tiling name.

They are the unit vectors e_j of its grids (make_tiling()) with their irrational ratios made rational, scaled along each axis to integers: τ replaced by F_{k+1}/F_k in the components (1, (τ - 1)/2, -τ/2, -τ/2, (τ - 1)/2) (times 2 F_k) and (0, 1, 1/τ, -1/τ, -1) (times F_{k+1}) of the Penrose grids, and in the axes (±1, τ, 0) and their cyclic permutations (times F_k) of the icosahedral ones; √2 replaced by H_k/P_k (Pell numbers, so that 1 + √2 becomes P_{k+1}/P_k) in the Ammann-Beenker grids. Column a is the period along axis a of the multigrid x . g_j + γ_j ∈ Z, in Z^n: the multigrid has the period 1 along each axis of x, and its dual tiling, of edges e_j (the same tiles), the period sum_j g_ja e_j, along axis a (approximant_period()).

morphogen.automata.tilings.approximant_period(name: str, order, cell_size: float = 1.0) → ndarray[source]

Edges of the rectangular or cuboid period of the approximant of order order (one, or one per axis) of the quasi-periodic tiling name whose tiles are those of mean area cell_size**2 (volume **3), tile_edge(): √5 τ^k by 2 sin 72° τ^k edges for Penrose rhombi, (1 + √2)^k for Ammann-Beenker tiles (a square), and the cube of edge 2 τ^(k+1) / √(2 + τ) for golden rhombohedra. A periodic box holds a whole number of periods along each axis (make_tiling()).

class morphogen.automata.tilings.Tiling(spec: dict, plane: dict | None, solid: dict | None)[source]

Bases: object

Cells of a tiling: centres, shapes, areas or volumes and adjacency.

Build tilings with make_tiling(). Cells are numbered layer by layer for prisms (layer * n_planar + planar_cell). adjacency(kind) gives the CSR lists of the cells sharing a "faces" (an edge in 2D), "edges" or "vertices" with each cell; neighbours() the neighbourhoods of the automata.

property n_cells: int
adjacency(kind: str = 'faces') → tuple[ndarray, ndarray][source]

CSR lists (indptr, indices) of the cells sharing a face (an edge in 2D), an edge or a vertex (kind: faces, edges or vertices) with each cell.

neighbours(neighbourhood: str = 'moore', radius: float = 1) → tuple[ndarray, ndarray][source]

Neighbourhood of every cell (CSR), the counterpart of the grid’s offsets.

von_neumann, edges and moore: the cells within floor(radius) steps across faces (edges in 2D), edges or vertices (on the square grid: the L1, edge and max-norm balls); euclidean: the cells whose centres lie within radius cell sizes, refused when it reaches none (the nearest centres lie 1.075, 1.091 and 1.122 cell sizes apart on undistorted hexagonal, BCC and FCC lattices).

ball(radius: float, include_self: bool = True) → tuple[ndarray, ndarray][source]

Cells whose centres lie within radius cell sizes of each centre (CSR).

counts(state, indptr, indices) → ndarray[source]

Number of cells in state 1 in the CSR neighbourhoods (indptr, indices).

colours(indptr, indices) → ndarray[source]

Colour of each cell such that neighbours (CSR) never share one (greedy).

face_measures() → tuple[ndarray, ndarray, ndarray][source]

Length (2D) or area (3D) of the face shared by each pair of face neighbours: CSR lists (indptr, indices, measures) aligned with adjacency("faces").

Periodic tilings are the affine images S of Voronoi tilings: a face of area A normal to the offset n of the centres becomes A |det S| |S^-1 n| (Nanson). Rhombi and rhombohedra measure the edges and faces they share: the tiles’ edge, and the area (2 / √5) a^2 of golden rhombi, unless an approximant is fitted to its box (their images by S).

diffusion_weights() → tuple[ndarray, ndarray, ndarray][source]

Weights of the finite-volume Laplacian of the tiling, in units of the cell size: CSR lists (indptr, indices, w) with w = A / d for the face of measure A (length or area) between centres d apart (two-point fluxes), so that lap(u)_i = sum_j w_ij (u_j - u_i) / V_i (V_i the cell’s measure, also in cell sizes): the 5- and 7-point Laplacians on the square tiling.

interface_density(state) → float[source]

Fraction of the pairs of cells sharing a face that are in different states.

cell_vertices(i: int) → ndarray[source]

Vertices of cell i: its polygon (counterclockwise, (k, 2)) for planar tilings in 2D, its corners (k, 3) in 3D.

property circumradius: float

Largest distance from a cell centre to its vertices.

locate(points) → ndarray[source]

Index of the cell containing each point ((n, 3); the nearest cell for points outside a finite patch).

cell_index(grid) → ndarray[source]

Index of the cell containing the centre of every voxel of grid (int32 image).

vertex_stars() → dict[tuple, int][source]

Vertex stars of a Penrose, Ammann-Beenker or icosahedral tiling: the number of interior vertices of each kind.

Penrose tilings: kinds (index, angles). angles is the cyclic sequence of the angles of the rhombi around the vertex, in units of 36 degrees (thick rhombi: 2 and 3; thin ones: 1 and 4), smallest over rotations and reflections; index is de Bruijn’s index sum_j K_j of the vertex, folded to min(k, 5 - k) (1 or 2 for Penrose tilings), which separates the stars of five thick rhombi into his S and S5. Ammann-Beenker tilings: kinds angles, in units of 45 degrees (squares: 2; rhombi: 1 and 3).

Icosahedral tilings: the star of a vertex is the set of the golden rhombohedra around it; kinds (corners, valences). corners: the numbers of the cells that meet the vertex by a tip of a prolate rhombohedron (the corner of its three acute angles), by another corner of a prolate one, by a tip of an oblate one (three obtuse angles) and by another corner of an oblate one; valences: the number of cells around each of its edges, sorted (as many as its coordination Z; its cells number 2 Z - 4). These tell apart the 24 stars of the tiling up to the 120 symmetries of the icosahedron (ICOSAHEDRAL_STARS, their frequencies in the infinite tiling); the directions of the edges alone would give 9 kinds. The interior vertices are those around which the solid angles of the cells add up to the whole sphere (all of them in a periodic approximant, whose phason strain leaves a few stars of other kinds).

morphogen.automata.tilings.window_stars(samples: int = 1048576, rng: Generator | None = None) → dict[source]

Frequencies of the vertex stars of the icosahedral tiling by cut and projection (the kinds of Tiling.vertex_stars()): the tiling is the projection of the points of Z^6 whose images in the perpendicular space fall in a window, the rhombic triacontahedron (the zonotope of the six perpendicular axes); a rhombohedron is a cell when its eight corners do, so that the star of a vertex depends only on its image, and the frequency of a star is the share of the window in which the images of its vertices fall. That share is measured here on samples points drawn uniformly in the box of the window (about 0.59 of them fall in it): an estimate within sqrt(f (1 - f) / (0.59 samples)) of each frequency f, independent of the dual method that builds the tilings (ICOSAHEDRAL_STARS: the 24 stars and their frequencies).

class morphogen.automata.tilings.TilingContext(tiling: Tiling, neighbourhood: str = 'moore', radius: float = 1)[source]

Bases: object

Neighbourhood of the cells of a tiling on which a rule acts: the counterpart of LatticeContext, for states holding one value per cell. n_neighbours is a number, or an array when cells differ (Penrose tilings, edges of finite patches).

counts(state: ndarray) → ndarray[source]
interface(state: ndarray) → float[source]
sublattices() → list[ndarray][source]

Classes of cells that are not neighbours (greedy colouring).

morphogen.automata.tilings.PARALLELEPIPED_FACES = array([[0, 2, 6, 4],        [1, 3, 7, 5],        [0, 1, 5, 4],        [2, 3, 7, 6],        [0, 1, 3, 2],        [4, 5, 7, 6]])

The six faces of a parallelepiped, as indices of its corners in _CUBE (around each face: x = 0, 1, y = 0, 1, z = 0, 1).

morphogen.automata.tilings.make_tiling(name: str, size, cell_size: float = 1.0, *, dims: int = 2, periodic: bool = True, origin=(0.0, 0.0, 0.0), offsets=None, rng: Generator | None = None, approximant=None) → Tiling[source]

Tiling name (see LATTICES) of the box origin + [0, size].

dims=2: one layer of planar cells through the thickness of the box; dims=3: layers of prisms cell_size high (planar tilings), or the bcc, fcc and icosahedral lattices. offsets: the offsets of the grids of a quasi-periodic tiling, drawn from rng when not given (uniform, centred): five for the pentagrid of a Penrose tiling (summing to 0; other sums give de Bruijn’s generalized Penrose tilings), four for an Ammann-Beenker tiling, six for an icosahedral tiling (any regular offsets give tilings of the same local isomorphism class). Singular grids, more lines (planes) than the dimension through one point in the box, are refused.

Quasi-periodic tilings tile no periodic box: approximant (an order k >= 1, or one per axis) gives their periodic approximant of that order, the same tiles periodic in a rectangle or a cube (approximant_grid(), approximant_period()). The box holds the nearest whole number of periods along each axis (at least half of one), scaled to fit it exactly like the unit cells of the periodic tilings: the tiles keep their shapes when the box is a multiple of the period.