Spatials

QuantumLattices.Spatials.heatmapConstant
@recipe plot(reciprocalspace::BrillouinZone, data::AbstractMatrix{<:Number})
@recipe plot(reciprocalspace::ReciprocalZone, data::AbstractMatrix{<:Number})

Define the recipe for the heatmap visualization of data on a Brillouin/reciprocal zone.

source
QuantumLattices.Spatials.lineConstant
@recipe plot(path::ReciprocalPath, data::AbstractVector{<:Number})
@recipe plot(path::ReciprocalPath, data::AbstractMatrix{<:Number})

Define the recipe for the line visualization of data along a reciprocal path.

source
QuantumLattices.QuantumNumbers.Momentum₁Method
Momentum₁{N}(momentum::AbstractVector{<:Number}, reciprocals::AbstractVector{<:AbstractVector{<:Number}}; atol=atol, rtol=rtol) where N

Construct a 1d quantum momentum by the coordinates.

source
QuantumLattices.QuantumNumbers.Momentum₂Method
Momentum₂{N₁, N₂}(momentum::AbstractVector{<:Number}, reciprocals::AbstractVector{<:AbstractVector{<:Number}}; atol=atol, rtol=rtol) where {N₁, N₂}

Construct a 2d quantum momentum by the coordinates.

source
QuantumLattices.QuantumNumbers.Momentum₃Method
Momentum₃{N₁, N₂, N₃}(momentum::AbstractVector{<:Number}, reciprocals::AbstractVector{<:AbstractVector{<:Number}}; atol=atol, rtol=rtol) where {N₁, N₂, N₃}

Construct a 3d quantum momentum by the coordinates.

source
QuantumLattices.Spatials.AbstractLatticeType
AbstractLattice{N, D<:Number, M}

Abstract type of a unitcell-described lattice.

It should have the following contents:

  • name::Symbol: the name of the lattice
  • coordinates::Matrix{D}: the coordinates of the lattice
  • vectors::SVector{M, SVector{N, D}}: the translation vectors of the lattice
source
QuantumLattices.Spatials.BrillouinZoneMethod
BrillouinZone(reciprocals::AbstractVector{<:AbstractVector{<:Number}}, nk)
BrillouinZone{K}(reciprocals::AbstractVector{<:AbstractVector{<:Number}}, nk) where K
BrillouinZone(::Type{P}, reciprocals::AbstractVector{<:AbstractVector{<:Number}}) where {P<:Momentum}
BrillouinZone{K}(::Type{P}, reciprocals::AbstractVector{<:AbstractVector{<:Number}}) where {K, P<:Momentum}

Construct a Brillouin zone.

source
QuantumLattices.Spatials.LatticeType
Lattice{N, D<:Number, M} <: AbstractLattice{N, D, M}

Simplest lattice.

A simplest lattice can be constructed from its coordinates and translation vectors.

source
QuantumLattices.Spatials.LatticeMethod
Lattice(lattice::AbstractLattice, ranges::NTuple{N, Int}, boundaries::NTuple{N, Union{Char, String, Symbol}}=ntuple(i->'O', Val(N)); mode::Symbol=:nonnegative) where N
Lattice(lattice::AbstractLattice, ranges::NTuple{N, UnitRange{Int}}, boundaries::NTuple{N, Union{Char, String, Symbol}}=ntuple(i->'O', Val(N))) where N

Construct a lattice from the translations of another.

source
QuantumLattices.Spatials.LatticeMethod
Lattice(coordinates::NTuple{N, Number}...; name::Symbol=:lattice, vectors::Union{AbstractVector{<:AbstractVector{<:Number}}, Nothing}=nothing) where N
Lattice(coordinates::AbstractVector{<:Number}...; name::Symbol=:lattice, vectors::Union{AbstractVector{<:AbstractVector{<:Number}}, Nothing}=nothing)

Construct a lattice.

source
QuantumLattices.Spatials.NeighborsMethod
Neighbors(lattice::AbstractLattice, nneighbor::Integer; coordination::Integer=12)

Get the neighbor vs. bond length map of a lattice up to the nneighborth order.

