Lattices

Each cell occupies a site on a lattice. A lattice provides a mapping between coordinates and indices of the underlying array.

N.B.: The structures are not true lattices, because they do not extend to infinity, but have finite size.

Currently, the following lattices are provided

They are subtypes of RealLattice. Populations without spatial structure "live" on a NoLattice.

Warning

Avoid manipulating the data field of a lattice directly. Doing so easily leads to an inconsistent state between lattice and metadata.

Use the getter and setter methods for Population instead.

Lattice Types

GrowthDynamics.Lattices.CubicLatticeType
CubicLattice

Three dimensional primitive cubic lattice. Each site has six equidistant neighbors with a fourfold rotational symmetry in each of the three planes.

See https://en.wikipedia.org/wiki/Cubic_crystal_system

Fields

  • a: lattice constant
  • data: underlying array

Example

julia> using GrowthDynamics.Lattices

julia> l = CubicLattice(1/2, ones(16,16,16))
CubicLattice{Float64, Array{Float64, 3}}(0.5, [1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0; … ; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0;;; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0; … ; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0;;; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0; … ; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0;;; … ;;; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0; … ; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0;;; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0; … ; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0;;; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0; … ; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0])

julia> neighbors(l, (8,8,8))
6-element StaticArraysCore.MVector{6, CartesianIndex{3}} with indices SOneTo(6):
 CartesianIndex(7, 8, 8)
 CartesianIndex(9, 8, 8)
 CartesianIndex(8, 7, 8)
 CartesianIndex(8, 9, 8)
 CartesianIndex(8, 8, 7)
 CartesianIndex(8, 8, 9)

julia> coord.(Ref(l), ans)
6-element StaticArraysCore.MVector{6, GeometryBasics.Point{3, Float32}} with indices SOneTo(6):
 [3.0, 3.5, 3.5]
 [4.0, 3.5, 3.5]
 [3.5, 3.0, 3.5]
 [3.5, 4.0, 3.5]
 [3.5, 3.5, 3.0]
 [3.5, 3.5, 4.0]
source
GrowthDynamics.Lattices.FCCLatticeType
FCCLattice

Three dimensional face-centered cubic lattice. Each site has twelve neighbors.

See https://en.wikipedia.org/wiki/Cubic_crystal_system

Fields

  • a: lattice constant
  • data: underlying array

Example

julia> using GrowthDynamics.Lattices

julia> l = FCCLattice(1/2, ones(16,16,16))
FCCLattice{Float64, Array{Float64, 3}}(0.5, [1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0; … ; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0;;; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0; … ; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0;;; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0; … ; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0;;; … ;;; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0; … ; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0;;; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0; … ; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0;;; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0; … ; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0])

julia> neighbors(l, (8,8,8))
12-element StaticArraysCore.MVector{12, CartesianIndex{3}} with indices SOneTo(12):
 CartesianIndex(7, 8, 8)
 CartesianIndex(9, 8, 8)
 CartesianIndex(9, 7, 8)
 CartesianIndex(7, 7, 8)
 CartesianIndex(7, 8, 9)
 CartesianIndex(8, 7, 9)
 CartesianIndex(9, 8, 9)
 CartesianIndex(8, 8, 9)
 CartesianIndex(7, 8, 7)
 CartesianIndex(8, 7, 7)
 CartesianIndex(9, 8, 7)
 CartesianIndex(8, 8, 7)

julia> coord.(Ref(l), ans)
12-element StaticArraysCore.MVector{12, GeometryBasics.Point{3, Float32}} with indices SOneTo(12):
 [1.5, 3.75, 1.75]
 [2.0, 3.75, 1.75]
 [2.0, 3.25, 1.75]
 [1.5, 3.25, 1.75]
 [1.5, 3.5, 2.0]
 [1.75, 3.25, 2.0]
 [2.0, 3.5, 2.0]
 [1.75, 3.75, 2.0]
 [1.5, 3.5, 1.5]
 [1.75, 3.25, 1.5]
 [2.0, 3.5, 1.5]
 [1.75, 3.75, 1.5]
source
GrowthDynamics.Lattices.HexagonalLatticeType
HexagonalLattice

Each site has six equidistant neighbors with a sixfold rotational symmetry.

See https://en.wikipedia.org/wiki/Hexagonal_lattice

Fields

  • a: lattice constant
  • data: underlying array

Example

julia> using GrowthDynamics.Lattices

julia> l = HexagonalLattice(1/2, ones(32,32))
HexagonalLattice{Float64, Matrix{Float64}}(0.5, [1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0; … ; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0])

julia> neighbors(l, (16,16))
6-element StaticArraysCore.MVector{6, CartesianIndex{2}} with indices SOneTo(6):
 CartesianIndex(15, 16)
 CartesianIndex(15, 17)
 CartesianIndex(16, 17)
 CartesianIndex(17, 17)
 CartesianIndex(17, 16)
 CartesianIndex(16, 15)

julia> coord.(Ref(l), ans)
6-element StaticArraysCore.MVector{6, GeometryBasics.Point{2, Float32}} with indices SOneTo(6):
 [7.5, 6.0621777]
 [8.0, 6.0621777]
 [8.25, 6.4951906]
 [8.0, 6.928203]
 [7.5, 6.928203]
 [7.25, 6.4951906]
source

Each lattice type except NoLattice derives from RealLattice and implements the following methods

Common Methods

Dictionaries.indexFunction
index(L, p)

Index of the coordinate p closest to the nearest site on lattice L. p is a GeometryBasics.Point.

source
GrowthDynamics.Lattices.nneighborsFunction
nneighbors(L, I)

Boundary-aware number of nearest neighbors of site I on lattice L.

Example

julia> using GrowthDynamics.Lattices

julia> l = HexagonalLattice(1/2, ones(32,32))
HexagonalLattice{Float64, Matrix{Float64}}(0.5, [1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0; … ; 1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0])

julia> nneighbors(l, (5,5))
6

julia> nneighbors(l, (1,5))
4

julia> nneighbors(l, (1,1))
2
source

Radial geometries

Populations often grow with approximate radial symmetry. One might then be interested in for example grouping cells with respect to their distance from an origin.

GrowthDynamics.Lattices.isonshellFunction
isonshell(L::RealLattice, p, r, o)

Determine whether a lattice point p is on a shell with radius r wrt. the origin o. A shell is defined as the collection of points with |(p-o)|≤r+a/2 where a is the lattice spacing.

source