wannier90-utils

This package provides a library of functions for reading/writing and manipulating the data associated with the wannier90 code [1].

Features

  • Routines for reading/writing/manipulating a variety of files

    • manipulating WIN files (see here)

    • parsing WOUT files (see here)

    • the nnkp file (see here)

    • the eigenvalues, overlap matrices, and projection matrices (see here)

    • output of postw90 program, such as bandstructures (see here)

  • Utilities for computing the centers and spreads of Wannier functions (see here)

Installation

To install the latest version of the wannier90-utils package, simply clone the repository and install using pip.

git clone https://github.com/jimustafa/wannier90-utils.git
cd wannier90-utils && pip install .

Documentation

Manipulating WIN files

Wannier90 I/O routines pertaining to WIN files

w90utils.io.win.print_atoms(atoms, units='crystal', file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]
w90utils.io.win.print_kgrid(kgrid, file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]
w90utils.io.win.print_kpoints(kpoints, mp_grid=None, file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]
w90utils.io.win.print_unit_cell(dlv, units='bohr', file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]
w90utils.io.win.read_atoms(fname, units='crystal')[source]
w90utils.io.win.read_dlv(fname, units='bohr')[source]

Read direct lattice vectors from WIN file.

Parameters
  • fname (str) – Wannier90 WIN file

  • units (str, {'bohr', 'angstrom'}) – units of returned lattice vectors

Returns

dlv (ndarray, shape (3, 3)) – direct lattice vectors

w90utils.io.win.read_kgrid(fname)[source]
w90utils.io.win.read_kpoints(fname)[source]
w90utils.io.win.read_proj_line(line, dlv, basis, spinors)[source]
w90utils.io.win.read_projections(fname)[source]
w90utils.io.win.remove_comments(s)[source]

Parsing WOUT files

Wannier90 I/O routines pertaining to WOUT files

w90utils.io.wout.read_centers_xyz(fname)[source]
w90utils.io.wout.read_conv(fname)[source]
w90utils.io.wout.read_sprd(fname)[source]

Parsing NNKP files

Wannier90 I/O routines pertaining to NNKP files

w90utils.io.nnkp.read_bvectors(fname, units='angstrom')[source]
w90utils.io.nnkp.read_dlv(fname, units='bohr')[source]
w90utils.io.nnkp.read_excluded_bands(fname)[source]
w90utils.io.nnkp.read_kpoints(fname, units='crystal')[source]
w90utils.io.nnkp.read_nnkpts(fname)[source]
w90utils.io.nnkp.read_projections(fname)[source]
w90utils.io.nnkp.read_rlv(fname, units='bohr')[source]

Fundamental I/O routines

w90utils.io.read_eig(fname)

Read EIG file.

w90utils.io.write_eig(fname, eig)

Write \(E_{n\mathbf{k}}\) to EIG file.

w90utils.io.read_hamiltonian(fname)

Read EIG file and return k-dependent Hamiltonian matrix.

w90utils.io.read_amn(fname)

Read AMN file.

w90utils.io.write_amn(fname, amn[, header])

Write \(A^{(\mathbf{k})}_{mn}\) to AMN file.

w90utils.io.read_mmn(fname)

Read MMN file

w90utils.io.write_mmn(fname, mmn, kpb_kidx, …)

Write \(M^{(\mathbf{k},\mathbf{b})}_{mn}\) to MMN file

w90utils.io.read_eig(fname)[source]

Read EIG file.

Parameters

fname (str) – path to EIG file

Returns

ndarray, shape (nkpts, nbnds, nproj)

w90utils.io.write_eig(fname, eig)[source]

Write \(E_{n\mathbf{k}}\) to EIG file.

Parameters
  • fname (str) – path to EIG file

  • eig (ndarray, shape (nkpts, nbnds)) –

w90utils.io.read_hamiltonian(fname)[source]

Read EIG file and return k-dependent Hamiltonian matrix.

Parameters

fname (str) – path to EIG file

Returns

ndarray, shape (nkpts, nbnds, nbnds)

w90utils.io.read_amn(fname)[source]

Read AMN file.

