Utility
These are some simple convenience functions to smoothen developer experience.
Contents
Index
Wannier.compute_imre_ratioWannier.eyes_UWannier.eyes_UWannier.find_nearest_atomWannier.find_nearestsWannier.findvectorWannier.fix_global_phaseWannier.get_atom_numberWannier.get_atom_numberWannier.get_kgridWannier.get_kpathWannier.get_kpathWannier.get_kpathWannier.get_kpoint_mappingsWannier.get_kpointsWannier.get_kpointsWannier.get_latticeWannier.get_projectabilityWannier.get_recip_latticeWannier.get_xWannier.imaglogWannier.interpolate_w90Wannier.isunitaryWannier.make_supercellWannier.make_supercellWannier.orthonorm_lowdinWannier.orthonorm_lowdinWannier.rand_unitaryWannier.rand_unitaryWannier.rand_unitaryWannier.rotate_MWannier.rotate_UWannier.rotate_gaugeWannier.sort_kpointsWannier.wrap_centers
Structure
Wannier.get_atom_number — Methodget_atom_number(symbol::AbstractString)Get atom number from symbol.
Wannier.get_atom_number — Methodget_atom_number(symbol::Vector{String})Get atom number from symbol.
Wannier.get_lattice — Methodget_lattice(recip_lattice::Mat3)Return lattice.
Wannier.get_recip_lattice — Methodget_recip_lattice(lattice::Mat3)Return reciprocal lattice.
Matrices
Wannier.compute_imre_ratio — Methodcompute_imre_ratio(W::AbstractArray)Compute Im/Re ratio of the wavefunction.
This follows the same logic as Wannier90 when computing the ratio for real space WFs.
Wannier.eyes_U — Methodeyes_U(T::Type, n_bands::Int, n_wann::Int, n_kpts::Int)Return a series of indentity matrices of type T and size n_bands * n_wann * n_kpts.
Wannier.eyes_U — Methodeyes_U(T::Type, n_wann::Int, n_kpts::Int)Return a series of indentity matrices of type T and size n_wann * n_wann * n_kpts.
Wannier.findvector — Methodfindvector(predicate::Function, v::AbstractVector, M::AbstractMatrix)Find index of vector in the columns of a matrix.
Arguments
predicate: comparison functionv: the vector to be foundM: the matrix to be searched, its column will be compared tovbypredicatefunction
Wannier.fix_global_phase — Methodfix_global_phase(W::AbstractArray)Return a factor to fix the global phase of wavefunction, such that the point having max norm is real.
Arguments
W: usuallysize(W) = nx * ny * nz
This follows the same logic as Wannier90 when computing the ratio for real space WFs.
Wannier.get_projectability — Methodget_projectability(U::AbstractArray{T,3})Return projectability of each kpoint.
Wannier.imaglog — Methodimaglog(z)Return the imaginary part of the logarithm of z.
Wannier.isunitary — Methodisunitary(U::AbstractArray{T,3}; atol=1e-10)Check if matrix is unitary or semi-unitary for all the kpoints?
I.e. does it have orthogonal columns?
Wannier.orthonorm_lowdin — Methodorthonorm_lowdin(U::Array{T,3})Lowdin orthonormalize a series of matrices M.
Wannier.orthonorm_lowdin — Methodorthonorm_lowdin(U::Matrix{T})Lowdin orthonormalize a matrix U to be (semi-)unitary.
If U is a matrix with orthogonal columns and V a non-singular matrix, then Lowdin-orthogonalizing U*V is equivalent to computing U*orthonorm_lowdin(V).
Wannier.rand_unitary — Methodrand_unitary(T::Type, m::Int, n::Int, k::Int)Generate a series of random (semi-)unitary matrix using Lowdin orthonormalization.
The returned M[:, :, ik] is (semi-)unitary for all ik = 1:k.
Arguments
T: the type of the matrixm: number of rowsn: number of columnsk: number of matrices
Wannier.rand_unitary — Methodrand_unitary(T::Type, m::Int, n::Int)Generate a random (semi-)unitary matrix using Lowdin orthonormalization.
Arguments
T: the type of the matrix, e.g.,ComplexF64,Float64m: number of rowsn: number of columns
Wannier.rand_unitary — Methodrand_unitary(T::Type, m::Int)Generate a random unitary matrix using Lowdin orthonormalization.
Arguments
T: the type of the matrixm: number of rows (= number of columns)
Wannier.rotate_M — Methodrotate_M(M::Array{T,4}, kpb_k::Matrix{Int}, U::Array{T,3})Rotate mmn matrices according to gauge U.
i.e., for each kpoint $\bm{k}$, $U_{\bm{k}+\bm{b}}^{\dagger} M_{\bm{k},\bm{b}} U_{\bm{k}}$.
Wannier.rotate_U — Methodrotate_U(U, V)Rotate the gauge matrices U by V.
For each kpoint $\bm{k}$, return $U_{\bm{k}} V_{\bm{k}}$.
Arguments
U: a series of gauge matrices, usuallysize(U) = n_bands * n_wann * n_kptsV: a series of gauge matrices, usuallysize(V) = n_wann * n_wann * n_kpts
Wannier.rotate_gauge — Methodrotate_gauge(O::Array{T,3}, U::Array{T,3})Rotate the gauge of the operator O.
I.e., $U^{\dagger} O U$.
Kpoint
Wannier.get_kgrid — Methodget_kgrid(kpoints)Guess kgrid from list of kpoint coordinates.
Input kpoints has size 3 * n_kpts, where n_kpts = nkx * nky * nkz, output [nkx, nky, nkz].
Arguments
kpoints:3 * n_kpts, fractional coordiantes
Wannier.get_kpoint_mappings — Methodget_kpoint_mappings(kpoints, kgrid)Get the mappings between kpoint indexes and kpoint coordiantes.
Return a tuple of (k_xyz, xyz_k):
k_xyz[ik]maps kpointkpoints[:, ik]to kpoint coordinates[ikx, iky, ikz]xyz_k[ikx, iky, ikz]maps kpoint coordinates[ikx, iky, ikz]to kpoint indexik- the kpoint fractional coordinates is
[(ikx - 1)/nkx, (iky - 1)/nky, (ikz - 1)/nkz]
Arguments
kpoints:3 * n_kpts, in fractional coordinateskgrid:3, number of kpoints along each reciprocal lattice vector
Wannier.get_kpoints — Methodget_kpoints(kgrid; fractional=true, endpoint=false)Generate list of kpoint coordinates from kpoint grid.
Arguments
kgrid: vector of 3 integers specifying ankx * nky * nkzmesh
Keyword Arguments
fractional: return an explicit list of kpoints in fractional coordinates, else integersendpoint: include the endpoint of the grid, only for fractional case. E.g., if true, 1.0 is included
If the default keyword arguments are used, this function works just like kmesh.pl of Wannier90.
Wannier.make_supercell — Functionmake_supercell(kpoints, replica=5)Make a supercell of kpoints by translating it along 3 directions.
Arguments
replica: integer, number of repetitions along ±x, ±y, ±z directions
Wannier.make_supercell — Methodmake_supercell(kpoints, replica)Make a supercell of kpoints by translating it along 3 directions.
On output there are (2*replica + 1)^3 cells, in fractional coordinates.
Arguments
kpoints:3 * n_kpts, in fractional coordinatesreplica:3, number of repetitions along ±x, ±y, ±z directions
Wannier.sort_kpoints — Methodsort_kpoints(kpoints)Sort kpoints such that z increases the fastest, then y, then x.
Arguments
kpoints:3 * n_kpts
Kpath
The KPath and KPathInterpolant are defined in Brillouin.jl, they are used to store the high-symmetry kpoints and their labels.
Wannier.get_kpath — Methodget_kpath(lattice, atom_positions, atom_labels)Get a Brillouin.KPath for arbitrary cell (can be non-standard).
Internally use Brillouin.jl.
Arguments
lattice:3 * 3, each column is a lattice vectoratom_positions:3 * n_atoms, fractional coordinatesatom_labels:n_atomsof string, atomic labels
Wannier.get_kpath — Methodget_kpath(lattice, atom_positions, atom_numbers)Get a Brillouin.KPath for arbitrary cell (can be non-standard).
Internally use Brillouin.jl.
Arguments
lattice:3 * 3, each column is a lattice vectoratom_positions:3 * n_atoms, fractional coordinatesatom_numbers:n_atomsof integer, atomic numbers
Wannier.get_kpath — Methodget_kpath(lattice, kpoint_path)Construct a Brillouin.KPath from the returned kpoint_path of WannierIO.read_win.
Arguments
lattice: each column is a lattice vectorkpoint_path: the returnedkpoint_pathofWannierIO.read_win, e.g.,
kpoint_path = [
[:Γ => [0.0, 0.0, 0.0], :M => [0.5, 0.5, 0.0]],
[:M => [0.5, 0.5, 0.0], :R => [0.5, 0.5, 0.5]],
]Wannier.get_kpoints — Methodget_kpoints(kpi::KPathInterpolant)Get the kpoints coordinates from a KPathInterpolant.
Arguments
kpi:KPathInterpolant
Return
kpoints:3 * n_kpts, kpath points coordinates in fractional coordinates.
Wannier.get_x — Methodget_x(kpi::KPathInterpolant)Get x axis value for plotting, in cartesian length.
Arguments
kpi: aKPathInterpolant
Wannier.interpolate_w90 — Methodinterpolate_w90(kpath::KPath, n_points::Int)Get kpoint coordinates from a Brillouin.KPath.
Use the kpath density of first segment to generate the following kpaths, also need to take care of high symmetry kpoints at the start and end of each segment.
Return a KPathInterpolant.
Arguments
kpath: aBrillouin.KPathn_points: number of kpoints in the first segment, remaining segments have the same density as the 1st segment.
This reproduce exactly the Wannier90 input parameter kpoint_path block and the input parameter bands_num_points.
Centers
Wannier.find_nearest_atom — Methodfind_nearest_atom(centers, lattice, atom_positions)Find nearest atom for each WF center.
Arguments
centers:3 * n_wann, in fractional coordinateslattice:3 * 3, each column is a lattice vectoratom_positions:3 * n_atoms, each column is fractional coordinate ∈[0, 1)
Example
wout = read_wout("silicon.wout")
points = inv(wout.lattice) * wout.centers # to fractional
find_nearest_atom(points, wout.lattice, wout.atom_positions)Wannier.find_nearests — Methodfind_nearests(point, search_neighbors, lattice, atom_positions)Find nearest-atom (including its periodic images) to a point.
Usually point is the WF center, so the function returns nearest atom to WF center.
Arguments
point: vector of3floats, fractional coordinates w.r.t. latticesearch_neighbors: number of nearest-neighbors to be returnedlattice:3 * 3, each column is a lattice vectoratom_positions:3 * n_atoms, each column is fractional coordinate ∈[0, 1)
Wannier.wrap_centers — Methodwrap_centers(centers, lattice)Wrap around centers back to unit cell at origin.
Arguments
centers::3 * n_wann, in Cartesian coordianteslattice::3 * 3, each column is a lattice vector