File

class py4vasp.raw.File(filename=None)

Bases: contextlib.AbstractContextManager

Extract raw data from the HDF5 file.

This class opens a given HDF5 file and its functions then provide access to the raw data via dataclasses. When you request the dataclass for a certain quantity, this class will generate the necessary pointers to the relevant HDF5 datasets, which can then be accessed like numpy arrays.

This class also extends a context manager so it can be used to automatically deal with closing the HDF5 file. You cannot access the data in the dataclasses after you closed the HDF5 file.

Parameters

filename (str or Path) – Name of the file from which the data is read (defaults to default_filename).

Notes

Except for scalars this class does not actually load the data from file. It only creates a pointer to the correct position in the HDF5 file. So you need to extract the data before closing the file. This lazy loading significantly enhances the performance if you are only interested in a subset of the data.

Attributes Summary

band

Read all the band structures generated by Vasp.

born_effective_charge

Read the Born effective charges from a linear response calculation.

cell

Read all the unit cell information of the crystal.

default_filename

Name of the HDF5 file Vasp creates.

density

Read the charge and potentially magnetization density.

dielectric_function

Read the dielectric functions.

dielectric_tensor

Read the dielectric tensor from a linear response calculation.

dos

Read all the electronic density of states (Dos) information.

elastic_modulus

Read the elastic modulus from a linear response calculation.

energy

Read all the energies during the ionic convergence.

force

Read the forces for all ionic steps.

force_constant

Read the force constants from a linear response calculation.

internal_strain

Read the internal strain from a linear response calculation.

kpoint

Read all the k points at which Vasp evaluated the orbitals and eigenvalues.

magnetism

Read all the magnetization data of the crystal.

path

piezoelectric_tensor

Read the piezoelectric tensor from a linear response calculation.

polarization

Read the electronic and ionic dipole moments from a linear response calculation.

projector

Read all the information about projectors if present.

stress

Read the stress for all ionic steps.

structure

Read all the structural information.

system

Read the system tag provided in the INCAR file.

topology

Read all the topology data used in the Vasp calculation.

version

Read the version number of Vasp.

Methods Summary

close()

Close the associated HDF5 file (automatically if used as context manager).

Attributes Documentation

band

Read all the band structures generated by Vasp.

Returns

The key of the dictionary specifies the kind of the band structure. The value contains the raw electronic eigenvalues at the specific k points. These values need to be manually aligned to the Fermi energy if desired. If available the projections on a set of projectors are included.

Return type

DataDict[str, RawBand or None]

born_effective_charge

Read the Born effective charges from a linear response calculation.

Returns

The key identifies the nature of the Born effective charges, the value provides the raw data and structural information.

Return type

DataDict[str, RawBornEffectiveCharges]

cell

Read all the unit cell information of the crystal.

Returns

The key of the dictionary specified the kind of the unit cell. The value contains the lattice vectors of the unit cell and a scaling factor.

Return type

DataDict[str, RawCell]

default_filename = 'vaspout.h5'

Name of the HDF5 file Vasp creates.

density

Read the charge and potentially magnetization density.

Returns

The key informs about the kind of density reported. The value represents the density on the Fourier grid in the unit cell. Structural information is added for convenient plotting.

Return type

DataDict[str, RawDensity]

dielectric_function

Read the dielectric functions.

Returns

The key specifies, which dielectric function is contained. The value represents the energy-resolved dielectric tensor.

Return type

DataDict[str, RawDielectricFunction]

dielectric_tensor

Read the dielectric tensor from a linear response calculation.

Returns

The key specifies which dielectric tensor is contained. The value describes the contributions to the dielectric tensor and the generating methodology.

Return type

DataDict[str, RawDielectricTensor]

dos

Read all the electronic density of states (Dos) information.

Returns

The key of the dictionary specifies the kind of the Dos. The value contains list of energies E and the associated raw electronic Dos D(E). The energies need to be manually shifted to the Fermi energy. If available, the projections on a set of projectors are included.

Return type

DataDict[str, RawDos or None]

elastic_modulus

Read the elastic modulus from a linear response calculation.

Returns

The key identifies the source of the elastic modulus, the value provides the raw data for relaxed ion and clamped ion elastic modulus.

Return type

DataDict[str, RawElasticModulus]

energy

Read all the energies during the ionic convergence.

Returns

The key of the dictionary specifies the kind of energy contained. The value contains a label for all energies and the values for every step in the relaxation or MD simulation.

Return type

DataDict[str, RawEnergy]

force

Read the forces for all ionic steps.

Returns

The key specifies how the forces are obtained. The value represents the information about structure and forces.

Return type

DataDict[str, RawForce]

force_constant

Read the force constants from a linear response calculation.

Returns

The key specifies how the force constants are obtained. The value represents information about the structure and the force constants matrix.

Return type

DataDict[str, RawForceConstant]

internal_strain

Read the internal strain from a linear response calculation.

Returns

The key identifies the source of the internal strain, the value provides the raw data and structural information.

Return type

DataDict[str, RawInternalStrain]

kpoint

Read all the k points at which Vasp evaluated the orbitals and eigenvalues.

Returns

The key of the dictionary specifies the kind of the k point grid. For the value, the coordinates of the k points and the cell information is returned. Added is some information given in the input file about the generation and labels of the k points, which may be useful for band structures.

Return type

DataDict[str, RawKpoint or None]

magnetism

Read all the magnetization data of the crystal.

Returns

The key specifies the kind of magnetization data and the value containes the magnetic moments and charges on every atom in orbital resolved representation. Structural information is added for convenient plotting.

Return type

DataDict[str, RawMagnetism]

path
piezoelectric_tensor

Read the piezoelectric tensor from a linear response calculation.

Returns

The key identifies the source of the piezoelectric tensor, the value provides the raw data for electronic and ionic contribution to the piezoelectric tensor.

Return type

DataDict[str, RawPiezoelectricTensor]

polarization

Read the electronic and ionic dipole moments from a linear response calculation.

Returns

The key identifies the source of the polarization, the value provides the raw data for electronic and ionic contribution to the dipole moment.

Return type

DataDict[str, RawPolarization]

projector

Read all the information about projectors if present.

Returns

If Vasp was set to produce the orbital decomposition of the bands the associated projector information is returned. The key specifies which kind of projectors are returned, the value lists the topology, the orbital types and the number of spins.

Return type

DataDict[str, RawProjector or None]

stress

Read the stress for all ionic steps.

Returns

The key specifies how the stress is obtained. The value represents the information about structure and stress.

Return type

DataDict[str, RawStress]

structure

Read all the structural information.

Returns

The key of the dictionary specifies the kind of the structure. The value contains the unit cell and the position of all the atoms.

Return type

DataDict[str, RawStructure]

system

Read the system tag provided in the INCAR file.

Returns

Contains the name of the system.

Return type

DataDict[str, RawSystem]

topology

Read all the topology data used in the Vasp calculation.

Returns

The key of the dictionary contains information about the kind of the topology. The value contains the information which ion types were used and how many ions of each type there are.

Return type

DataDict[str, RawTopology]

version

Read the version number of Vasp.

Returns

The major, minor, and patch number of Vasp.

Return type

RawVersion

Methods Documentation

close()

Close the associated HDF5 file (automatically if used as context manager).