source
QuantumLattices.Spatials.PointMethod
Point(site::Integer, rcoordinate::SVector{N, D}, icoordinate::SVector{N, D}) where {N, D<:Number}
Point(site::Integer, rcoordinate::NTuple{N, <:Number}, icoordinate::NTuple{N, <:Number}=ntuple(i->0, Val(N))) where N
Point(site::Integer, rcoordinate::AbstractVector{<:Number}, icoordinate::AbstractVector{<:Number}=zero(SVector{length(rcoordinate), Int}))

Construct a labeled point.

source
QuantumLattices.Spatials.ReciprocalCurveMethod
ReciprocalCurve(curve::AbstractVector{<:NTuple{N, Number}}) where N
ReciprocalCurve(curve::AbstractVector{<:AbstractVector{<:Number}})
ReciprocalCurve{K}(curve::AbstractVector{<:NTuple{N, Number}}) where {K, N}
ReciprocalCurve{K}(curve::AbstractVector{<:AbstractVector{<:Number}}) where K

Construct a curve in the reciprocal space.

source
QuantumLattices.Spatials.ReciprocalPathMethod
ReciprocalPath(reciprocals::AbstractVector{<:AbstractVector{<:Number}}, contents::NamedTuple{(:points, :labels), <:Tuple{<:Tuple, <:Tuple}}; length=100, ends=nothing)
ReciprocalPath{K}(reciprocals::AbstractVector{<:AbstractVector{<:Number}}, contents::NamedTuple{(:points, :labels), <:Tuple{<:Tuple, <:Tuple}}; length=100, ends=nothing) where K

ReciprocalPath(reciprocals::AbstractVector{<:AbstractVector{<:Number}}, points::NTuple{N, Number}...; labels=points, length=100, ends=nothing) where N
ReciprocalPath(reciprocals::AbstractVector{<:AbstractVector{<:Number}}, points::Tuple{Vararg{NTuple{N, Number}}}; labels=points, length=100, ends=nothing) where N
ReciprocalPath{K}(reciprocals::AbstractVector{<:AbstractVector{<:Number}}, points::NTuple{N, Number}...; labels=points, length=100, ends=nothing) where {K, N}
ReciprocalPath{K}(reciprocals::AbstractVector{<:AbstractVector{<:Number}}, points::Tuple{Vararg{NTuple{N, Number}}}; labels=points, length=100, ends=nothing) where {K, N}

ReciprocalPath(reciprocals::AbstractVector{<:AbstractVector{<:Number}}, segments::Pair{<:NTuple{N, Number}, <:NTuple{N, Number}}...; labels=segments, length=100, ends=nothing) where N
ReciprocalPath(reciprocals::AbstractVector{<:AbstractVector{<:Number}}, segments::Tuple{Vararg{Pair{<:NTuple{N, Number}, <:NTuple{N, Number}}}}; labels=segments, length=100, ends=nothing) where N
ReciprocalPath{K}(reciprocals::AbstractVector{<:AbstractVector{<:Number}}, segments::Pair{<:NTuple{N, Number}, <:NTuple{N, Number}}...; labels=segments, length=100, ends=nothing) where {K, N}
ReciprocalPath{K}(reciprocals::AbstractVector{<:AbstractVector{<:Number}}, segments::Tuple{Vararg{Pair{<:NTuple{N, Number}, <:NTuple{N, Number}}}}; labels=segments, length=100, ends=nothing) where {K, N}

Construct a path in the reciprocal space.

Note
  1. For connected segments,

    • when length is an integer, it specifies the length of each segment except for the last whose length will be length+1;
    • when ends is nothing, the start point will be included while the end point will be not for each segment except for the last both points of which will be included.
  2. For disconnected segments, they can be partitioned into several connected parts, and the rules for connected segments apply for each of such connected parts.

With the above rules, all the points along the assigned path will be counted once and only once with the largest homogeneity.

source
QuantumLattices.Spatials.ReciprocalZoneMethod
ReciprocalZone(reciprocals::AbstractVector{<:AbstractVector{<:Number}}; length=100, ends=(true, false))
ReciprocalZone{K}(reciprocals::AbstractVector{<:AbstractVector{<:Number}}; length=100, ends=(true, false)) where K

