schrodinger.application.matsci.espresso.qeoutput module

Classes and functions to deal reading XML generated by Quantum Espresso.

Copyright Schrodinger, LLC. All rights reserved.

class schrodinger.application.matsci.espresso.qeoutput.KptLegend(label, coords)

Bases: tuple

__contains__

Return key in self.

__init__

Initialize self. See help(type(self)) for accurate signature.

__len__

Return len(self).

coords

Alias for field number 1

count(value) → integer -- return number of occurrences of value
index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

label

Alias for field number 0

class schrodinger.application.matsci.espresso.qeoutput.WfcType(atom_idx, atom_type, n_qn, l_qn, m_qn)

Bases: tuple

__contains__

Return key in self.

__init__

Initialize self. See help(type(self)) for accurate signature.

__len__

Return len(self).

atom_idx

Alias for field number 0

atom_type

Alias for field number 1

count(value) → integer -- return number of occurrences of value
index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

l_qn

Alias for field number 3

m_qn

Alias for field number 4

n_qn

Alias for field number 2

class schrodinger.application.matsci.espresso.qeoutput.EsmType(data, bc_type, efield)

Bases: tuple

__contains__

Return key in self.

__init__

Initialize self. See help(type(self)) for accurate signature.

__len__

Return len(self).

bc_type

Alias for field number 1

count(value) → integer -- return number of occurrences of value
data

Alias for field number 0

efield

Alias for field number 2

index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

class schrodinger.application.matsci.espresso.qeoutput.OutStruct(struct, std_struct)

Bases: tuple

__contains__

Return key in self.

__init__

Initialize self. See help(type(self)) for accurate signature.

__len__

Return len(self).

count(value) → integer -- return number of occurrences of value
index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

std_struct

Alias for field number 1

struct

Alias for field number 0

schrodinger.application.matsci.espresso.qeoutput.gaussian_delta(eigenval, energies, degauss)

Get Gaussian-function values

Parameters:
  • eigenval (float) – Energy at which to calculate Gaussian delta
  • energies (numpy.array) – Energy grid
  • degauss (float) – Broadening
Return type:

numpy.array

Returns:

delta values on the grid

class schrodinger.application.matsci.espresso.qeoutput.OrderedDefaultDict(default_factory=None, *args, **kwargs)

Bases: collections.OrderedDict

This class implements ordered default dict functionality.

__init__(default_factory=None, *args, **kwargs)

Initialize OrderedDefaultDict class. See parent classes for more documentation.

Parameters:default_factory (callable method) – Callable to be invoked when a new item is created
__contains__()

True if D has a key k, else False.

__len__

Return len(self).

clear() → None. Remove all items from od.
copy() → a shallow copy of od
fromkeys(S[, v]) → New ordered dictionary with keys from S.

If not specified, the value defaults to None.

get(k[, d]) → D[k] if k in D, else d. d defaults to None.
items() → a set-like object providing a view on D's items
keys() → a set-like object providing a view on D's keys
move_to_end()

Move an existing element to the end (or beginning if last==False).

Raises KeyError if the element does not exist. When last=True, acts like a fast version of self[key]=self.pop(key).

pop(k[, d]) → v, remove specified key and return the corresponding

value. If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() → (k, v), return and remove a (key, value) pair.

Pairs are returned in LIFO order if last is true or FIFO order if false.

setdefault(k[, d]) → od.get(k,d), also set od[k]=d if k not in od
update([E, ]**F) → None. Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() → an object providing a view on D's values
class schrodinger.application.matsci.espresso.qeoutput.KPoint(tag, vecs=None)

Bases: object

Class to hold information about a k-point.

__init__(tag, vecs=None)

Initialize KPoint object from ElementTree element.

Parameters:
  • tag (xml.etree.ElementTree.Element) – k_point tag
  • vecs (numpy array (3x3)) – Cell vectors
getCoords(coords_str)

Return list of coordinates.

Parameters:coords_str (str) – String representing K-point coordinates
Return type:list of three floats
Returns:K-point coordinates
getCoordsStr(frac=False)

Get string representation of the coordinates.

Parameters:frac (bool) – If True, self.frac_coords are returned, otherwise self.cart_coords
Return type:str
Returns:String representation of the coordinates
static getKptFromCfg(kpt)
class schrodinger.application.matsci.espresso.qeoutput.DOS(band, dos_fn)

Bases: object

Basic DOS class, based on the class from pymatgen (MIT license).

__init__(band, dos_fn)

Initialize DOS object. ‘band’ can be None, in this case, dos_fn MUST point to the .dos file. If both ‘band’ and ‘dos_fn’ are present, former one has priority.

Parameters:
  • band (BandStructure) – BandStructure object to extract eigenvalues and k-points from
  • dos_fn (str) – .dos filename. This file holds DOS plot data
getDOS(degauss, delta_e=0.01)

