Basics
Coordinate Types
LatticeTools.CarteCoord — TypeCarteCoordCartesian coordinates. Vector{Float64}.
LatticeTools.FractCoord — TypeFractCoordFractional coordinates.
Fields
whole::Vector{Int}: Integer part of fractional coordinatesfraction::Vector{Float64}: [0,1) part of fractional coordinates
Functions
LatticeTools.FractCoord — MethodFractCoord(w, f)Arguments
w::AbstractVector{<:Integer}: whole part of the coordinatef::AbstractVector{<:Real}: fractional part. In [0, 1).
LatticeTools.FractCoord — MethodFractCoord(coord)Create a FractCoord from coord, where whole is determined by fld(x, 1) and fraction by mod(x, 1).
Arguments
coord::AbstractVector{<:Real}
LatticeTools.FractCoord — MethodFractCoord(ndim)Construct a zero FractCoord of ndim dimensions.
Arguments
ndim::Integer: spatial dimensions
LatticeTools.fract2carte — Methodfract2carte(latticevectors, fc)Arguments
latticevectors::AbstractArray{<:Real, 2}: square matrix whose columns are lattice vectors.fc::FractCoord: fractional coordinates
LatticeTools.carte2fract — Methodcarte2fract(latticevectors, cc; tol=√ϵ)Arguments
latticevectors::AbstractArray{<:Real, 2}: square matrix whose columns are lattice vectors.cc::CarteCoord: cartesian coordinatestol::Real=Base.rtoldefault(Float64): tolerance
UnitCell
LatticeTools.UnitCell — TypeUnitCell{O}Represent a unitcell of a lattice, which contains sites at fixed locations (does not yet implement multiple orbitals per site). It is recommended to use makeunitcell rather than the constructor to make a UnitCell object.
Parameters
O: type of "site". Any type can be used, but we recommend usingStringor tuple ofStringandIntfor compatibility with JSON.
Fields
latticevectors::Array{Float64, 2}: Lattice vectorsreducedreciprocallatticevectors::Array{Float64, 2}: Reduced reciprocal lattice vectors (transpose of inverse oflatticevectors)reciprocallatticevectors ::Array{Float64, 2}: Reciprocal lattice vectors.2π * reducedreciprocallatticevectorssites::Vector{Tuple{T, FractCoord}}: List of sites within unit cellsiteindices::Dict{T, Int}: Indices of sites
LatticeTools.makeunitcell — Functionmakeunitcell(latticevectors; SiteType=Any, tol=√ϵ)Construct an n-dimensional lattice.
Arguments
latticevectors: Lattice vectors. Can be a nested array of lattice vectors, or a two-dimensional array whose columns are lattice vectors, or a real number.
Optional Arguments
SiteType::DataTypetol=√ϵ: Epsilon
Functions
LatticeTools.dimension — Functiondimension(fc::FractCoord)Dimension of the fractional coordinates
Arguments
fc::FractCoord: Fractional coordinates.
dimension(cube::Hypercube)Return the spatial dimension of the hypercube.
dimension(uc)Spatial dimension of the unit cell.
dimension(lattice)Spatial dimension of the lattice.
Arguments
lattice::Lattice
dimension(arg::IdentityOperation)Return the spatial dimension of the identity operation.
dimension(arg::TranslationOperation)Spatial dimension of the translation operation
dimension(arg::PointOperation)Return spatial dimension of arg.
dimension(arg::SpaceOperation)Return the spatial dimension of arg.
dimension(sym::TranslationSymmetry)Spatial dimension of the translation symmetry
dimension(sym::PointSymmetry)Spatial dimension of the point symmetry
LatticeTools.numsite — Functionnumsite(unitcell)Number of sites of the unit cell.
Arguments
uc ::UnitCell
LatticeTools.sitecount — Functionsitecount(unitcell)Number of sites of the unit cell.
Arguments
uc ::UnitCell
LatticeTools.addsite! — Functionaddsite!(unitcell, sitename, sitecoord)Add an site to the unit cell.
Arguments
uc ::UnitCell{T}sitename ::{T}sitecoord ::FractCoord
LatticeTools.hassite — Functionhassite(unitcell, name)Test whether the unit cell contains the site of given name.
Arguments
unitcell::UnitCell{O}name::O
LatticeTools.getsite — Functiongetsite(unitcell, name)Get the site (its site name and its fractional coordinates) with the given name.
Arguments
unitcell::UnitCell{O}name::O
Return
(sitename, fractcoord)
getsite(unitcell, index)Arguments
unitcell::UnitCellindex::Integer
Return
(sitename, fractcoord)
LatticeTools.getsiteindex — Functiongetsiteindex(unitcell, name)Get index of the given site.
Arguments
unitcell::UnitCell{O}name::O
LatticeTools.getsitecoord — Functiongetsitecoord(unitcell, name)Get the fractional coordinates of the site with the given name.
Arguments
uc ::UnitCell{O}name ::O
Return
fractcoord
getsitecoord(unitcell, index)Arguments
unitcell::UnitCellindex::Integer
Return
FractCoord
LatticeTools.getsiteindexcoord — Functiongetsiteindexcoord(unitcell, name)Arguments
unitcell::UnitCell{T}name::T
Return
(index, fractcoord)
LatticeTools.getsitename — Functiongetsitename(unitcell, index)Arguments
uc::UnitCellindex::Integer
Return
sitename
LatticeTools.carte2fract — Methodcarte2fract(unitcell, cartecoord; tol=√ϵ)Arguments
unitcell::UnitCellcc::CarteCoordtol::Real=Base.rtoldefault(Float64)
LatticeTools.fract2carte — Methodfract2carte(unitcell, fractcoord)Arguments
unitcell::UnitCellfractcoord::FractCoord
LatticeTools.whichunitcell — Functionwhichunitcell(unitcell, name, cartecoord; tol=√ϵ)
Return
Vector{Int}: the integer coordinate of the unitcell that the specified site/cartesian coordinate belongs to.
whichunitcell(unitcell, name, fractcoord; tol=√ϵ)Return
Vector{Int}: the integer coordinate of the unitcell that the specified site/fractional coordinate belongs to.
LatticeTools.momentumgrid — Methodmomentumgrid(unitcell, shape)Generate an n-dimensional grid of momenta of given shape.
Returns an n-dimensional array of the following form: math k[i_1, i_2, \ldots ] = G \cdot ( \frac{i_1}{n_1}, \frac{i_2}{n_2}, \ldots )` where G is the reciprocal lattice vector
LatticeTools.findsiteindex — Functionfindsiteindex(unitcell::UnitCell, fc::FractCoord; tol=√ϵ)Find the index of the site, and the unitcell coordinate at the specified fractional coordinate.
Arguments
unitcell::UnitCellfc::FractCoord
Returns
(site_index, unitcell_vector), or(-1, [])if not found.
Hypercube
LatticeTools.Hypercube — TypeHypercube(shape)Represent a hypercubic (Bravais) lattice.
Fields
shape_matrix: a matrix whose columns are the lattice vectors of theinverse_shape_matrix:(shape_matrix)wrap: periodic wrapping function which takes an integer array, and maps it onto a site in the Bravais lattice. Analogous tofldmod.
LatticeTools.dimension — Methoddimension(cube::Hypercube)Return the spatial dimension of the hypercube.
LatticeTools.volume — Methodvolume(cube::Hypercube)Return the signed volume of the hypercube, defined by the determinant of the shape.
LatticeTools.isequiv — Methodisequiv(lhs::Hypercube, rhs::Hypercube)Check whether the two hypercubes are equivalent.
LatticeTools.find_generators — Methodfind_generators(cube::Hypercube)Find generators of an Hypercube. For one-dimensional lattice, which is isomorphic to Zₙ, the generator is +1. For two-dimensional lattices, this function invokes find_generators_2d. Higher dimensions are currently not supported.
LatticeTools.find_generators_2d — Methodfind_generators_2d(cube::Hypercube)Find translation generators of an Hypercube.
LatticeTools.generate_coordinates — Methodgenerate_coordinates(cube, generators)Generate a list of coordinates of the hypercube
Arguments
cube::Hypercubegenerator_translations::AbstractMatrix{<:Integer}
Lattice
LatticeTools.Lattice — TypeLattice{O}Represent a lattice.
Arguments
unitcell::UnitCell{O}hypercube::Hypercubebravais_coordinates::Vector{Vector{Int}}supercell::UnitCell{Tuple{O, Vector{Int}}}
LatticeTools.makelattice — Functionmakelattice(unitcell, shape)Create a Lattice from unitcell and shape. Generating translations are fouond using find_generators.
Arguments
unitcellshape: shape of the cluster
makelattice(unitcell, shape, [generators])Create a lattice with periodic boundary condition, using the unitcell, shape, and translation generators.
Arguments
unitcell::UnitCell{O}shape_matrix::AbstractMatrix{<:Integer}: shape of the Bravais lattice. This can also be
a single integer, which is equivalent to a identity matrix times the number.
Optional Arguments
generator_translations::AbstractMatrix{<:Integer}
makelattice(unitcell, scale)Construct a Lattice with unitcell having shape scale. Works for one-dimensional lattice.
LatticeTools.dimension — Methoddimension(lattice)Spatial dimension of the lattice.
Arguments
lattice::Lattice