Utility

These are some simple convenience functions to smoothen developer experience.

Contents

Index

Structure

Matrices

Wannier.compute_imre_ratioMethod
compute_imre_ratio(W::AbstractArray)

Compute Im/Re ratio of the wavefunction.

Note

This follows the same logic as Wannier90 when computing the ratio for real space WFs.

source
Wannier.eyes_UMethod
eyes_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.

source
Wannier.eyes_UMethod
eyes_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.

source
Wannier.findvectorMethod
findvector(predicate::Function, v::AbstractVector, M::AbstractMatrix)

Find index of vector in the columns of a matrix.

Arguments

  • predicate: comparison function
  • v: the vector to be found
  • M: the matrix to be searched, its column will be compared to v by predicate function
source
Wannier.fix_global_phaseMethod
fix_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: usually size(W) = nx * ny * nz
Note

This follows the same logic as Wannier90 when computing the ratio for real space WFs.

source
Wannier.isunitaryMethod
isunitary(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?

source
Wannier.orthonorm_lowdinMethod
orthonorm_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).

source
Wannier.rand_unitaryMethod
rand_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 matrix
  • m: number of rows
  • n: number of columns
  • k: number of matrices
source
Wannier.rand_unitaryMethod
rand_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, Float64
  • m: number of rows
  • n: number of columns
source
Wannier.rand_unitaryMethod
rand_unitary(T::Type, m::Int)

Generate a random unitary matrix using Lowdin orthonormalization.

Arguments

  • T: the type of the matrix
  • m: number of rows (= number of columns)
source
Wannier.rotate_MMethod
rotate_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}}$.

source
Wannier.rotate_UMethod
rotate_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, usually size(U) = n_bands * n_wann * n_kpts
  • V: a series of gauge matrices, usually size(V) = n_wann * n_wann * n_kpts
source
Wannier.rotate_gaugeMethod
rotate_gauge(O::Array{T,3}, U::Array{T,3})

Rotate the gauge of the operator O.

I.e., $U^{\dagger} O U$.

source

Kpoint

Wannier.get_kgridMethod
get_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
source
Wannier.get_kpoint_mappingsMethod
get_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 kpoint kpoints[:, ik] to kpoint coordinates [ikx, iky, ikz]
  • xyz_k[ikx, iky, ikz] maps kpoint coordinates [ikx, iky, ikz] to kpoint index ik
  • the kpoint fractional coordinates is [(ikx - 1)/nkx, (iky - 1)/nky, (ikz - 1)/nkz]

Arguments

  • kpoints: 3 * n_kpts, in fractional coordinates
  • kgrid: 3, number of kpoints along each reciprocal lattice vector
source
Wannier.get_kpointsMethod
get_kpoints(kgrid; fractional=true, endpoint=false)

Generate list of kpoint coordinates from kpoint grid.

Arguments

  • kgrid: vector of 3 integers specifying a nkx * nky * nkz mesh

Keyword Arguments

  • fractional: return an explicit list of kpoints in fractional coordinates, else integers
  • endpoint: include the endpoint of the grid, only for fractional case. E.g., if true, 1.0 is included
Note

If the default keyword arguments are used, this function works just like kmesh.pl of Wannier90.

source
Wannier.make_supercellFunction
make_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
source
Wannier.make_supercellMethod
make_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 coordinates
  • replica: 3, number of repetitions along ±x, ±y, ±z directions
source
Wannier.sort_kpointsMethod
sort_kpoints(kpoints)

Sort kpoints such that z increases the fastest, then y, then x.

Arguments

  • kpoints: 3 * n_kpts
source

Kpath

The KPath and KPathInterpolant are defined in Brillouin.jl, they are used to store the high-symmetry kpoints and their labels.

Wannier.get_kpathMethod
get_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 vector
  • atom_positions: 3 * n_atoms, fractional coordinates
  • atom_labels: n_atoms of string, atomic labels
source
Wannier.get_kpathMethod
get_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 vector
  • atom_positions: 3 * n_atoms, fractional coordinates
  • atom_numbers: n_atoms of integer, atomic numbers
source
Wannier.get_kpathMethod
get_kpath(lattice, kpoint_path)

Construct a Brillouin.KPath from the returned kpoint_path of WannierIO.read_win.

Arguments

  • lattice: each column is a lattice vector
  • kpoint_path: the returned kpoint_path of WannierIO.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]],
]
source
Wannier.get_kpointsMethod
get_kpoints(kpi::KPathInterpolant)

Get the kpoints coordinates from a KPathInterpolant.

Arguments

  • kpi: KPathInterpolant

Return

  • kpoints: 3 * n_kpts, kpath points coordinates in fractional coordinates.
source
Wannier.get_xMethod
get_x(kpi::KPathInterpolant)

Get x axis value for plotting, in cartesian length.

Arguments

  • kpi: a KPathInterpolant
source
Wannier.interpolate_w90Method
interpolate_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: a Brillouin.KPath
  • n_points: number of kpoints in the first segment, remaining segments have the same density as the 1st segment.
Note

This reproduce exactly the Wannier90 input parameter kpoint_path block and the input parameter bands_num_points.

source

Centers

Wannier.find_nearest_atomMethod
find_nearest_atom(centers, lattice, atom_positions)

Find nearest atom for each WF center.

Arguments

  • centers: 3 * n_wann, in fractional coordinates
  • lattice: 3 * 3, each column is a lattice vector
  • atom_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)
source
Wannier.find_nearestsMethod
find_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 of 3 floats, fractional coordinates w.r.t. lattice
  • search_neighbors: number of nearest-neighbors to be returned
  • lattice: 3 * 3, each column is a lattice vector
  • atom_positions: 3 * n_atoms, each column is fractional coordinate ∈ [0, 1)
source
Wannier.wrap_centersMethod
wrap_centers(centers, lattice)

Wrap around centers back to unit cell at origin.

Arguments

  • centers:: 3 * n_wann, in Cartesian coordiantes
  • lattice:: 3 * 3, each column is a lattice vector
source