readfiles

class irrep.readfiles.ParserAbinit(filename)[source]

Parse header of the WFK file of Abinit.

Parameters:

filename (str) – Name of the WFK file of Abinit.

fWFK

Corresponds to the WFK file.

Type:

file object

kpt

Each row contains the direct coordinates of a k-point.

Type:

array

nband

Each element contains the number of bands in a k-point.

Type:

array

spinor

Whether the DFT calculation involved spinors (SOC) or not

Type:

bool

npwarr

Each element is the number of plane waves used at a k-point

Type:

array

kpt

Each row contains the coordinates of a k-point in the DFT BZ

Type:

array

Notes

Abinit’s routines that write the header can be found here or in the file src/56_io_mpi/m_hdr.f90.

parse_header(v=0)[source]

Parse header of WFK file and save as attributes quantities that will be used in the rest of methods

Parameters:

v (int, default=0) – Verbosity level. Default set to minimal printing

Returns:

  • nband (array) – Each element contains the number of bands in a k-point.

  • nkpt (int) – Number of k-points in WFK file

  • rprimd (array) – Each row contains the Cartesian coords of a DFT cell vector

  • ecut (float) – Plane-wave cutoff used for the DFT calculation

  • spinor (bool) – Whether the DFT calculation involved spinors (SOC) or not

  • typat (array) – Each element is an integer expressing the type ion

  • xred (array) – Each row contains the direct coords of an ion

  • efermi (float) – Fermi energy

parse_kpoint(ik)[source]

Parse block of a k-point from WFK file

Returns:

  • CG (array) – Each row contains the coefficients of the plane-wave expansion of a wave function

  • eigen (array) – Energies of the wave functions

  • kg (array) – Each row contains the direct coords of a reciprocal vector used in the expansion of wave functions

class irrep.readfiles.ParserEspresso(prefix)[source]

Parser of the interface for Quantum Espresso

Parameters:

prefix (str) – Prefix that serves as path to the .save directory. For example: if the path is ./foo/bar.save then prefix is foo/bar.

prefix

Prefix that serves as path to the .save directory.

Type:

str

input

Instance of Element in the ElementTree XML API corresponding to tag input in data-file-schema.xml file

Type:

class

bandstructure

Instance of Element in the ElementTree XML API corresponding to tag band_structure in data-file-schema.xml file

Type:

class

spinor

Whether wave functions are spinors (SOC)

Type:

bool

parse_header()[source]

Parse universal info of the bandstructure from data-file-schema.xml file

Returns:

  • spinpol (bool) – Whether the calculation is spin-polarized

  • Ecut0 (float) – Plane-wave cutoff (in eV) used in DFT

  • EF (float) – Fermi energy in eV

  • NK (int) – Number of k-points

  • NBin_list (list) – If the calculation was spin polarized, NBin_list[0] and NBin_list[1] are the number of bands for spin up and down channels, respectively. Otherwise, NBin_list[0] is the number of bands.

parse_kpoint(ik, NBin, spin_channel, v=0)[source]

Parse block of a particular k-point from data-file-schema.xml file

Parameters:
  • ik (int) – Index of the k-point

  • NBin (int) – Number of bands

  • spin_channel (str) – up for spin up, dw for spin down, None if not spin polarized

Returns:

  • WF (array) – Each row contains the coefficients of the plane-wave expansion of a wave function

  • Energy (array) – Energy levels in eV. Degenerate levels are repeated

  • kg (array) – Each row contains the direct coords (ints) of a plane wave’s reciprocal lattice vector

  • kpt (array) – Direct coords of the k-point w.r.t. DFT cell vectors

  • v (int, default=0) – Verbosity level. Default set to minimalistic printing

parse_lattice()[source]

Parse info about the crystal structure from data-file-schema.xml file

Returns:

  • lattice (array) – Each row contains the cartesian coords of a DFT unit cell vector

  • positions (array) – Each row contains the direct coords of an ion in the DFT cell

  • typat (list) – Indices that describe the type of element at each position. All ions of the same type share the same index.

  • alat (float) – Lattice parameter in Quantum Espresso’s convention

class irrep.readfiles.ParserVasp(fPOS, fWAV, onlysym=False)[source]

Parser for Vasp interface

Parameters:
  • fPOS (str) – Name of the POSCAR file.

  • fWAV (str) – Name of the WAVECAR file.

  • onlysym (bool) – To stop right after parsing the POSCAR, before parsing the header of the WAVECAR.

fPOS

Name of the POSCAR file.

Type:

str

fWAV

Instance of WAVECARFILE

Type:

class

parse_header()[source]

Parse header of WAVECAR

Returns:

  • NK (int) – Number of k-points

  • NBin (int) – Number of bands

  • Ecut0 (float) – Plane-wave cutoff (in eV) used in DFT

  • lattice (array) – Each row contains the cartesian coords of a unit cell vector

