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.
squaresquares (cubes in 3D): the grid of
morphogen.automata.lattice, as a tiling;triangularequilateral triangles: 3 edge and 12 vertex neighbours;
hexagonalregular hexagons (honeycomb cells): 6 neighbours, each sharing an edge;
penrosethe 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_beenkerthe 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 ofICOSAHEDRAL_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 bywindow_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
namewhose mean area (volume foricosahedral) iscell_size**2(**3): Penrose’s thick and thin rhombi (areassin 72°andsin 36°times the squared edge, in the ratio of the golden mean τ), Ammann-Beenker’s squares and 45° rhombi (areas 1 and1/√2, in the ratio1 : √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 areassin 72°andsin 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 orderorder(one, or one per axis) of the quasi-periodic tilingname.They are the unit vectors
e_jof its grids (make_tiling()) with their irrational ratios made rational, scaled along each axis to integers: τ replaced byF_{k+1}/F_kin the components(1, (τ - 1)/2, -τ/2, -τ/2, (τ - 1)/2)(times2 F_k) and(0, 1, 1/τ, -1/τ, -1)(timesF_{k+1}) of the Penrose grids, and in the axes(±1, τ, 0)and their cyclic permutations (timesF_k) of the icosahedral ones;√2replaced byH_k/P_k(Pell numbers, so that1 + √2becomesP_{k+1}/P_k) in the Ammann-Beenker grids. Columnais the period along axisaof the multigridx . g_j + γ_j ∈ Z, in Z^n: the multigrid has the period 1 along each axis ofx, and its dual tiling, of edgese_j(the same tiles), the periodsum_j g_ja e_j, along axisa(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 tilingnamewhose tiles are those of mean areacell_size**2(volume**3),tile_edge():√5 τ^kby2 sin 72° τ^kedges for Penrose rhombi,(1 + √2)^kfor Ammann-Beenker tiles (a square), and the cube of edge2 τ^(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:
objectCells 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,edgesandmoore: the cells withinfloor(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 withinradiuscell 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
radiuscell 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 withadjacency("faces").Periodic tilings are the affine images
Sof Voronoi tilings: a face of areaAnormal to the offsetnof the centres becomesA |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^2of golden rhombi, unless an approximant is fitted to its box (their images byS).
- 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)withw = A / dfor the face of measureA(length or area) between centresdapart (two-point fluxes), so thatlap(u)_i = sum_j w_ij (u_j - u_i) / V_i(V_ithe 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).anglesis 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;indexis de Bruijn’s indexsum_j K_jof the vertex, folded tomin(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: kindsangles, 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 coordinationZ; its cells number2 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 onsamplespoints drawn uniformly in the box of the window (about 0.59 of them fall in it): an estimate withinsqrt(f (1 - f) / (0.59 samples))of each frequencyf, 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:
objectNeighbourhood of the cells of a tiling on which a rule acts: the counterpart of
LatticeContext, for states holding one value per cell.n_neighboursis a number, or an array when cells differ (Penrose tilings, edges of finite patches).
- 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(seeLATTICES) of the boxorigin + [0, size].dims=2: one layer of planar cells through the thickness of the box;dims=3: layers of prismscell_sizehigh (planar tilings), or thebcc,fccandicosahedrallattices.offsets: the offsets of the grids of a quasi-periodic tiling, drawn fromrngwhen 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 orderk >= 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.