Parameters

fname (str) –

Returns

ndarray, shape (nkpts, nbnds, nproj)

w90utils.io.write_amn(fname, amn, header='HEADER')[source]

Write \(A^{(\mathbf{k})}_{mn}\) to AMN file.

Parameters
  • fname (str) –

  • amn (ndarray, shape (nkpts, nbnds, nproj)) –

  • header (str) –

w90utils.io.read_mmn(fname)[source]

Read MMN file

Parameters

fname (str) –

Returns

ndarray, shape (nkpts, nntot, nbnds, nbnds)

w90utils.io.write_mmn(fname, mmn, kpb_kidx, kpb_g)[source]

Write \(M^{(\mathbf{k},\mathbf{b})}_{mn}\) to MMN file

Parameters
  • fname (str) –

  • mmn (ndarray, shape (nkpts, nntot, nbnds, nbnds)) –

Wannier function centers and spreads

Functions for computing Wannier centers and components of the spread

w90utils.sprd.omega(Mmn, bvectors, bweights)[source]

Compute the spread functional

Parameters
  • Mmn (ndarray, shape (nkpts, nntot, nbnds, nbnds)) – the overlap matrix

  • bvectors (ndarray, shape (nkpts, nntot, 3)) –

  • bweights (ndarray, shape (nntot,)) –

w90utils.sprd.omega_d(m, bvectors, bweights, idx=None)[source]

Compute the diagonal contribution to the spread functional

Parameters
  • m (ndarray, shape (nkpts, nntot, nbnds, nbnds)) – the overlap matrix

  • bvectors (ndarray, shape (nkpts, nntot, 3)) –

  • bweights (ndarray, shape (nntot,)) –

w90utils.sprd.omega_dod(Mmn, bvectors, bweights)[source]

Compute the sum of the diagonal and off-diagonal contribution to the spread functional

Parameters
  • Mmn (ndarray, shape (nkpts, nntot, nbnds, nbnds)) – the overlap matrix

  • bvectors (ndarray, shape (nkpts, nntot, 3)) –

  • bweights (ndarray, shape (nntot,)) –

w90utils.sprd.omega_i(Mmn, bweights)[source]

Compute the invariant contribution to the spread functional

Parameters
  • Mmn (ndarray, shape (nkpts, nntot, nbnds, nbnds)) – the overlap matrix

  • bweights (ndarray, shape (nntot,)) –

w90utils.sprd.omega_iod(m, bweights, idx=None)[source]

Compute the sum of the invariant and off-diagonal contribution to the spread functional

Parameters
  • m (ndarray, shape (nkpts, nntot, nbnds, nbnds)) – the overlap matrix

  • bweights (ndarray, shape (nntot,)) –

w90utils.sprd.omega_od(Mmn, bweights)[source]

Compute the off-diagonal contribution to the spread functional

Parameters
  • Mmn (ndarray, shape (nkpts, nntot, nbnds, nbnds)) – the overlap matrix

  • bweights (ndarray, shape (nntot,)) –

w90utils.sprd.wannier_centers(m, bvectors, bweights)[source]

Processing postw90 output

w90utils.io.postw90.print_kpoints(kpoints, header='', units='crystal', file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]
w90utils.io.postw90.read_band_velocities(fname)[source]
w90utils.io.postw90.read_bands(fname)[source]
w90utils.io.postw90.read_bands_kpoints(fname)[source]

Read k-points from the geninterp dat file

Parameters

fname (str) –

Returns

ndarray, shape (nkpts, 3) – array of kpoints using for geninterp, in units of \(\unicode{x212B}^{-1}\)

w90utils.io.postw90.read_dos(fname)[source]
w90utils.io.postw90.read_elcond(fname)[source]
w90utils.io.postw90.read_kpoints(fname)[source]
w90utils.io.postw90.read_vnk(fname)
w90utils.io.postw90.write_kpoints(fname, kpoints)[source]

Examples

Read the Hamiltonian in the Wannier representation

from w90utils import io as w90io

HR, Rvectors, Rweights = w90io.read_hr('wannier_hr.dat')

Indices and tables