Broaden energies and set DOS in self.dos. This requires self.band to be set in the constructor.

Parameters:
  • degauss (float) – Used only if dos is True, broadening (eV) for computing DOS
  • delta_e (float) – Used only if dos is True, energy grid spacing (in eV)
Raises:

ValueError – If self.band is None

getDensities(spin=None)

Get density of states for a particular spin.

Parameters:spin (str or None) – Can be SPIN_UP or SPIN_DW or None.
Return type:numpy.array
Returns:Density of states for a particular spin. If Spin is None, the sum of all spins is returned.
getCbmVbm(tol=0.001, abs_tol=False, spin=None)

Get Conduction Band Minimum (cbm) and Valence Band Maximum (vbm).

Param:

tolerance in occupations for determining the cbm/vbm

Parameters:
  • abs_tol (bool) – An absolute tolerance (True) or a relative one (False)
  • spin (str or None) – Possible values are None - finds the cbm/vbm in the summed densities, SPIN_UP - finds the cbm/vbm in the up spin channel, SPIN_DW - finds the cbm/vbm in the down spin channel.
Return type:

float, float

Returns:

cbm and vbm in Ry corresponding to the gap

getGap(tol=0.001, abs_tol=False, spin=None)

Get the gap.

Param:

tolerance in occupations for determining the gap

Parameters:
  • abs_tol (bool) – An absolute tolerance (True) or a relative one (False)
  • spin (str or None) – Possible values are None - finds the gap in the summed densities, SPIN_UP - finds the gap in the up spin channel, SPIN_DW - finds the gap in the down spin channel.
Return type:

float

Returns:

gap in Ry or 0.0, if it is a metal

class schrodinger.application.matsci.espresso.qeoutput.PhDOS(file_fh)

Bases: object

Phonon DOS class.

__init__(file_fh)

Initialize PhDOS object.

Parameters:file_fh (File handler of phonon DOS from matdyn.x) – file object
c_v(temperature)

Constant volume specific heat C_v at temperature T obtained from the integration of the DOS. Only positive frequencies will be used. Result in J/(K*mol-c). A mol-c is the abbreviation of a mole-cell, that is, the number of Avogadro times the atoms in a unit cell. To compare with experimental data the result should be divided by the number of unit formulas in the cell. If the structure is provided the division is performed internally and the result is in J/(K*mol).

Parameters:temperature (float) – Temperature at which to evaluate C_v, in K
Return type:float
Returns:Constant volume specific heat C_v in J/(K*mol)
entropy(temperature)

Vibrational entropy at temperature T obtained from the integration of the DOS. Only positive frequencies will be used. Result in J/(K*mol-c). A mol-c is the abbreviation of a mole-cell, that is, the number of Avogadro times the atoms in a unit cell. To compare with experimental data the result should be divided by the number of unit formulas in the cell. If the structure is provided the division is performed internally and the result is in J/(K*mol).

Parameters:temperature (float) – Temperature at which to evaluate C_v, in K
Return type:float
Returns:Vibrational entropy in J/(K*mol)
internal_energy(temperature)

Phonon contribution to the internal energy at temperature T obtained from the integration of the DOS. Only positive frequencies will be used. Result in J/mol-c. A mol-c is the abbreviation of a mole-cell, that is, the number of Avogadro times the atoms in a unit cell. To compare with experimental data the result should be divided by the number of unit formulas in the cell. If the structure is provided the division is performed internally and the result is in J/mol.

Parameters:temperature (float) – Temperature at which to evaluate energy, in K
Return type:float
Returns:Phonon contribution to the internal energy, in J/mol.
helmholtz_free_energy(temperature)

Phonon contribution to the Helmholtz free energy at temperature T obtained from the integration of the DOS. Only positive frequencies will be used. Result in J/mol-c. A mol-c is the abbreviation of a mole-cell, that is, the number of Avogadro times the atoms in a unit cell. To compare with experimental data the result should be divided by the number of unit formulas in the cell. If the structure is provided the division is performed internally and the result is in J/mol.

Parameters:temperature (float) – Temperature at which to evaluate free energy, in K
Return type:float
Returns:Phonon contribution to the Helmholtz free energy, in J/mol
zero_point_energy()

Zero point energy energy of the system. Only positive frequencies will be used. Result in J/mol-c. A mol-c is the abbreviation of a mole-cell, that is, the number of Avogadro times the atoms in a unit cell. To compare with experimental data the result should be divided by the number of unit formulas in the cell. If the structure is provided the division is performed internally and the result is in J/mol.

Parameters:temperature (float) – Temperature at which to evaluate ZPE, in K
Return type:float
Returns:Phonon contribution to ZPE, in J/mol
class schrodinger.application.matsci.espresso.qeoutput.PDOS(proj, wfc_types, efermi, band)

Bases: object

Class that holds partial DOS (PDOS) data. Call getPDOS to get broadened data.