parse_kpoint(ik, NBin, spinor)[source]

Parse block of a particular k-point from WAVECAR

Parameters:
  • ik (int) – Index of the k-point

  • NBin (int) – Number of bands

  • spinor (bool) – Whether wave functions are spinors (SOC)

Returns:

  • Energy (array) – Energy levels. Degenerate levels are repeated

  • kpt (array) – Direct coords of the k-points with respect to the basis vectors of the DFT reciprocal space cell

  • npw (int) – Number of plane waves in the expansion of wave functions

parse_poscar(v=0)[source]

Parses POSCAR.

Parameters:

v (int, default=0) – Verbosity level. Default set to minimal printing

Returns:

  • lattice (array) – 3x3 array where cartesian coordinates of basis vectors a, b and c are given in rows.

  • positions (array) – Each row contains the direct coordinates of an ion’s position.

  • typat (list) – Each element is a number identifying the atomic species of an ion.

class irrep.readfiles.ParserW90(prefix)[source]

Parser for Wannier90’s interface

Parameters:

prefix (str) – Part of the path that serves as prefix for the wannier90.win file. For example: if the path is ./foo/bar.win, then prefix is foo/bar

prefix

Part of the path that serves as prefix for the wannier90.win file.

Type:

str

fwin

Each element is a list of a non-comment line in wannier90.win file, split by blank spaces

Type:

list

ind

Each element is the first keyword of a line in wannier90.win

Type:

list

iterwin

Iterator object for attribute fwin

Type:

iterator object

NBin

Number of DFT bands

Type:

int

spinor

Whether wave functions are spinors (SOC)

Type:

bool

NK

Number of k-points in DFT calculation

Type:

int

check_end(name)[source]

Check if block in .win file is closed.

Parameters:

name (str) – Name of the block in .win file.

Raises:

RuntimeError – Block is not closed.

get_param(key, tp, default=None, join=False)[source]

Return value of a parameter in .win file.

Parameters:
  • key (str) – Wannier90 input parameter.

  • tp (function) – Function to apply to the value of the parameter, before returning it.

  • default – Default value to return in case parameter key is not found.

  • join (bool, default=False) – If the value of parameter key contains more than one element, they will be concatenated with a blank space if join is set to True. Used when the parameter is mpgrid.

Returns:

Return the value of the parameter, after applying function passed es keyword tp.

Return type:

Type(tp)

Raises:

RuntimeError – The parameter is not found in .win file, it is found more than once or its value is formed by many elements but it is not mpgrid.

parse_energies()[source]

Parse energies from wannier90.eig file

Returns:

Energy – Each row contains the energy levels of a k-point. Degenerate levels are repeated

Return type:

array

parse_grid(ik)[source]

Parse grid of plane waves for a k-point from the file of wave functions

Parameters:

ik (int) – Index of k-point

Returns:

  • ngx (int) – Number of k-point along 1st direction in reciprocal space

  • ngy (int) – Number of k-point along 2nd direction in reciprocal space

  • ngz (int) – Number of k-point along 3rd direction in reciprocal space

parse_header()[source]

Parse universal properties of the band structure

Returns:

  • NK (int) – Number of k-points in DFT calculation

  • NBin (int) – Number of DFT bands

  • spinor (bool) – Whether wave functions are spinors (SOC)

  • EF (float) – Fermi energy in eV

parse_kpoint(ik, selectG)[source]

Parse wave functions’ file of a k-point

Parameters:
  • ik (int) – Index of the k-point

  • selectG (array) – First 3 rows of the array returned by calc_gvectors()

Returns:

WF – Each row contains the coefficients of the expansion of a wave function in plane waves

Return type:

array

parse_lattice()[source]

Parse crystal structure from wannier90.win file

Returns:

  • lattice (array) – Each row contains the cartesian coords of a DFT unit cell vector

  • positions (array) – Each row contains the direct coords of an ion in the DFT cell

  • typat (list) – Indices that describe the type of element at each position. All ions of the same type share the same index.

  • kpred (array) – Each row contains the direct coords of a k-point in the DFT cell

class irrep.readfiles.WAVECARFILE(filename, RL=3)[source]

Routines to read info from file WAVECAR of VASP.

Parameters:
  • fname (str, default=None) – Name of the WAVECAR file.

  • RL (int, default=3) – Length parameter used to locate info in the file.

f

Corresponds to fname.

Type:

file object

rl

Equal to parameter RL.

Type:

int

record(irec, cnt=inf, dtype=<class 'float'>)[source]

An auxilary function to get records from WAVECAR

irrep.readfiles.record_abinit(fWFK, st)[source]

An auxilary function to get records from WAVECAR

Parameters:
  • fWFK (file object) – Corresponds to the WFK file of Abinit.

  • st (str) – Format to be read.

Returns:

r – String read.

Return type:

str