Classes to store Wannier90 input and output files

class wannierberri.w90files.Wannier90data(seedname='wannier90', read_chk=False, kmesh_tol=1e-07, bk_complete_tol=1e-05, read_npz=True, write_npz_list=('mmn', 'eig', 'amn', 'dmn'), write_npz_formatted=True, overwrite_npz=False, formatted=(), files={})[source]

Bases: object

A class to describe all input files of wannier90, and to construct the Wannier functions

via disentanglement procedure

Parameters:
  • seedname – str the prefix of the file (including relative/absolute path, but not including the extensions, like .chk, .mmn, etc)

  • formatted – tuple(str) list of files which should be read as formatted files (uHu, uIu, etc)

  • read_npz – bool if True, try to read the files converted to npz (e.g. wanier90.mmn.npz instead of wannier90.

  • write_npz_list – list(str) for which files npz will be written

  • write_npz_formatted – bool write npz for all formatted files

  • overwrite_npz – bool overwrite existing npz files (incompatinble with read_npz)

  • read_chk – bool if True, read the checkpoint file, otherwise create a ‘~wannierberri.system.w90_files.CheckPoint_bare’ object and prepare for disentanglement

  • kmesh_tol – float see ~wannierberri.system.w90_files.CheckPoint

  • bk_complete_tol – float see ~wannierberri.system.w90_files.CheckPoint

chk

the checkpoint file

Type:

~wannierberri.system.w90_files.CheckPoint or ~wannierberri.system.w90_files.CheckPoint_bare

seedname

the prefix of the file (including relative/absolute path, but not including the extensions, like .chk, .mmn, etc)

Type:

str

wannierised

if True, the data is already wannierised (so, it can be used to create a System_w90 object)

Type:

bool

read_npz

if True, try to read the files converted to npz (e.g. wanier90.mmn.npz instead of wannier90.

Type:

bool

write_npz_list

for which files npz will be written

Type:

set(str)

write_npz_formatted

write npz for all formatted files

Type:

bool

formatted_list

list of files which should be read as formatted files (uHu, uIu, etc)

Type:

list(str)

_files

the dictionary of the files (e.g. the keys are ‘mmn’, ‘eig’, ‘amn’, ‘uiu’, ‘uhu’, ‘siu’, ‘shu’, ‘spn’, ‘dmn’)

Type:

dict(str, ~wannierberri.system.w90_files.W90_file)

__init__(seedname='wannier90', read_chk=False, kmesh_tol=1e-07, bk_complete_tol=1e-05, read_npz=True, write_npz_list=('mmn', 'eig', 'amn', 'dmn'), write_npz_formatted=True, overwrite_npz=False, formatted=(), files={})[source]
disentangle(**kwargs)[source]

Perform the disentanglement procedure calling ~wannierberri.system.disentangle

Parameters:

kwargs (dict) – the keyword arguments to be passed to ~wannierberri.system.disentangle

get_disentangled(files=[])[source]

after disentanglement, get the Wannier90data object with num_wann == num_bands

Parameters:

files (list(str)) – the extensions of the files to be read (e.g. ‘mmn’, ‘eig’, ‘amn’, ‘uiu’, ‘uhu’, ‘siu’, ‘shu’, ‘spn’, ‘dmn’)

write(seedname, files=None)[source]

writes the files on disk

Parameters:
  • seedname (str) – the seedname of the files (including relative/absolute path, but not including the extensions, like .chk, .mmn, etc)

  • files (list(str)) – the list of files extensions to be written. If None, all files are written

class wannierberri.w90files.AMN(seedname='wannier90', npar=2, **kwargs)[source]

Bases: W90_file

Class to store the projection of the wavefunctions on the initial Wannier functions AMN.data[ik, ib, iw] = <u_{i,k}|w_{i,w}>

Parameters:
  • seedname (str) – the prefix of the file (including relative/absolute path, but not including the extension .amn)

  • npar (int) – the number of parallel processes to be used for reading

Notes

NB

number of bands

Type:

int

NW

number of Wannier functions

Type:

int

NK

number of k-points

Type:

int

data

the data projections

Type:

numpy.ndarray( (NK, NB, NW), dtype=complex)

property NB
property NW
from_w90_file(seedname, npar)[source]

abstract method to read the necessary data from Wannier90 file

get_disentangled(v_left, v_right)[source]

reduce number of bands

Parameters:

v_matrix (np.ndarray(NB,num_wann)) – the matrix of column vectors defining the Wannier gauge

to_w90_file(seedname)[source]
class wannierberri.w90files.CheckPoint(seedname, kmesh_tol=1e-07, bk_complete_tol=1e-05)[source]

Bases: object

A class to store the data about wannierisation, written by Wannier90

Parameters:
  • seedname (str) – the prefix of the file (including relative/absolute path, but not including the extension .chk)

  • kmesh_tol (float) – tolerance to distinguish different/same k-points

  • bk_complete_tol (float) – tolerance for the completeness relation for finite-difference scheme

get_AABB_qb(mmn, transl_inv=False, eig=None, phase=None, sum_b=False)[source]

Returns the matrix elements AA or BB(if eig is not Flase) in the Wannier gauge

Parameters:
  • mmn (~wannierberri.system.w90_files.MMN) – the overlap matrix elements between the Wavefunctions at neighbouring k-points

  • transl_inv (bool) – if True, the band-diagonal matrix elements are calculated using the Marzari & Vanderbilt translational invariant formula

  • eig (~wannierberri.system.w90_files.EIG) – the eigenvalues of the Hamiltonian, needed to calculate BB (if None, the matrix elements are AA)

  • phase (np.ndarray(shape=(num_wann, num_wann, nnb), dtype=complex)) – the phase factors to be applied to the matrix elements (if None, no phase factors are applied)

  • sum_b (bool) – if True, the matrix elements are summed over the neighbouring k-points. Otherwise, the matrix elements are stored in a 5D array of shape (num_kpts, num_wann, num_wann, nnb, 3)

Returns:

  • np.ndarray(shape=(num_kpts, num_wann, num_wann, nnb, 3), dtype=complex) (if sum_b=False)

  • or np.ndarray(shape=(num_kpts, num_wann, num_wann, nnb, 3), dtype=complex) (if sum_b=True) – the q-resolved matrix elements AA or BB in the Wannier gauge

get_AA_q(mmn, transl_inv=False)[source]

A wrapper for get_AA_qb with sum_b=True see ‘~wannierberri.system.w90_files.CheckPoint.get_AA_qb’ for more details

get_AA_qb(mmn, transl_inv=False, phase=None, sum_b=False)[source]

A wrapper for get_AABB_qb with eig=None see ‘~wannierberri.system.w90_files.CheckPoint.get_AABB_qb’ for more details

get_BB_qb(mmn, eig, phase=None, sum_b=False)[source]

a wrapper for get_AABB_qb to evaluate BB matrix elements. (transl_inv is disabled) see ‘~wannierberri.system.w90_files.CheckPoint.get_AABB_qb’ for more details

get_CCOOGG_qb(mmn, uhu, antisym=True, phase=None, sum_b=False)[source]

Returns the matrix elements CC, OO or GG in the Wannier gauge

Parameters:
  • mmn (~wannierberri.system.w90_files.MMN) – the overlap matrix elements between the Wavefunctions at neighbouring k-points

  • uhu (~wannierberri.system.w90_files.UHU or ~wannierberri.system.w90_files.UIU) – the matrix elements uhu or uiu produced by pw2wannier90

  • antisym (bool) – if True, the antisymmetric piece of the matrix elements is calculated. Otherwise, the full matrix is calculated

  • phase (np.ndarray(shape=(num_wann, num_wann, nnb), dtype=complex)) – the phase factors to be applied to the matrix elements (if None, no phase factors are applied)

  • sum_b (bool) – if True, the matrix elements are summed over the neighbouring k-points. Otherwise, the matrix elements are stored in a 6D array of shape (num_kpts, num_wann, num_wann, nnb, nnb, 3)

Returns:

  • np.ndarray(shape=(num_kpts, num_wann, num_wann, nnb, nnb, 3), dtype=complex) (if sum_b=False)

  • or np.ndarray(shape=(num_kpts, num_wann, num_wann, nnb, nnb, 3), dtype=complex) (if sum_b=True) – the q-resolved matrix elements CC, OO or GG in the Wannier gauge

get_CC_qb(mmn, uhu, phase=None, sum_b=False)[source]

A wrapper for get_CCOOGG_qb with antisym=True see ‘~wannierberri.system.w90_files.CheckPoint.get_CCOOGG_qb’ for more details

get_GG_qb(mmn, uiu, phase=None, sum_b=False)[source]

A wrapper for get_CCOOGG_qb with antisym=False see ‘~wannierberri.system.w90_files.CheckPoint.get_CCOOGG_qb’ for more details

get_HH_q(eig)[source]

Returns the Hamiltonian matrix in the Wannier gauge

Parameters:

eig (~wannierberri.system.w90_files.EIG) – the eigenvalues of the Hamiltonian

Returns:

the Hamiltonian matrix in the Wannier gauge

Return type:

np.ndarray

get_OO_qb(mmn, uiu, phase=None, sum_b=False)[source]

A wrapper for get_CCOOGG_qb with antisym=False see ‘~wannierberri.system.w90_files.CheckPoint.get_CCOOGG_qb’ for more details (actually, the same as “~wannierberri.system.w90_files.CheckPoint.get_CC_qb”)

get_SHA_q(shu, mmn, phase=None, sum_b=False)[source]

SHA or SA (if siu is used instead of shu)

get_SHR_q(spn, mmn, eig=None, phase=None)[source]

SHR or SR(if eig is None)

get_SH_q(spn, eig)[source]
get_SS_q(spn)[source]

Returns the spin matrix in the Wannier gauge

Parameters:

spn (~wannierberri.system.w90_files.SPN) – the spin matrix

Returns:

the spin matrix in the Wannier gauge

Return type:

np.ndarray

get_wannier_centers(mmn, spreads=False)[source]

calculate wannier centers with the Marzarri-Vanderbilt translational invariant formula and optionally the spreads

Parameters:
  • mmn (~wannierberri.system.w90_files.MMN) – the overlap matrix elements between the Wavefunctions at neighbouring k-points

  • spreads (bool) – if True, the spreads are calculated

Returns:

  • np.ndarray(shape=(num_wann, 3), dtype=float) – the wannier centers

  • np.ndarray(shape=(num_wann,), dtype=float) – the wannier spreads (in Angstrom^2) (if spreads=True)

property wannier_centers
wannier_gauge(mat, ik1, ik2)[source]

Returns the matrix elements in the Wannier gauge

Parameters:
  • mat (np.ndarray) – the matrix elements in the Hamiltonian gauge

  • ik1 (int) – the indices of the k-points

  • ik2 (int) – the indices of the k-points

Returns:

the matrix elements in the Wannier gauge

Return type:

np.ndarray

class wannierberri.w90files.CheckPoint_bare(win, eig, amn, mmn)[source]

Bases: CheckPoint

Class to store data from Wanierisationm obtained internally Initialize without the v_matrix (to be written later by ~wannierberri.system.disentangle)

Parameters:
  • win (~wannierberri.system.w90_files.WIN)

  • eig (~wannierberri.system.w90_files.EIG)

  • amn (~wannierberri.system.w90_files.AMN)

  • mmn (~wannierberri.system.w90_files.MMN)

class wannierberri.w90files.MMN(seedname='wannier90', npar=2, **kwargs)[source]

Bases: W90_file

class to store overlaps between Bloch functions at neighbouring k-points the MMN file of wannier90

MMN.data[ik, ib, m, n] = <u_{m,k}|u_{n,k+b}>

Parameters:
  • seedname (str) – the prefix of the file (including relative/absolute path, but not including the extension .mmn)

  • npar (int) – the number of parallel processes to be used for reading the file

data

the overlap matrix elements between the Wavefunctions at neighbouring k-points

Type:

np.ndarray(shape=(NK, NNB, NB, NB), dtype=complex)

neighbours

the indices of the neighbouring k-points

Type:

np.ndarray(shape=(NK, NNB), dtype=int)

G

the reciprocal lattice vectors connecting the k-points

Type:

np.ndarray(shape=(NK, NNB, 3), dtype=int)

from_w90_file(seedname, npar)[source]

abstract method to read the necessary data from Wannier90 file

get_disentangled(v_left, v_right)[source]

Reduce number of bands

Parameters:
  • v_matrix (np.ndarray(NB,num_wann)) – the matrix of column vectors defining the Wannier gauge

  • v_matrix_dagger (np.ndarray(num_wann,NB)) – the Hermitian conjugate of v_matrix

Returns:

the disentangled MMN object

Return type:

~wannierberri.system.w90_files.MMN

property n_neighb

number of nearest neighbours indices

set_bk(kpt_latt, mp_grid, recip_lattice, kmesh_tol=1e-07, bk_complete_tol=1e-05)[source]
set_bk_chk(chk, **argv)[source]
to_w90_file(seedname)[source]
class wannierberri.w90files.SHU(seedname='wannier90', formatted=False, **kwargs)[source]

Bases: SXU

SHU.data[ik, ib, m, n, ipol] = <u_{m,k}|S_ipol*H(k)|u_{n,k+b}>

Parameters:
  • seedname (str) – the prefix of the file (including relative/absolute path, but not including the extensions, like .sHu, sIu)

  • formatted (bool) – if True, the file is expected to be formatted, otherwise it is binary

  • kwargs (dict(str, Any)) – the keyword arguments to be passed to the parent constructor, see ~wannierberri.system.w90_files.SXU for more details

class wannierberri.w90files.SIU(seedname='wannier90', formatted=False, **kwargs)[source]

Bases: SXU

SIU.data[ik, ib, m, n, ipol] = <u_{m,k}|S_ipol|u_{n,k+b}>

Parameters:
  • seedname (str) – the prefix of the file (including relative/absolute path, but not including the extensions, like .sIu, sHu)

  • formatted (bool) – if True, the file is expected to be formatted, otherwise it is binary

  • kwargs (dict(str, Any)) – the keyword arguments to be passed to the parent constructor, see ~wannierberri.system.w90_files.SXU for more details

class wannierberri.w90files.SPN(seedname='wannier90', **kwargs)[source]

Bases: W90_file

SPN.data[ik, m, n, ipol] = <u_{m,k}|S_ipol|u_{n,k}>

from_w90_file(seedname='wannier90', formatted=False)[source]

abstract method to read the necessary data from Wannier90 file

class wannierberri.w90files.UHU(seedname='wannier90', **kwargs)[source]

Bases: UXU

UHU.data[ik, ib1, ib2, m, n] = <u_{m,k+b1}|H(k)|u_{n,k+b2}>

class wannierberri.w90files.UIU(seedname='wannier90', **kwargs)[source]

Bases: UXU

UIU.data[ik, ib1, ib2, m, n] = <u_{m,k+b1}|u_{n,k+b2}>

class wannierberri.w90files.WIN(seedname='wannier90', data=None)[source]

Bases: object

Class to read and store the wannier90.win input file

Parameters:

seedname (str) – the prefix of the file (including relative/absolute path, but not including the extensions, like .win)

name

the name of the file

Type:

str

parsed

the parsed data

Type:

dict(str, Any)

units_length

the units of length (Angstrom or Bohr radius)

Type:

dict(str, float)

get_atoms()[source]
get_kpoints()[source]

Get the kpoints in reciprocal coordinates

Returns:

the kpoints in reciprocal coordinates

Return type:

numpy.ndarray(float, shape=(NK, 3))

get_projections()[source]

Get the projections

Returns:

the projections in the wannier90 format

Return type:

list(str)

get_unit_cell_cart_ang()[source]

Get the unit cell in Angstrom in Cartesian coordinates

Returns:

the unit cell in Angstrom in Cartesian coordinates

Return type:

numpy.ndarray(float, shape=(3, 3))

write(seedname=None, comment='written by WannierBerri')[source]

Write the wannier90.win file

Parameters:
  • seedname (str) – the prefix of the file (including relative/absolute path, but not including the extensions, like .win) if None, the file is written to self.seedname + “.win”

  • comment (str) – the comment to be written at the beginning of the file