AbstractLattice API
Auto-generated reference for the AbstractLattice interface. See Lattice interface for the narrative version and Lattices and unit cells for the physical background.
Abstract type
LatticeCore.AbstractLattice — Type
AbstractLattice{D, T}Abstract supertype for lattice types. Type parameters:
D: spatial dimension (integer literal)T: numeric type for real-space positions (typicallyFloat64)
Required interface (concrete subtypes must implement)
position(lat, i)::SVector{D, T}neighbors(lat, i)— iterable of neighbor site indicesboundary(lat)— returns anAbstractBoundaryConditionsize_trait(lat)::AbstractSizeTraitnum_sites(lat)::Int— required forFiniteSize/QuasiInfiniteSizelattices;InfiniteSizelattices should throwDomainError.
Optional interface (defaults provided)
positions(lat)— defaults to an iterator built frompositionbonds(lat)— defaults to an iterator built fromneighborsneighbor_bonds(lat, i)— defaults to an iterator built fromneighborstopology(lat)—TopologyTrait{:unknown}()periodicity(lat)—Aperiodic()is_bipartite(lat)—falsereciprocal_support(lat)—NoReciprocal()is_finite(lat)— derived fromsize_trait
See dev/note/04_architecture/02_lattice_interface/README.md for the design rationale.
Required interface
LatticeCore.num_sites — Function
num_sites(lat::AbstractLattice)::IntNumber of sites in the lattice. Must be implemented by finite concrete types. InfiniteSize lattices should throw DomainError.
Base.position — Function
position(lat::AbstractLattice{D, T}, i::Int)::SVector{D, T}Real-space position of site i. This extends Base.position so that downstream code can write position(lat, i) directly after using LatticeCore.
LatticeCore.neighbors — Function
neighbors(lat::AbstractLattice, i::Int)Indices of sites adjacent to site i (nearest neighbors by default). Concrete types may additionally define neighbors(lat, i; shell) or neighbors(lat, i, shell::Int) to support higher shells.
LatticeCore.boundary — Function
boundary(lat::AbstractLattice)The lattice's boundary condition (subtype of AbstractBoundaryCondition, defined in BoundaryCondition.jl).
LatticeCore.size_trait — Function
size_trait(lat::AbstractLattice) → AbstractSizeTraitSize trait describing the lattice's extent. Must be implemented by concrete types.
LatticeCore.site_layout — Function
site_layout(lat::AbstractLattice) → AbstractSiteLayoutReturn the lattice's site layout. Concrete lattices must either implement this method directly or hold an AbstractSiteLayout in a field of that name.
Derived / default helpers
LatticeCore.dimension — Function
dimension(lat) → IntSpatial dimension D of the lattice.
LatticeCore.positions — Function
positions(lat::AbstractLattice)Iterator over all positions. Default implementation lazily constructs from num_sites and position; works only for finite lattices. Concrete types may override for efficiency.
LatticeCore.is_finite — Function
is_finite(lat::AbstractLattice) → Booltrue if size_trait(lat) is a FiniteSize. Monte Carlo algorithms should guard against non-finite lattices with this predicate.
LatticeCore.num_sublattices — Function
num_sublattices(lat::AbstractLattice) → IntNumber of geometric sublattices in the lattice. Defaults to 1 so lattices that are not sublattice-aware need not override.
LatticeCore.sublattice — Function
sublattice(lat::AbstractLattice, i::Int) → IntGeometric sublattice id (1-based) of site i. Defaults to 1, matching the default num_sublattices of 1.