NUM_IDX = 5
LDOS_IDX = 0
ADOS_IDX = 1
EDOS_IDX = 2
AIDOS_IDX = 3
ALDOS_IDX = 4
__init__(proj, wfc_types, efermi, band)

Initialize PDOS object. Constructor only assigns values, call getPDOS for broadening.

Parameters:
  • proj (dict of 3d numpy.array) – Dict with SPIN_UP, SPIN_DW (optional) keys, each containing a 3D array containing: index of projected atom wavefunction, index of k-point, index of band and WFC projection as value.
  • wfc_types (list of WfcType) – List containing wavefunction types description
  • efermi (float) – Fermi energy in eV
getPDOS(degauss, delta_e=0.01)

Calculate PDOS and set in self.pdos.

Parameters:
  • degauss (float) – Broadening (eV) for computing PDOS
  • delta_e (float) – Energy grid spacing eV
class schrodinger.application.matsci.espresso.qeoutput.BandStructure(kpoints, eigenvals, efermi, struct=None)

Bases: object

This class is based on the class from pymatgen (MIT license).

__init__(kpoints, eigenvals, efermi, struct=None)

Initialize BandStructure object.

Param:

List of k-points for this band structure

Parameters:
  • eigenvals (dict) –

    Energies of the band structure in the shape: {SPIN_UP: numpy.array([iband, jkpoint]),

    SPIN_DW: numpy.array([iband, jkpoint])}

    SPIN_DW key can be present or not depending on the calculation type

  • efermi (float) – Fermi energy in Hartree
  • struct (structure.Structure) – Related structure
isMetal()

Check if the band structure indicates a metal by looking if the Fermi level crosses a band.

Return type:bool
Returns:True, if the system is metallic
getVbmCbm(vbm=True)

Return data about the valence band maximum (VBM) or conduction band minimum (CBM).

Parameters:vbm (bool) – If True calculates VBM, if False CBM
Return type:dict
Returns:
dict with keys BAND_INDEX_KEY, KPOINT_INDEX_KEY, KPOINT_KEY,
ENERGY_KEY
  • BAND_INDEX_KEY: A dict with spin keys pointing to a list of the

indices of the band containing the VBM (please note that you can have several bands sharing the VBM) {SPIN_UP:[], SPIN_DW:[]} - KPOINT_INDEX_KEY: The list of indices in self.kpoints for the kpoint vbm. Please note that there can be several kpoint_indices relating to the same kpoint (e.g., Gamma can occur at different spots in the band structure line plot) - KPOINT_KEY: The kpoint (as a kpoint object) - ENERGY_KEY: The energy of the VBM

getBandGap()

Get band gap data.

Return type:dict
Returns:dict with keys ENERGY_KEY, DIRECT_KEY, TRANSITION_KEY: ENERGY_KEY: band gap energy DIRECT_KEY: A boolean telling if the gap is direct or not TRANSITION_KEY: kpoint labels of the transition (e.g., “Gamma-X”)
generatePlotData()

Generate distances between k-points (in self.distances) for plotting band structure.

class schrodinger.application.matsci.espresso.qeoutput.Output(qegz_fn, struct=False, band=False, dos=False, pdos=False, esm=False, neb=False, phdos=False, phband=False, dynamics=False, epsilon=False, hpu=False, tree=None)

Bases: object

Class to deal with QE XML output parsing.

__init__(qegz_fn, struct=False, band=False, dos=False, pdos=False, esm=False, neb=False, phdos=False, phband=False, dynamics=False, epsilon=False, hpu=False, tree=None)

Initialize Output object.

Parameters:
  • qegz_fn (str) – Archive name of the compressed .save folder
  • struct (bool) – If True, parse and create structure in self.struct of type structure.Structure
  • band (bool) – If true, parse and store energies at different k-points in self.band of type BandStructure
  • dos (bool) – If true, compute density of states and store in self.dos of type DOS
  • pdos (bool) – If true, compute projected density of states and store in self.pdos of type PDOS
  • esm (bool) – If true, try to extract density/potential data and store it in self.esm
  • phdos (bool) – If true, try to extract phonons frequencies and generate phonons DOS in self.phdos
  • epsilon (bool) – If true, try to extract dielectric function data in self.epsilon
  • hpu (bool) – Parse Hubbard U from hp.x if True
getMDStepStruct(step, timestep)

Extract MD step structure from step XML.

Parameters:
  • step (xml.etree.ElementTree.Element) – step element
  • timestep (float) – MD time step
Return type:

structure.Structure, structure.Structure or None

Returns:

Structure of the MD step, standardized structure if requested and found

static parseHP(hp_fh)

Parse and return data from the Hubbard_parameters.dat.

Parameters:hp_fh (File handler object) – Handler of the Hubbard_parameters.dat
Return type:dict
Returns:Dictionary with atom indexes as keys and Hubbard U as values