Calculations

In qmpy a VASP calculation is represented by a Calculation object. This object contains tools for writing calcualtion inputs and reading calculation outputs. Additionally, it provides tools for automatically correcting errors in calculations.

Calculation

class qmpy.Calculation(*args, **kwargs)[source]

Base class for storing a VASP calculation.

Relationships:
Composition via composition
DOS via dos
Structure via input. Input structure.
Structure via output. Resulting structure.
Element via element_set.
Potential via potential_set.
Hubbard via hubbard_set.
Entry via entry.
Fit via fit. Reference energy sets that have been fit using
this calculation.
FormationEnergy via formationenergy_set. Formation
energies computed from this calculation, for different choices of
fit sets.
MetaData via meta_data
Attributes:
id
label: key for entry.calculations dict.
attempt: # of this attempt at a calculation.
band_gap: Energy gap occupied by the fermi energy.
configuration: Type of calculation (module).
converged: Did the calculation converge electronically and ionically.
energy: Total energy (eV/UC)
energy_pa: Energy per atom (eV/atom)
irreducible_kpoints: # of irreducible k-points.
magmom: Total magnetic moment (mu_b)
magmom_pa: Magnetic moment per atom. (mu_b/atom)
natoms: # of atoms in the input.
nsteps: # of ionic steps.
path: Calculation path.
runtime: Runtime in seconds.
settings: dictionary of VASP settings.
exception DoesNotExist
exception MultipleObjectsReturned
address_errors()[source]

Attempts to fix any encountered errors.

backup(path=None)[source]

Create a copy of the calculation folder in a subdirectory of the current Calculation.

Keyword arguments:

path: If None, the backup folder is generated based on the Calculation.attempt and Calculation.errors.

Return: None

property co_spin_objects

Return list of co_spins (MetaData objects of type co_spin)

compress(files=['OUTCAR', 'CHGCAR', 'CHG', 'PROCAR', 'DOSCAR', 'EIGENVAL', 'LOCPOT', 'ELFCAR', 'vasprun.xml'])[source]

gzip every file in files

Keyword arguments:

files: List of files to zip up.

Return: None

copy()[source]

Create a deep copy of the Calculation.

Return: None

property error_objects

Return list of errors (MetaData objects of type error)

get_outcar()[source]

Sets the calculations outcar attribute to a list of lines from the outcar.

Examples:

>>> calc = Calculation.read('calculation_path')
>>> print calc.outcar
None
>>> calc.get_outcar()
>>> len(calc.outcar)
12345L
static read(path)[source]

Reads the outcar specified by the objects path. Populates input field values, as well as outputs, in addition to finding errors and confirming convergence.

Examples:

>>> path = '/analysis/vasp/files/normal/standard/'
>>> calc = Calculation.read(INSTALL_PATH+path)
read_charges()[source]

Reads and returns VASP-calculated projected charge for each atom. Returns the RAW charge, not NET charge.

Examples:

>>> calc = Calculation.read('path_to_calculation')
>>> calc.read_charges()
read_chgcar(filename='CHGCAR.gz', filetype='CHGCAR')[source]

Reads a VASP CHGCAR or ELFCAR and returns a GridData instance.

read_elements()[source]

Reads the elements of the atoms in the structure. Returned as a list of atoms of shape (natoms,).

Examples:

>>> calc = Calculation.read('path_to_calculation')
>>> calc.read_elements()
['Fe', 'Fe', 'O', 'O', 'O']
read_energies()[source]

Returns a numpy.ndarray of energies over all ionic steps.

Examples:

>>> calc = Calculation.read('calculation_path')
>>> calc.read_energies()
array([-12.415236, -12.416596, -12.416927])
read_incar()[source]

Collect information of INCAR settings

read_lattice_vectors()[source]

Reads and returns a numpy ndarray of lattice vectors for every ionic step of the calculation.

Examples:

>>> path = 'analysis/vasp/files/magnetic/standard'
>>> calc = Calculation.read(INSTALL_PATH+'/'+path)
>>> calc.read_lattice_vectors()
array([[[ 5.707918,  0.      ,  0.      ],
        [ 0.      ,  5.707918,  0.      ],
        [ 0.      ,  0.      ,  7.408951]],
       [[ 5.707918,  0.      ,  0.      ],
        [ 0.      ,  5.707918,  0.      ],
        [ 0.      ,  0.      ,  7.408951]]])
read_n_ionic()[source]

Reads the number of ionic steps, and assigns the value to nsteps.

read_natoms()[source]

Reads the number of atoms, and assigns the value to natoms.

read_stresses()[source]

Using vasprun.xml.gz to collect stresses. In future, this function will be moved to read_output_from_vasprun()

save(*args, **kwargs)[source]

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

set_chgcar(source)[source]

Copy the CHGCAR specified by source to this calculation.

Arguments:

source: can be another Calculation instance or a string containing a path to a CHGCAR. If it is a path, it should be a absolute, i.e. begin with “/”, and can either end with the CHGCAR or simply point to the path that contains it. For example, if you want to take the CHGCAR from a previous calculation you can do any of:

>>> c1 # old calculation
>>> c2 # new calculation
>>> c2.set_chgcar(c1)
>>> c2.set_chgcar(c1.path)
>>> c2.set_chgcar(c1.path+'/CHGCAR')
set_wavecar(source)[source]

Copy the WAVECAR specified by source to this calculation.

Arguments:

source: can be another Calculation instance or a string containing a path to a WAVECAR. If it is a path, it should be a absolute, i.e. begin with “/”, and can either end with the WAVECAR or simply point to the path that contains it. For example, if you want to take the WAVECAR from a previous calculation you can do any of:

>>> c1 # old calculation
>>> c2 # new calculation
>>> c2.set_wavecar(c1)
>>> c2.set_wavecar(c1.path)
>>> c2.set_wavecar(c1.path+'/WAVECAR')
static setup(structure, configuration='static', path=None, entry=None, hubbard='wang', potentials='vasp_rec', settings={}, chgcar=None, wavecar=None, **kwargs)[source]

Method for creating a new VASP calculation.

Arguments:

structure: Structure instance, or string indicating an input structure file.

Keyword Arguments:
configuration:

String indicating the type of calculation to perform. Options can be found with qmpy.VASP_SETTINGS.keys(). Create your own configuration options by adding a new file to configuration/vasp_settings/inputs/ using the files already in that directory as a guide. Default=”static”

settings:

Dictionary of VASP settings to be applied to the calculation. Is applied after the settings which are provided by the configuration choice.

path:

Location at which to perform the calculation. If the calculation takes repeated iterations to finish successfully, all steps will be nested in the path directory.

entry:

If the full qmpy data structure is being used, you can specify an entry to associate with the calculation.

hubbard:

String indicating the hubbard correctionconvention. Options found with qmpy.HUBBARDS.keys(), and can be added to or altered by editing configuration/vasp_settings/hubbards.yml. Default=”wang”.

potentials:

String indicating the vasp potentials to use. Options can be found with qmpy.POTENTIALS.keys(), and can be added to or altered by editing configuration/vasp_settings/potentials/yml. Default=”vasp_rec”.

chgcar/wavecar:

Calculation, or path, indicating where to obtain an initial CHGCAR/WAVECAR file for the calculation.

property warning_objects

Return list of warnings (MetaData objects of type warning)

write()[source]

Write calculation to disk

Density of States

class qmpy.DOS(*args, **kwargs)[source]

Electronic density of states..

Relationships:
Entry via entry
MetaData via meta_data
Calculation via calculation
Attributes:
id
data: Numpy array of DOS occupations.
file: Source file.
gap: Band gap in eV.
exception DoesNotExist
exception MultipleObjectsReturned
property energy

Return the array with the energies.

get_projected_dos(strc, element, orbital=None, debug=False)[source]

Get the density of states for a certain element

Returns an NDOSx1 array with DOS for the chosen element

and orbital type

strc: qmpy.materials.Structure

Structure associated with this DOS

element: str

Symbol of the element

orbital: str or list or None

Which orbitals to retrieve. See site_dos for options. Use None to integrate all orbitals If you specify an orbital without phase factors or spins,

this operation will automatically sum all bands that match that criteria (ex: if you specify ‘d+’, this may sum the dxy+, dyz+, dz2+, … orbitals. Another example, if you put “+” it will get only the positive band

read_doscar(fname='DOSCAR')[source]

Read a VASP DOSCAR file

site_dos(atom, orbital)[source]

Return an NDOSx1 array with dos for the chosen atom and orbital.

atom: int

Atom index

orbital: int or str

Which orbital to plot

If the orbital is given as an integer: If spin-unpolarized calculation, no phase factors: s = 0, p = 1, d = 2 Spin-polarized, no phase factors: s-up = 0, s-down = 1, p-up = 2, p-down = 3, d-up = 4, d-down = 5 If phase factors have been calculated, orbitals are s, py, pz, px, dxy, dyz, dz2, dxz, dx2 double in the above fashion if spin polarized.

Potential

class qmpy.Potential(*args, **kwargs)[source]

Class for storing a VASP potential.

Relationships:
calculation
element
Attributes:
name
date
electrons: Electrons in potential.
enmax
enmin
gw
id
paw
potcar
us
xc
exception DoesNotExist
exception MultipleObjectsReturned
classmethod read_potcar(potfile)[source]

Import pseudopotential(s) from VASP POTCAR.

Make sure to save each of them after importing in order to store in them in the OQMD

Arguments:

potfile - string, Path to POTCAR file

Output:

List of Potential objects

class qmpy.Hubbard(*args, **kwargs)[source]

Base class for a hubbard correction parameterization.

Attributes:
calculation
convention
correction
element
id
l
ligand
ox
u
exception DoesNotExist
exception MultipleObjectsReturned