Lattice interface

This guide walks through the AbstractLattice interface — the minimum a concrete lattice must implement, the trait-based extension points, and the default methods that come for free.

For the physics and mathematical background, see the concept column Lattices and unit cells.

The abstract type

abstract type AbstractLattice{D, T} end

The two type parameters are:

  • D::Int — the physical dimension (1, 2, 3, ...)
  • T<:Real — the numeric type used to store positions (typically Float64)

Nothing else lives in the type parameters. Boundary conditions, topology, indexing, and site types are all stored as fields on the concrete subtype, and dispatched through multiple dispatch and trait objects.

Required interface

A concrete subtype must implement these:

MethodReturns
num_sitesInt
positionSVector{D, T}
neighborsAbstractVector{Int} (pinpoint)
boundaryLatticeBoundary
site_layoutAbstractSiteLayout
size_traitAbstractSizeTrait

num_sites may be undefined — or may throw — when the lattice's size_trait is InfiniteSize.

Free defaults

Once the required methods are in place, LatticeCore derives:

Trait-based extension

Extension points use value types rather than flags, so dispatch stays compile-time. The main traits are:

API reference