Tight-binding models
API reference for the tight-binding operator container and its storage.
For a narrative introduction and examples, see Tight-binding operators and Sparse storage.
Operator containers
Container types and conversions for generic operator storage.
WannierIO.OperatorPack Type
Named Wannier operators on a common set of R-vectors, with dense storage.
An OperatorPack is a storage container: it checks shapes, but holds no physics. Each operator is an array O[m, n, components..., iR] of n_wann × n_wann × component dimensions × n_Rvecs, e.g. a Hamiltonian n_wann × n_wann × n_Rvecs or a vector operator n_wann × n_wann × 3 × n_Rvecs. The R-vectors are unique and carry no degeneracy weights, so an operator at a kpoint is the plain sum k and R fractional). Wigner–Seitz degeneracies and minimum-distance replicas of Wannier90 tb.dat/wsvec.dat files must have been absorbed before packing, e.g. by Wannier.jl's OperatorPack(::TightBindingModel).
The operator names are free-form strings; the dense layout is preserved by sparsify/densify and by write_operator/ read_operator.
Fields
header: Short description of the operator setlattice: Lattice vectors as columns of a 3×3 matrix, in Å.Rvectors: R-vectors as a vector of 3-component integer vectors.operators: Mapping operator names to densen_wann × n_wann × … × n_Rvecsarrays. The operators can be either real or complex.
WannierIO.read_operator Function
read_operator(file, format)
read_operator(file)Read operators from a backend storage format (HDF5/JLD2/Zarr) and return an OperatorPack.
When called without a format argument, the format is inferred from the file extension via detect_operator_format.
WannierIO.write_operator Function
write_operator(file, pack, format; kwargs...)
write_operator(file, pack; kwargs...)Write an operator pack to a backend storage format (HDF5/JLD2/Zarr).
When called without a format argument, the format is inferred from the file extension via detect_operator_format.
Sparse representation
Sparse containers and conversion routines (sparsify, densify).
WannierIO.CscPack Type
Pack a series of CSC matrices into a compact representation.
struct CscPack{Tv<:Number, Ti<:Integer}This packs a dense N × N × … array, whose leading two axes are the matrix axes, into one struct with concatenated nonzero values and indices. The axes after the two matrix axes (components, R-vectors) are flattened in column-major order into L matrices; each N × N matrix is stored in compressed sparse column (CSC) format, and the L matrices are concatenated along the nonzero dimension.
For example, N = 3 and L = 2 (dims = [3, 3, 2]):
l = 1 l = 2
[ a . . ] [ . e . ]
[ . . b ] [ . . . ]
[ c . d ] [ . . f ]
|<---- l = 1 -->|<l = 2>|
index 1 2 3 4 5 6 7
nzval = [ a c b d e f ]
rowval = [ 1 3 2 3 1 3 ]
nzptr = [ 1 5 7 ]
l=1 l=2
colptr = [ 1 1 ] column j of matrix l is the local range
[ 3 1 ] colptr[j, l] : colptr[j+1, l] - 1, i.e. the
[ 3 2 ] indices nzptr[l] - 1 .+ (that range) of
[ 5 3 ] rowval and nzvalFields
nzptr: 1-based offsets into concatenated nonzero buffers for each matrix. Length isL + 1, andnzptr[l]:nzptr[l+1]-1are the entries of thel-th matrix inrowvalandnzval.colptr: CSC column pointer table for each packed matrix. Size is(N + 1, L), andcolptr[:, l]is the column pointer of thel-th matrix.rowval: Concatenated row indices of all nonzeros. Length is the total number of nonzeros across all matrices.nzval: Concatenated nonzero values of all matrices. Length is the total number of nonzeros across all matrices.dims: Dimensions of the dense array,[N, N, trailing...], in column-major (Julia) order, e.g.[n_wann, n_wann, n_Rvecs]or[n_wann, n_wann, 3, n_Rvecs]. The product of the trailing dimensions isL.
WannierIO.CscPack Method
CscPack{Tv, Ti}(mats, dims = [N, N, length(mats)])Pack the sparse N × N matrices mats, the column-major flattening of a dense array of dimensions dims.
WannierIO.SparseOperatorPack Type
Series of operators with sparse CSC storage.
Fields
header: Short description of the operator setlattice: Lattice vectors as columns of a 3×3 matrix, in Å.Rvectors: R-vectors as columns of a3 × n_Rvecsmatrix, integers.operators: Mapping operator names to sparse packs.
WannierIO.SparseOption Type
Control sparsification behavior.
Fields
atol: Absolute tolerance for treating values as zero. Must be nonnegative. Elements withabs(real(v)) < atolandabs(imag(v)) < atolare dropped.index_type: Integer type for storing row and column indices in sparse matrices.value_type: Numeric type for storing nonzero values in sparse matrices. Can be real or complex. If real, will attempt to convert complex values to real if all imaginary parts are smaller thanatol.
Base.getindex Method
Return the l-th packed matrix as a SparseMatrixCSC with p[:, :, l]; l is the column-major linear index over the trailing dimensions.
WannierIO._chunk_shape Method
_chunk_shape(data)Return a conservative HDF5/Zarr chunk shape.
For 1D arrays, cap the chunk at _MAX_CHUNK_ELEMS_1D elements. For 2D arrays, cap each edge at _MAX_CHUNK_EDGE_2D, i.e. at most _MAX_CHUNK_EDGE_2D^2 == _MAX_CHUNK_ELEMS_1D elements per chunk.
WannierIO._force_value_type Method
_force_value_type(operator_eltype, value_type)Return the sparse storage element type for an operator with element type operator_eltype and requested precision value_type.
WannierIO.densify Method
densify(pack; value_type)Reconstruct dense matrices from sparse CSC matrices produced by sparsify.
Set value_type to force conversion. Use nothing to preserve stored type.
WannierIO.densify Method
densify(pack; value_type)Reconstruct dense operators from a sparse CSC pack produced by sparsify.
WannierIO.sparsify Function
sparsify(pack)
sparsify(pack, opt)Convert the operators of an OperatorPack to sparse CSC matrices suitable for storage in HDF5, JLD2, or Zarr.
See densify for the inverse.
WannierIO.sparsify Method
sparsify(op)
sparsify(op, opt)Convert an operator to sparse CSC representation.
Only entries with abs(real(v)) >= atol || abs(imag(v)) >= atol are stored.
See densify for the inverse.
Arguments
op: ann_wann × n_wann × … × n_Rvecsarray, the operator at the R-vectors, with any component axes between the matrix axes and the R axisopt: aSparseOption