ReciprocalZone(reciprocals::AbstractVector{<:AbstractVector{<:Number}}, bounds::Pair{<:Number, <:Number}...; length=100, ends=(true, false))
ReciprocalZone{K}(reciprocals::AbstractVector{<:AbstractVector{<:Number}}, bounds::Pair{<:Number, <:Number}...; length=100, ends=(true, false)) where K

ReciprocalZone(reciprocals::AbstractVector{<:AbstractVector{<:Number}}, bounds::AbstractVector{<:Pair{<:Number, <:Number}}; length=100, ends=(true, false))
ReciprocalZone{K}(reciprocals::AbstractVector{<:AbstractVector{<:Number}}, bounds::AbstractVector{<:Pair{<:Number, <:Number}}; length=100, ends=(true, false)) where K

ReciprocalZone(reciprocals::AbstractVector{<:AbstractVector{<:Number}}, bounds::Tuple{Vararg{Pair{<:Number, <:Number}}}; length=100, ends=(true, false))
ReciprocalZone{K}(reciprocals::AbstractVector{<:AbstractVector{<:Number}}, bounds::Tuple{Vararg{Pair{<:Number, <:Number}}}; length=100, ends=(true, false)) where K

Construct a rectangular zone in the reciprocal space.

source
QuantumLattices.Spatials.@hexagon_strMacro
hexagon"P₁-P₂-P₃-..."
hexagon"P₁-P₂-P₃-..., 120°"
hexagon"P₁-P₂-P₃-..., 60°"

Construct a tuple of start-stop point pairs for the hexagonal reciprocal space.

source
Base.eltypeMethod
eltype(bond::Bond)
eltype(::Type{<:Bond{K, P} where K}) where {P<:Point}

Get the point type contained in a generic bond.

source
Base.getindexMethod
getindex(lattice::AbstractLattice, i::Integer) -> SVector

Get the ith coordinate.

source
Base.getindexMethod
getindex(bond::Bond, i::Integer) -> Point

Get the ith point contained in a generic bond.

source
Base.iterateFunction
iterate(bond::Bond, state=1)

Iterate over the points contained in a generic bond.

source
Base.lengthMethod
length(lattice::AbstractLattice) -> Int

Get the number of points contained in a lattice.

source
Base.lengthMethod
length(bond::Bond) -> Int

Get the number of points contained in a generic bond.

source
Base.stepMethod
step(path::ReciprocalPath, i::Integer) -> dtype(path)

Get the step between the ith and the (i+1)th points in the path.

source
QuantumLattices.Spatials.bonds!Method
bonds!(bonds::Vector, lattice::AbstractLattice, nneighbor::Integer; coordination::Integer=12)
bonds!(bonds::Vector, lattice::AbstractLattice, neighbors::Neighbors) -> typeof(bonds)

Get the required bonds of a lattice and append them to the input bonds.

source
QuantumLattices.Spatials.bondsMethod
bonds(lattice::AbstractLattice, nneighbor::Integer; coordination::Integer=12) -> Vector{Bond{Int, Point{dimension(lattice), dtype(lattice)}}}
bonds(lattice::AbstractLattice, neighbors::Neighbors) -> Vector{Bond{keytype(neighbors), Point{dimension(lattice), dtype(lattice)}}}

Get the required bonds of a lattice.

source
QuantumLattices.Spatials.directionMethod
direction(v::Char, args...) -> SVector{3, <:Number}
direction(v::Number, unit::Symbol) -> SVector{2, <:Number}
direction(v::Tuple{Number, Number}, unit::Symbol) -> SVector{3, <:Number}
direction(v::AbstractVector{<:Number}, args...) -> AbstractVector{<:Number}

Get the unit vector that specifies the direction of a vector.

source
QuantumLattices.Spatials.distanceMethod
distance(p₁::AbstractVector{<:Number}, p₂::AbstractVector{<:Number}) -> Number

Get the distance between two points.

Note

Compared to norm(p₁-p₂), this function avoids the memory allocation for p₁-p₂, thus is more efficient.

source
QuantumLattices.Spatials.distanceMethod
distance(path::ReciprocalPath) -> dtype(path)
distance(path::ReciprocalPath, i::Integer) -> dtype(path)
distance(path::ReciprocalPath, i::Integer, j::Integer) -> dtype(path)

Get the distance

  1. of the total path,
  2. from the start point to the ith point in the path,
  3. from the ith point to the jth point in the path (when i is greater than j, the value is negative).
