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.
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.CubicLattice — TypeCubicLatticeThree 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 constantdata: 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]GrowthDynamics.Lattices.FCCLattice — TypeFCCLatticeThree dimensional face-centered cubic lattice. Each site has twelve neighbors.
See https://en.wikipedia.org/wiki/Cubic_crystal_system
Fields
a: lattice constantdata: 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]GrowthDynamics.Lattices.HexagonalLattice — TypeHexagonalLatticeEach site has six equidistant neighbors with a sixfold rotational symmetry.
See https://en.wikipedia.org/wiki/Hexagonal_lattice
Fields
a: lattice constantdata: 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]GrowthDynamics.Lattices.LineLattice — TypeLineLatticeOne dimensional lattice.
Fields
a: lattice spacingdata
GrowthDynamics.Lattices.NoLattice — TypeNoLattice{T}Dummy 'lattice' for systems without spatial structure."
Each lattice type except NoLattice derives from RealLattice and implements the following methods
Common Methods
GrowthDynamics.Lattices.coord — Functioncoord(L, I)Coordinate of index I on the lattice L. I is either a tuple of integers, or an appropriate CartesianIndex.
Dictionaries.index — Functionindex(L, p)Index of the coordinate p closest to the nearest site on lattice L. p is a GeometryBasics.Point.
GrowthDynamics.Lattices.coordination — FunctionCoordination number of the lattice.
GrowthDynamics.Lattices.dimension — FunctionDimension of the lattice. Functionally equivalent to ndims(lattice.data).
GrowthDynamics.Lattices.midpoint — Functionmidpoint(L)Return the index of the point nearest to the geometeric center of the lattice L.
GrowthDynamics.Lattices.midpointcoord — Functionmidpointcoord(L)Return the coordinate of the point nearest to the geometeric center of the lattice L.
GrowthDynamics.Lattices.neighbors — Functionneighbors(L::RealLattice, I)Vector of neighbors of index I. ReturnsVector{CartesianIndex{dimension(L)}}``.
Does not check for bounds.
GrowthDynamics.Lattices.neighbors! — Functionneighbors!(n, L, I)In-place version of neighbors.
Use n = Neighbors(L) to allocate an appropriate vector.
GrowthDynamics.Lattices.nneighbors — Functionnneighbors(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))
2GrowthDynamics.Lattices.density — Functiondensity(L::RealLattice{T}, I)Calculates (occupied sites)/(no. of neighbors)
"Occupied" is defined as not equal to zero(T).
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.shell — Functionshell(L::CubicLattice, r, o=midpointcoord(L))Return indices of shell of radius r around o.
GrowthDynamics.Lattices.isonshell — Functionisonshell(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.
GrowthDynamics.Lattices.conicsection — Functionconicsection(L, points, Ω; axis, o)Filter those points that lie within a conic section of opening angle Ω around axis emanating from origin o.