storing and handling Wannier90 input and output files
- class wannierberri.w90files.Wannier90data(seedname='wannier90', read_npz=True, write_npz_list=('mmn', 'eig', 'amn'), write_npz_formatted=True, overwrite_npz=False, formatted=(), readfiles=())[source]
Bases:
objectA class to describe all input files of wannier90, and to construct the Wannier functions
- 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.mmn)
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
CheckPointfile, otherwise create a “bare”CheckPointobject and prepare for wannierisationkmesh_tol – float see
CheckPointbk_complete_tol – float see
CheckPoint
- chk
the checkpoint file
- Type:
~wannierberri.w90files.CheckPoint or ~wannierberri.w90files.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)
- readfiles
the list of files to be read durint the initialization. Others may be read later.
- Type:
list(str)
- __init__(seedname='wannier90', read_npz=True, write_npz_list=('mmn', 'eig', 'amn'), write_npz_formatted=True, overwrite_npz=False, formatted=(), readfiles=())[source]
- select_bands(win_min=-inf, win_max=inf, band_start=None, band_end=None, selected_bands=None, allow_again=False)[source]
exclude some bands from the data
- Parameters:
win_min (float) – the minimum and maximum energy of the window. Only the bands that are ENTIRELY below win_min or ENTIRELY above win_max are EXCLUDED
win_max (float) – the minimum and maximum energy of the window. Only the bands that are ENTIRELY below win_min or ENTIRELY above win_max are EXCLUDED
band_start (int) – the range of bands to be included (the numeration in the current system, not in the original (if bands are selected more than once)) note : the pythonic indexing is used, so the included bands are [band_start, band_start+1, … band_end-1]
band_end (int) – the range of bands to be included (the numeration in the current system, not in the original (if bands are selected more than once)) note : the pythonic indexing is used, so the included bands are [band_start, band_start+1, … band_end-1]
selected_bands (array((NB,), dtype=bool) or list of int) – if present, the those bands are selected, and the other parameters are ignored
allow_again (bool) – if False, but bands were already selected, raise an error.
- Returns:
new_selected_bands – the indices of bands that were actually selected. If data files are added to the dataset later, one should manually select those bands before adding, using the select_bands method of those objects
- Return type:
list of int
- set_random_symmetric_projections()[source]
Set random symmetric projections for the system, according to the symmetrizer object
- 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.w90file.W90_file(autoread=False, **kwargs)[source]
Bases:
SavableNPZAbstract class for the files of wannier90
- Parameters:
seedname (str) – the prefix of the file (including relative/absolute path, but not including the extensions, like .chk, .mmn, etc)
ext (str) – the extension of the file, e.g. ‘mmn’, ‘eig’, ‘amn’, ‘uiu’, ‘uhu’, ‘siu’, ‘shu’, ‘spn’
tags (list(str)) – the tags to be saved in the npz file
read_npz (bool) – if True, try to read the files converted to npz (e.g. wanier90.mmn.npz instead of wannier90.mmn)
write_npz (bool) – if True, write the files to npz
kwargs (dict) – the keyword arguments to be passed to the constructor of the file see
MMN,EIG,AMN,UIU,UHU,SIU,SHU,SPN,WINfor more details
- npz_tags
the tags to be saved/loaded in the npz file
- Type:
list(str)
- class wannierberri.w90files.AMN(seedname='wannier90', npar=2, **kwargs)[source]
Bases:
W90_fileClass 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)
- from_w90_file(seedname, npar)[source]
abstract method to read the necessary data from Wannier90 file
- select_bands(selected_bands)[source]
Select the bands to be used in the calculation, the rest are excluded
- Parameters:
selected_bands (list of int or bool) – the indices of the bands to be used, or a boolean mask
- class wannierberri.w90files.CheckPoint(real_lattice=None, num_wann=None, num_bands=None, num_kpts=None, wannier_centers_cart=None, wannier_spreads=None, v_matrix=None, kpt_latt=None, mp_grid=None, kmesh_tol=1e-07, bk_complete_tol=1e-05)[source]
Bases:
objectA 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.w90files.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.w90files.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
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
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
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 (
MMN) – the overlap matrix elements between the Wavefunctions at neighbouring k-pointsuhu (
UHUorUIU) – the matrix elements uhu or uiu produced by pw2wannier90antisym (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
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
get_CCOOGG_qb()for more details
- get_HH_q(eig)[source]
Returns the Hamiltonian matrix in the Wannier gauge
- Parameters:
eig (~wannierberri.w90files.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
get_CCOOGG_qb()for more details (actually, the same asget_CC_qb())
- get_SS_q(spn)[source]
Returns the spin matrix in the Wannier gauge
- Parameters:
spn (~wannierberri.w90files.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 (
MMN) – the overlap matrix elements between the Wavefunctions at neighbouring k-pointsspreads (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 kpt_latt_int
Returns the k-points in the lattice basis
- spin_order_block_to_interlace()[source]
If the chk was obtain from a block ordering (like in old VASP versions), the ordering should be changed to interlace
- spin_order_interlace_to_block()[source]
If the chk was obtain from an interlace ordering, one may want to change the ordering to block
- 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.MMN(seedname='wannier90', npar=2, **kwargs)[source]
Bases:
W90_fileclass 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
- property n_neighb
number of nearest neighbours indices
- class wannierberri.w90files.SHU(seedname='wannier90', formatted=False, **kwargs)[source]
Bases:
SXUSHU.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:
SXUSIU.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_fileSPN.data[ik, m, n, ipol] = <u_{m,k}|S_ipol|u_{n,k}>
- class wannierberri.w90files.UHU(seedname='wannier90', **kwargs)[source]
Bases:
UXUUHU.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:
UXUUIU.data[ik, ib1, ib2, m, n] = <u_{m,k+b1}|u_{n,k+b2}>
- class wannierberri.w90files.WIN(seedname='wannier90', data=None, autoread=False)[source]
Bases:
objectClass 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)
- 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))
- update(dic)[source]
Update the parameters with a dictionary
Parameters:
dic(dict) : the dictionary with the new parameters
- 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
- class wannierberri.w90files.xxu.SXU(autoread=False, **kwargs)[source]
Bases:
W90_fileRead and setup sHu or sIu object. pw2wannier90 writes data_pw2w90[n, m, ipol, ib, ik] = <u_{m,k}|S_ipol * X|u_{n,k+b}> in column-major order. (X = H for SHU, X = I for SIU.) Here, we read to have data[ik, ib, m, n, ipol] = <u_{m,k}|S_ipol * X|u_{n,k+b}>.
- from_w90_file(seedname='wannier90', formatted=False, suffix='sHu', **kwargs)[source]
Read the sHu or sIu file
- 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
suffix (str) – the suffix of the file, e.g. ‘sHu’, ‘sIu’
kwargs (dict(str, Any)) – the keyword arguments to be passed to the constructor of the file see ~wannierberri.system.w90_files.SIU, ~wannierberri.system.w90_files.SHU for more details
- Raises:
AssertionError – if the file does not conform with the other files
Sets
- self.datanumpy.ndarray(complex, shape=(NK, NNB, NB, NB, 3)
the data of the file
- property n_neighb
number of nearest neighbours indices
- class wannierberri.w90files.xxu.UXU(autoread=False, **kwargs)[source]
Bases:
W90_fileRead and setup uHu or uIu object. pw2wannier90 writes data_pw2w90[n, m, ib1, ib2, ik] = <u_{m,k+b1}|X|u_{n,k+b2}> in column-major order. (X = H for UHU, X = I for UIU.) Here, we read to have data[ik, ib1, ib2, m, n] = <u_{m,k+b1}|X|u_{n,k+b2}>.
- from_w90_file(seedname='wannier90', suffix='uXu', formatted=False)[source]
abstract method to read the necessary data from Wannier90 file
- property n_neighb
number of nearest neighbours indices