PwParser

Class to perform the parsing of a QuantumESPRESSO XML file. Makes usage of the data-file-schema.xml file that is found in the run_dir/prefix.save folder.

class mppi.Parsers.PwParser.PwParser(file, verbose=True)[source]

Bases: object

Initialize the data member of the class.

Parameters:
  • file (str) – The name, including the path of the data-file-schema.xml

  • verbose (bool) – set the amount of information written on terminal

natoms

number of atoms in the cell

natypes

number of atomic species

atomic_positions

list with the name and position of each atom, expressed in cartesian coordinates (in a.u.)

atomic_species

dictionary with mass and pseudo for each species

alat

lattice parameter (in a.u.)

lattice

array with the lattice vector. The i-th row represents the i-th lattice vectors in cartesian units

syms

list with the symmetries of the lattice

num_electrons

number of electrons

nkpoints

numer of kpoints

nbands

number of bands

nbands_full

number of occupied bands (for systems with a gap)

nbands_empty

number of empty bands (for systems with a gap)

occupations_kind

type of occupation (fixed or smearing)

kpoints

array with the kpoints

occupations

array with the bands occupation for each kpoint

weights

array with the weight of each kpoint, each element is a one-dimensional array.

energy

total energy of the system (in Hartree)

evals

array of the ks energies for each kpoint (in Hartree)

lsda

True if collinear spin is activated

noncolin

True if noncollinear spin calculation is activated

spinorbit

True if spin-orbit couping is present

spin_degen

1 if lsda or non collinear spin is activated, 2 otherwise

eval_lattice_volume(rescale=False)[source]
Compute the volume of the direct lattice. If rescale is False the results is expressed in a.u., otherwise

the lattice vectors are expressed in units of alat.

Returns:

lattice volume

Return type:

float

eval_reciprocal_lattice_volume(rescale=False)[source]

Compute the volume of the reciprocal lattice. If rescale is True the reciprocal lattice vectors are expressed in units of 2*np.pi/alat.

Returns:

reciprocal lattice volume

Return type:

float

get_energy(convert_eV=True)[source]

Return the total energy the system. If convert_eV is True the energy is provided in eV other the Hartree units are used.

get_evals(set_scissor=None, set_gap=None, set_direct_gap=None, verbose=True)[source]

Return the ks energies for each kpoint (in eV). The top of the valence band is used as the reference energy value. It is possible to shift the energies of the empty bands by setting an arbitrary value for the gap (direct or indirect) or by adding an explicit scissor. Implemented only for semiconductors, the energy shift of empty bands does not update their occupation levels.

Parameters:
  • set_scissor (float) – set the value of the scissor (in eV) that is added to the empty bands. If a scissor is provided the set_gap and set_direct_gap parameters are ignored

  • set_gap (float) – set the value of the gap (in eV) of the system. If set_gap is provided the set_direct_gap parameter is ignored

  • set_direct_gap (float) – set the value of the direct gap (in eV) of the system.

Returns:

an array with the ks energies for each kpoint

Return type:

numpy.array

get_fermi(convert_eV=True)[source]

Return the fermi energy of the system (if present in the xml file). If convert_eV is True the fermi energy is provided in eV, otherwise the Hartree units are used.

get_gap(verbose=True)[source]

Compute the energy gap of the system (in eV). The method check if the gap is direct or indirect. Implemented and tested only for semiconductors.

Returns:

a dictionary with the values of direct and indirect gaps and the positions of the VMB and CBM

Return type:

dict

get_lattice(rescale=False)[source]

Compute the lattice vectors. If rescale = True the vectors are expressed in units of the lattice constant.

Parameters:

rescale (bool) – if True express the lattice vectors in units alat

Returns:

array with the lattice vectors a_i as rows

Return type:

array

get_reciprocal_lattice(rescale=False)[source]

Compute the reciprocal lattice vectors. If rescale = False the vectors are normalized so that np.dot(a_i,b_j) = 2*np.pi*delta_ij, where a_i is a basis vector of the direct lattice. If rescale = True the reciprocal lattice vectors are expressed in units of 2*np.pi/alat.

Parameters:

rescale (bool) – if True express the reciprocal vectors in units of 2*np.pi/alat

Returns:

array with the reciprocal lattice vectors b_i as rows

Return type:

array

get_transitions(initial='full', final='empty', set_scissor=None, set_gap=None, set_direct_gap=None)[source]

Compute the (vertical) transitions energies. For each kpoint compute the transition energies, i.e. the (positive) energy difference (in eV) between the final and the initial states.

Parameters:
  • initial (string or list) – specifies the bands from which electrons can be extracted. It can be set to full or empty to select the occupied or empty bands, respectively. Otherwise a list of bands can be provided

  • final (string or list) – specifies the final bands of the excited electrons. It can be set to full or empty to select the occupied or empty bands, respectively. Otherwise a list of bands can be provided

  • set_scissor (float) – set the value of the scissor (in eV) that is added to the empty bands. If a scissor is provided the set_gap and set_direct_gap parameters are ignored

  • set_gap (float) – set the value of the gap (in eV) of the system. If set_gap is provided the set_direct_gap parameter is ignored

  • set_direct_gap (float) – set the value of the direct gap (in eV) of the system.

Returns:

an array with the transition energies for each kpoint

Return type:

numpy.array

parseXML(file)[source]

Read the data from the xml file in the new format of QuantumESPRESSO. Some variable are extracted from the XML file and stored in the attributes of the object.