source
QuantumLattices.Spatials.interlinksMethod
interlinks(cluster₁::AbstractMatrix{<:Number}, cluster₂::AbstractMatrix{<:Number}, neighbors::Neighbors) -> Vector{Tuple{Int, Int, Int}}

Use kdtree to get the intercluster nearest neighbors.

source
QuantumLattices.Spatials.isintratriangleMethod
isintratriangle(
    p::AbstractVector{<:Number}, p₁::AbstractVector{<:Number}, p₂::AbstractVector{<:Number}, p₃::AbstractVector{<:Number};
    vertexes::NTuple{3, Bool}=(true, true, true), edges::NTuple{3, Bool}=(true, true, true), atol::Real=atol, rtol::Real=rtol
) -> Bool

Judge whether a point belongs to the interior of a triangle whose vertexes are p₁, 'p₂' and p₃ with the give tolerance. vertexes and edges define whether the interior should contain the vertexes or edges, respectively.

Note
  1. The vertexes are in the order (p₁, p₂, p₃) and the edges are in the order (p₁p₂, p₂p₃, p₃p₁).
  2. The edges do not contain the vertexes.
source
QuantumLattices.Spatials.isonlineMethod
isonline(
    p::AbstractVector{<:Number}, p₁::AbstractVector{<:Number}, p₂::AbstractVector{<:Number};
    ends::Tuple{Bool, Bool}=(true, true), atol::Real=atol, rtol::Real=rtol
) -> Bool

Judge whether a point is on a line segment whose end points are p₁ and p₂ with the given tolerance. ends defines whether the line segment should contain its ends.

source
QuantumLattices.Spatials.isparallelMethod
isparallel(v₁::AbstractVector{<:Number}, v₂::AbstractVector{<:Number}; atol::Real=atol, rtol::Real=rtol) -> Int

Judge whether two vectors are parallel to each other with the given tolerance, 0 for not parallel, 1 for parallel and -1 for antiparallel.

source
QuantumLattices.Spatials.issubordinateMethod
issubordinate(coordinate::AbstractVector{<:Number}, vectors::AbstractVector{<:AbstractVector{<:Number}}; atol::Real=atol, rtol::Real=rtol) -> Bool

Judge whether a coordinate belongs to a lattice defined by vectors with the given tolerance.

source
QuantumLattices.Spatials.minimumlengthsFunction
minimumlengths(cluster::AbstractVector{<:Number}, vectors::AbstractVector{<:AbstractVector{<:Number}}, nneighbor::Integer=1; coordination::Integer=12) -> Vector{Float}
minimumlengths(cluster::AbstractMatrix{<:Number}, vectors::AbstractVector{<:AbstractVector{<:Number}}, nneighbor::Integer=1; coordination::Integer=12) -> Vector{Float}

Use kdtree to search the lowest several minimum bond lengths within a lattice translated by a cluster.

When the translation vectors are not empty, the lattice will be considered periodic in the corresponding directions. Otherwise the lattice will be open in all directions. To search for the bonds across the periodic boundaries, the cluster will be pre-translated to become a supercluster, which has open boundaries but is large enough to contain all the nearest neighbors within the required order. The coordination parameter sets the average number of each order of nearest neighbors. If it is to small, larger bond lengths may not be searched, and the result will contain Inf. This is a sign that you may need a larger coordination. Another situation that Inf appears in the result occurs when the minimum lengths are searched in open lattices. Indeed, the cluster may be too small so that the required order just goes beyond it. In this case the warning message can be safely ignored.

source
QuantumLattices.Spatials.rotateMethod
rotate(vector::AbstractVector{<:Number}, angle::Number; axis::Tuple{Union{AbstractVector{<:Number}, Nothing}, Tuple{<:Number, <:Number}}=(nothing, (0, 0))) -> AbstrctVector{<:Number}
rotate(cluster::AbstractMatrix{<:Number}, angle::Number; axis::Tuple{Union{AbstractVector{<:Number}, Nothing}, Tuple{<:Number, <:Number}}=(nothing, (0, 0))) -> AbstractMatrix{<:Number}

Get a rotated vector/cluster of the original one by a certain angle around an axis.

