Tight-binding models
API reference for tight-binding reduction and storage helpers.
For a narrative introduction and examples, see Tight-binding operators and Sparse storage.
R-vector reducers
Reducers that absorb R-degeneracy (and optional MDRS corrections) into operator definitions.
WannierIO.AbstractRvectorReducer Type
Simplify the R-vectors of a tight-binding operator, such that the inverse Fourier transform is a simple sum (and is faster).
sourceWannierIO.MdrsRvectorReducer Type
MDRS R-vector reducer, which simplifies the R-vectors by absorbing the R degeneracies, T vectors and degeneracies into the operator.
This expands the R-vectors to a new set of R-vectors R̃ = R + T, where T is the translation vectors; also divide the operator by the degeneracies of R and T vectors.
struct MdrsRvectorReducer <: WannierIO.AbstractRvectorReducerFields
Rvectors: The new R vectors.mapping: The contribution mapping from new R vectors to original operator entries.mapping[iR]is a vector of(iR0, m, n)tuples, where each tuple means one MDRS contribution fromoperator[iR0][m, n]to the newiR-th R vector.degens: The combined R and T degeneracies of the original R vectors.degens[iR0](iR0 ∈ iR0s) gives the degeneracy matrices of the originaliR0-th R vector by combining the originalRdegensand theTdegensof the T vectors. Theoperator[iR0]will be divided bydegens[iR0]to absorb the degeneracies.
WannierIO.WsRvectorReducer Type
Wigner-Seitz R-vector reducer, which simplifies the R-vectors by absorbing the R degeneracies into the operator.
The R-vectors are still the same, the operator will be divided by the R-vector degeneracy.
struct WsRvectorReducer <: WannierIO.AbstractRvectorReducerFields
Rvectors: The new R vectors (same as the original R vectors).degens: The R degeneracies of the (original) R vectors.degens[iR]gives the degeneracy of the (original)iR-th R vector. The originaloperator[iR]is divided bydegens[iR]to absorb the degeneracy.
WannierIO.RvectorReducer Function
Reduce the R-vectors of a tight-binding operator by absorbing the R degeneracies (and T vectors & degeneracies, if provided) into the operator.
This is a general interface for R-vector reduction, which can be implemented for different input argument types.
sourceTight-binding operators
High-level TB API and conversions.
WannierIO.read_w90_tb Function
read_w90_tb(file)Read Wannier90 prefix_tb.dat (and optional matching prefix_wsvec.dat).
The Rvectors and degeneracies will be reduced by RvectorReducer automatically, resulting in a OperatorPack with just the Rvectors and the operator matrices defined on them.
If a corresponding wsvec.dat file is found, the MDRS Tvectors and degeneracies will also be reduced automatically.
As a consequence, the Wannier interpolation will be just a simple inverse Fourier transform without any complications from R-degeneracies or MDRS T vectors and degeneracies.
See also read_w90_tb_dat and read_w90_wsvec for reading just the prefix_tb.dat and prefix_wsvec.dat files without any reduction.
This high-level API is intentionally for native Wannier90 text files only. For HDF5/JLD2/Zarr backends, use read_operator.
WannierIO.write_w90_tb Function
write_w90_tb(file, tbdat)
write_w90_tb(file, tbdat, wsvec)Write Wannier90 tight-binding text data.
This high-level API is intentionally for native Wannier90 text files only. For HDF5/JLD2/Zarr backends, use write_operator.
For W90Dat:
write_w90_tb(file, tbdat, W90Dat())writes onlyprefix_tb.dat.write_w90_tb(file, tbdat, wsvec, W90Dat())writes bothprefix_tb.datandprefix_wsvec.dat.
Hamiltonian operators
High-level HR API and conversions.
WannierIO.read_w90_hr Method
read_w90_hr(file)Read Wannier90 prefix_hr.dat (and optional matching prefix_wsvec.dat).
The Rvectors and degeneracies will be reduced by RvectorReducer automatically, resulting in a OperatorPack with just the Rvectors and the H operator matrices defined on them.
If a corresponding wsvec.dat file is found, the MDRS Tvectors and degeneracies will also be reduced automatically.
Because prefix_hr.dat does not store lattice vectors, the returned OperatorPack uses a 3×3 lattice filled with NaN as a sentinel for "lattice unavailable".
As a consequence, the Wannier interpolation will be just a simple inverse Fourier transform without any complications from R-degeneracies or MDRS T vectors and degeneracies.
See also read_w90_hr_dat and read_w90_wsvec for reading just the prefix_hr.dat and prefix_wsvec.dat files without any reduction.
This high-level API is intentionally for native Wannier90 text files only. For HDF5/JLD2/Zarr backends, use read_operator.
WannierIO.write_w90_hr Function
write_w90_hr(file, hrdat)
write_w90_hr(file, hrdat, wsvec)Write Wannier90 Hamiltonian text data.
This high-level API is intentionally for native Wannier90 text files only. For HDF5/JLD2/Zarr backends, use write_operator.
For W90Dat:
write_w90_hr(file, hrdat)writes onlyprefix_hr.dat.write_w90_hr(file, hrdat, wsvec)writes bothprefix_hr.datandprefix_wsvec.dat.
Operator containers
Container types and conversions for generic operator storage.
WannierIO.OperatorPack Type
Series of operators with dense matrix storage.
The operators should have been simplified by WsRvectorReducer or MdrsRvectorReducer, i.e., no Rdegens or Tvectors.
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 vectors of dense matrices. The operators can be either real or complex.n_Rvecs: Number of R-vectors.n_wann: Number of Wannier functions.
WannierIO.pack Function
Pack tight-binding operators into an OperatorPack struct.
e.g., from TbDat and WsvecDat structs to OperatorPack.
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 length-L vector of N × N sparse matrices into one struct with concatenated nonzero values and indices.
Fields
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.
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.n_Rvecs: Number of R-vectors.n_wann: Number of Wannier functions.
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.
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(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: a vector ofn_wann × n_wannmatrices representing the operator at different R-vectors.
Keyword Arguments
sourceWannierIO.sparsify Function
sparsify(pack)
sparsify(pack, opt)Pack a set of Wannier90 operators into sparse CSC matrices suitable for storage in HDF5, JLD2, or Zarr.
See densify for the inverse.
Page index
WannierIO.AbstractRvectorReducerWannierIO.CscPackWannierIO.MdrsRvectorReducerWannierIO.OperatorPackWannierIO.SparseOperatorPackWannierIO.SparseOptionWannierIO.WsRvectorReducerWannierIO.RvectorReducerWannierIO._chunk_shapeWannierIO._force_value_typeWannierIO.densifyWannierIO.densifyWannierIO.is_almost_realWannierIO.matrix_orderWannierIO.packWannierIO.read_operatorWannierIO.read_w90_hrWannierIO.read_w90_tbWannierIO.sparsifyWannierIO.sparsifyWannierIO.write_operatorWannierIO.write_w90_hrWannierIO.write_w90_tb