The axis is determined by a point it gets through (nothing can be used to denote the origin), and its polar as well as azimuth angles in radians. The default axis is the z axis.

Note
  1. The result is given by the Rodrigues' rotation formula.
  2. Only 2 and 3 dimensional vectors can be rotated.
  3. When the input vectors are 2 dimensional, both the polar and azimuth of the axis must be 0.
source
QuantumLattices.Spatials.saveMethod
save(filename::AbstractString, path::ReciprocalPath, data::Union{AbstractVector{<:Number}, AbstractMatrix{<:Number}})
save(filename::AbstractString, path::ReciprocalPath, y::AbstractVector{<:Number}, data::Union{AbstractMatrix{<:Number}, AbstractArray{<:Number, 3}})
save(filename::AbstractString, reciprocalspace::Union{BrillouinZone, ReciprocalZone}, data::Union{AbstractMatrix{<:Number}, AbstractArray{<:Number, 3}})

Save data to delimited files.

source
QuantumLattices.Spatials.selectpathMethod
selectpath(brillouinzone::BrillouinZone, contents::NamedTuple{(:points, :labels), <:Tuple{<:Tuple, <:Tuple}}; ends=nothing, atol::Real=atol, rtol::Real=rtol) -> Tuple(ReciprocalPath, Vector{Int})
selectpath(brillouinzone::BrillouinZone, points::NTuple{N, Number}...; labels=points, ends=nothing, atol::Real=atol, rtol::Real=rtol) where N -> Tuple(ReciprocalPath, Vector{Int})
selectpath(brillouinzone::BrillouinZone, points::Tuple{Vararg{NTuple{N, Number}}}; labels=points, ends=nothing, atol::Real=atol, rtol::Real=rtol) where N -> Tuple(ReciprocalPath, Vector{Int})
selectpath(brillouinzone::BrillouinZone, segments::Pair{<:NTuple{N, Number}, <:NTuple{N, Number}}...; labels=segments, ends=nothing, atol::Real=atol, rtol::Real=rtol) where N -> Tuple(ReciprocalPath, Vector{Int})
selectpath(brillouinzone::BrillouinZone, segments::Tuple{Vararg{Pair{<:NTuple{N, Number}, <:NTuple{N, Number}}}}; labels=segments, ends=nothing, atol::Real=atol, rtol::Real=rtol) where N -> Tuple(ReciprocalPath, Vector{Int})

Select a path from a BrillouinZone. Return a ReciprocalPath and the positions of the equivalent points in the BrillouinZone.

Note
  1. For connected segments, the start point will be included while the stop point will be not for each segment except for the last both points of which will be included if ends is nothing.
  2. For disconnected segments, they can be partitioned into several connected parts, and the rule for connected segments applies for each of such connected parts.

With the above rules, all the points along the assigned path will be counted once and only once.

source
QuantumLattices.Spatials.setupMethod
@recipe plot(path::ReciprocalPath, y::AbstractVector{<:Number}, data::AbstractArray{<:Number, 3}; subtitles=nothing, subtitlefontsize=8, nrow=nothing, ncol=nothing, clims=nothing)
@recipe plot(reciprocalspace::BrillouinZone, data::AbstractArray{<:Number, 3}; subtitles=nothing, subtitlefontsize=8, nrow=nothing, ncol=nothing, clims=nothing)
@recipe plot(reciprocalspace::ReciprocalZone, data::AbstractArray{<:Number, 3}; subtitles=nothing, subtitlefontsize=8, nrow=nothing, ncol=nothing, clims=nothing)

Define the recipe for the heatmap visualization of a series of data on

  1. the x-y plain with the x axis being a reciprocal path,
  2. a Brillouin zone,
  3. a reciprocal zone.
source
QuantumLattices.Spatials.shrinkMethod
shrink(reciprocalzone::ReciprocalZone{K}, ranges::Vararg{OrdinalRange{<:Integer}, N}) where {K, N} -> ReciprocalZone

Shrink a reciprocal zone.

source
QuantumLattices.Spatials.tileMethod
tile(cluster::AbstractVector{<:Number}, vectors::AbstractVector{<:AbstractVector{<:Number}}, translations) -> AbstractMatrix{<:Number}
tile(cluster::AbstractMatrix{<:Number}, vectors::AbstractVector{<:AbstractVector{<:Number}}, translations) -> AbstractMatrix{<:Number}

Tile a supercluster by translations of the input cluster.

Basically, the final supercluster is composed of several parts, each of which is a translation of the original cluster, with the translation vectors specified by vectors and each set of the translation indices contained in translations. When translation vectors are empty, a copy of the original cluster will be returned.

source
QuantumLattices.Spatials.translateMethod
translate(cluster::AbstractVector{<:Number}, vector::AbstractVector{<:Number}) -> AbstractVector{<:Number}
translate(cluster::AbstractMatrix{<:Number}, vector::AbstractVector{<:Number}) -> AbstractMatrix{<:Number}

Get the translated cluster of the original one by a vector.

source
QuantumLattices.Spatials.volumeMethod
volume(vectors::AbstractVector{<:AbstractVector{<:Number}}) -> Number
volume(v::AbstractVector{<:Number}) -> Number
volume(v₁::AbstractVector{<:Number}, v₂::AbstractVector{<:Number}) -> Number
volume(v₁::AbstractVector{<:Number}, v₂::AbstractVector{<:Number}, v₃::AbstractVector{<:Number}) -> Number

Get the volume spanned by the input vectors.

source
QuantumLattices.decomposeMethod
decompose(m::AbstractMatrix{<:Number}, m₀::AbstractMatrix{<:Number}) -> Number
decompose(m::AbstractMatrix{<:Number}, ms::Tuple{Vararg{AbstractMatrix{<:Number}}}) -> Tuple{Vararg{Number}}
decompose(m::AbstractMatrix{<:Number}, ms::AbstractVector{<:AbstractMatrix{<:Number}}) -> Vector{<:Number}

Decompose a matrix.

source
QuantumLattices.decomposeMethod
decompose(v₀::AbstractVector{<:Number}, v₁::AbstractVector{<:Number}) -> Number
decompose(v₀::AbstractVector{<:Number}, v₁::AbstractVector{<:Number}, v₂::AbstractVector{<:Number}) -> Tuple{Number, Number}
decompose(v₀::AbstractVector{<:Number}, v₁::AbstractVector{<:Number}, v₂::AbstractVector{<:Number}, v₃::AbstractVector{<:Number}) -> Tuple{Number, Number, Number}
decompose(v₀::AbstractVector{<:Number}, vs::AbstractVector{<:AbstractVector{<:Number}}) -> Vector{<:Number}

Decompose a vector with respect to input basis vectors.

source
QuantumLattices.dimensionMethod
dimension(lattice::AbstractLattice) -> Int
dimension(::Type{<:AbstractLattice{N}}) where N -> Int

Get the space dimension of the lattice.

source
QuantumLattices.dimensionMethod
dimension(bond::Bond) -> Int
dimension(::Type{<:Bond{K, P} where K}) where {P<:Point} -> Int

Get the space dimension of a concrete bond.

source
QuantumLattices.dtypeMethod
dtype(lattice::AbstractLattice)
dtype(::Type{<:AbstractLattice{N, D} where N}) where {D<:Number}

Get the data type of the coordinates of a lattice.

source
QuantumLattices.dtypeMethod
dtype(bond::Bond)
dtype(::Type{<:Bond{K, P} where K}) where {P<:Point}

Get the data type of the coordinates of the points contained in a generic bond.

source
QuantumLattices.dtypeMethod
dtype(point::Point)
dtype(::Type{<:Point{N, D} where N}) where {D<:Number}

Get the data type of the coordinates of a point.

source
QuantumLattices.expandMethod
expand(momentum::Momentum, reciprocals::AbstractVector{<:AbstractVector{<:Number}}) -> eltype(reciprocals)

Expand the momentum from integral values to real values with the given reciprocals.

source
RecipesBase.apply_recipeFunction
@recipe plot(lattice::AbstractLattice, neighbors::Union{Int, Neighbors}, filter::Function=bond->true; siteon=false)

Define the recipe for the visualization of a lattice.

source
RecipesBase.apply_recipeMethod
@recipe plot(path::ReciprocalPath, y::AbstractVector{<:Number}, data::AbstractMatrix{<:Number})

Define the recipe for the heatmap visualization of data on the x-y plain with the x axis being a reciprocal path.

source