Support functions¶
Helper functions¶

class
storq.vasp.helpers.
Helpers
[source]¶ 
archive
(tag=None, organize=True, cleanup=False)[source]¶ Archive a run by (separately) gzipping entire vaspdir, vasp xml file and OUTCAR.

backup
(include='minimal', dirname='run.')[source]¶ Flexible function for backing up calcualtion files.
Parameters: include (str, list) – Can be ‘minimal’ or ‘all’ in which case a minimal set of files or all files are backed up, respectively. Can also be a list of filenames to back up.

static
copy_files
(newdir, include='all', exceptions=[])[source]¶ Flexible method for copying VASP calculation files.

static
remove
(target, exceptions=set())[source]¶ Flexible function for removing calculation files.
Note that this is a staticmethod so as to enable cleanup of broken calculation directories where a calculator object cannot be intialized.
Parameters:  rundir (str) – The calculation directory from which to remove files.
 target (str, list) – Decides which files to remove. Can be ‘input’, ‘output’, ‘all’, ‘backup’, the name of a single file or a list of filenames.

POTCAR support functions¶
Getters¶

class
storq.vasp.getters.
Getters
[source]¶ 
get_ados
(atom_index, orbital, spin=1, efermi=None)[source]¶ Return Atom projected DOS for atom index, orbital and spin.
Parameters:  atom_index (int) – pass
 orbital (string) – can be any of ‘s’, ‘p’, ‘d’
 spin (int) – pass
 efermi (float) – the fermi energy
Returns:  energies (np.ndarray) – pass
 ados (np.ndarray) – pass

get_charge_density
(spin=0, filename=None)[source]¶ Returns x, y, and z coordinate and charge density arrays.
Supported file formats: CHG, CHGCAR
Parameters: spin (int) – pass Returns: x, y, z – charge density arrays Return type: np.ndarrays

get_charges
(atoms=None)[source]¶ Returns a list of cached charges from a previous call to bader(). Useful for storing the charges to a database.

get_composition
(basis=None)[source]¶ Acquire the chemical composition of an atoms object
Returns: atoms and their compositions dictionary sorted by atomic number Return type: dict Parameters: basis (string) – allows the user to define the basis element for determining the composition. If a basis element is specified, the composition of that element is returned.

get_core_levels
()[source]¶ Parse an OUTCAR file and extract either the average (electrostatic) potential at core or the core state eigenenergies.
Parameters: f (fileobj) – input file Returns: the list is either comprised of floats representing the average electrostatic vasp_potentials at the ionic cores or dictionaries containing the KohnSham eigen energies of the core states; if neither information is found the method returns a None value Return type: list

get_db
(*keys)[source]¶ Retrieve values for each key in keys.
First look for key/value, then in data.

get_default_number_of_electrons
(filename=None)[source]¶ Get the default number of valence electrons.
Parameters: filename (str) – name of the POTCAR file in which to look Returns: number of electorns for each species in filename Return type: list

get_density_of_states
(index=1)[source]¶ Parse vasprun.xml file and extract the density of states.
Parameters:  f (fileobj) – input file
 index (int) – index of frame(s) to return
Returns: dictionary, each entry of corresponds to another spin channel and comprises a tuple of two lists (energies and density of states)
Return type: generator

get_dipole_moment
(atoms=None)[source]¶ Return dipole_moment.
dipole_moment = ((dipole_vector**2).sum())**0.5/Debye

get_dipole_vector
()[source]¶ Tries to return the dipole vector of the unit cell in atomic units.
Returns None when CHG file is empty/notpresent.

get_elastic_moduli
()[source]¶ Returns the total elastic moduli in GPa.
(i.e. the rigid ion and contributions from relaxation) from the OUTCAR file.
you must run with IBRION=6 and ISIF>= 3 for this output to exist.
There are also contributions from ionic relaxation ELASTIC MODULI CONTR FROM IONIC RELAXATION (kBar) and the rigid moduli SYMMETRIZED ELASTIC MODULI (kBar)
For now these are not returned.

get_electron_density_center
(spin=0, scaled=True)[source]¶ Returns center of electron density. If scaled, use scaled coordinates, otherwise use cartesian coordinates.

get_ibz_k_points
(cartesian=True)[source]¶ Return the IBZ kpoint list.
Uses vasprun.xml and returns them in cartesian coordinates. set cartesian=False to get them in reciprocal coordinates.

get_linear_response_properties
()[source]¶ Parse an OUTCAR file and extract properties that are obtained from linear response calculations. This includes elastic and dielectric tensors, Born effective charges as well as normal vasp_modes.
Parameters: f (fileobj) – input file Returns: The properties are returned in the form of a dictionary, which contains entries for all properties that were succesfully parsed from the input file. Return type: dictionary

get_local_potential
()[source]¶ Returns x, y, z, and local potential arrays
We multiply the data by the volume because we are reusing the charge density code which divides by volume.

get_memory
()[source]¶ Retrieves the recommended memory from the OUTCAR in GB.
If no OUTCAR exists, or the memory estimate can not be found, return None

get_number_of_bands
()[source]¶ Return the number of bands.
NBANDS is read from an OUTCAR if it exists, otherwise the default value used by vasp is computed and returned.

get_number_of_ionic_steps
()[source]¶ Get the number of ionic steps from the OUTCAR file.
Returns: The number of ionic steps. Return type: int

get_occupation_numbers
(kpt=0, spin=0)[source]¶ Read occupation_numbers for KPT and spin.
Read from vasprun.xml. This may be fractional occupation. For nonspinpolarized calculations you may need to multiply by 2.
Returns an np.array.

get_orbital_occupations
()[source]¶ Read occuations from OUTCAR.
Returns a numpy array of [[s, p, d tot]] for each atom.
You probably need to have used LORBIT=11 for this function to work.

Setters¶

class
storq.vasp.setters.
Setters
[source]¶ 
set
(**kwargs)[source]¶ Set parameters with keyword=value pairs.
A few special kwargs are handled separately to expand them prior to setting the parameters. This is done to enable one set to track changes.
Parameters: **kwargs – Can be any calculator keyword.

set_atoms
(atoms)[source]¶ Set the atoms attribute.
This is called by the set_calculator method of ASE Atoms objects.

set_encut
(factor=1.3)[source]¶ Heuristic for setting the PW cutoff.
Uses the formula factor*max(ENMAX) where the maximum is taken over all POTCARs involved.
Parameters: factor (float) – Multiplicative scaling factor for the eneryg cutoff.

set_ispin_dict
(val)[source]¶ Returns dictionary of changes for ispin change.
Parameters: val – TODO Returns: TODO Return type: dict

set_number_of_bands
(factor=1.0)[source]¶ Convenience function to compute and set the number of bands.
Uses the same rule as VASP does internally, which looks roughly like
nbands = int(nelectrons/2 + factor*nions/2).
The difference is that this method allows the specification of a scaling factor for the term proportional to the number of ions. This can be useful for e.g., transition metals where more bands need to be added sometimes (factor=2 can be required).
Parameters: factor (float) – Multiplicative scaling factor for the number of bands. Returns: The new number of bands. Return type: int

Validation functions¶

storq.vasp.validate.
addgrid
(calc, val)[source]¶ ADDGRID gives an extra grid for the evaluation of augmentation charges.

storq.vasp.validate.
aggac
(calc, val)[source]¶ Fraction of gradient correction to correlation in a hybrid calculation

storq.vasp.validate.
algo
(calc, val)[source]¶ specify the electronic minimisation algorithm (as of VASP.4.5) (string)

storq.vasp.validate.
eb_k
(calc, val)[source]¶ The relative permittivity of the solvent used in the VASPsol code. (float)
https://github.com/henniggroup/VASPsol/blob/master/docs/USAGE.md

storq.vasp.validate.
ediff
(calc, val)[source]¶ EDIFF specifies the global break condition for the electronic loop. (float)

storq.vasp.validate.
ediffg
(calc, val)[source]¶ EDIFFG defines the break condition for the ionic relaxation loop. (float)
If EDIFFG < 0, it defines a force criteria.

storq.vasp.validate.
ialgo
(calc, val)[source]¶ IALGO selects the algorithm used to optimize the orbitals.

storq.vasp.validate.
ibrion
(calc, val)[source]¶ IBRION determines the algorithm to update geometry during relaxtion. (int)

storq.vasp.validate.
icharg
(calc, val)[source]¶ Determines how VASP constructs the initial charge density.
Value Meaning 0 calculate from initial wave functions 1 read from the CHGCAR 2 (default) Superposition of atomic charge densities 11 for bandstructure plots Parameters: val (int) – new value

storq.vasp.validate.
images
(calc, val)[source]¶ The number of images for a nudge elastic band (NEB) calculation not counting the end points.
Parameters: val (int) – new value

storq.vasp.validate.
isif
(calc, val)[source]¶ ISIF determines what is changed during relaxations.
ISIF calculate force calculate stress tensor relax ions change cell shape change cell volume 0 yes no yes no no 1 yes trace only yes no no 2 yes yes yes no no 3 yes yes yes yes yes 4 yes yes yes yes no 5 yes yes no yes no 6 yes yes no yes yes 7 yes yes no no yes Parameters: val (int) – new value

storq.vasp.validate.
ismear
(calc, val)[source]¶ ISMEAR determines how the partial occupancies are set.
Parameters: val (int) – new value

storq.vasp.validate.
ispin
(calc, val)[source]¶ 
Value Meaning 1 default, no spin polarization 2 spinpolarization. Parameters: val (int) – new value

storq.vasp.validate.
ivdw
(calc, val)[source]¶ IVDW determines the approximate vdW correction methods used.
Value Meaning 0 no correction 110 DFTD2 method of Grimme (available as of VASP.5.2.11) 11 zero damping DFTD3 method of Grimme (available as of VASP.5.3.4) 12 DFTD3 method with BeckeJonson damping (available as of VASP.5.3.4) 2 TkatchenkoScheffler method (available as of VASP.5.3.3) 21 TkatchenkoScheffler method with iterative Hirshfeld partitioning (available as of VASP.5.3.5) 202 Manybody dispersion energy method (MBD@rSC) (available as of VASP.5.4.1) 4 dDsC dispersion correction method (available as of VASP.5.4.1) Parameters: val (int) – new value

storq.vasp.validate.
keyword_alist
()[source]¶ Returns an alist of (keyword . “first doc string”).
Returns the alist for use in Emacs.

storq.vasp.validate.
keywords
()[source]¶ Return list of keywords we vasp_validate.
Returns a lisp list for Emacs.

storq.vasp.validate.
kspacing
(calc, val)[source]¶ KSPACING determines the number of kpoints if the KPOINTS file is not present.
Parameters: val (float) – new value

storq.vasp.validate.
lcharg
(calc, val)[source]¶ LCHARG determines whether CHGCAR and CHG are written.
Parameters: val (bool) – new value

storq.vasp.validate.
ldau
(calc, val)[source]¶ LDAU switches on the L(S)DA+U.
Parameters: val (bool) – new value

storq.vasp.validate.
ldau_luj
(calc, val)[source]¶ Dictionary of DFT+U parameters:
ldau_luj={'Mn': {'L': 2, 'U': 0.0, 'J': 0.0}, 'O': {'L': 1, 'U': 0.0, 'J': 0.0}},

storq.vasp.validate.
ldauprint
(calc, val)[source]¶ LDAUPRINT controls the verbosity of the L(S)DA+U routines.
Value Meaning 0 silent. 1 Write occupancy matrix to the OUTCAR file. 2 same as LDAUPRINT=1, plus potential matrix dumped to vasp_stdout Parameters: val (int) – new value

storq.vasp.validate.
ldautype
(calc, val)[source]¶ LDAUTYPE specifies which type of L(S)DA+U approach will be used.
LDAUTYPE=1
: Rotationally invariant LSDA+U [1]LDAUTYPE=2
: Simplified (rotationally invariant) LSDA+U [2] A. I. Liechtenstein, V. I. Anisimov and J. Zaane, Phys. Rev. B 52, R5467 (1995).
 S. L. Dudarev, G. A. Botton, S. Y. Savrasov, C. J. Humphreys and A. P. Sutton, Phys. Rev. B 57, 1505 (1998).
Parameters: val (int) – new value

storq.vasp.validate.
lmaxmix
(calc, val)[source]¶ LMAXMIX the max lquantum number the charge densities used.
Mostly used for DFT+U. 4 for delectrons (or 6 for felements)
Parameters: val (int) – new value

storq.vasp.validate.
lorbit
(calc, val)[source]¶ Determines whether the PROCAR or PROOUT files are written.
Parameters: val (int) – new value

storq.vasp.validate.
lreal
(calc, val)[source]¶ LREAL determines whether the projection operators are evaluated in realspace or in reciprocal space.
Parameters: val (bool/string) – new value

storq.vasp.validate.
lsol
(calc, val)[source]¶ LSOL determines whether the VASPsol is activated.
Parameters: val (bool) – new value

storq.vasp.validate.
lwave
(calc, val)[source]¶ LWAVE determines whether the WAVECAR is written.
Parameters: val (bool) – new value

storq.vasp.validate.
magmom
(calc, val)[source]¶ MAGMOM specifies the initial magnetic moment for each atom.
Parameters: val (list) – new value

storq.vasp.validate.
maxmix
(calc, val)[source]¶ MAXMIX specifies the maximum number steps stored in Broyden mixer (IMIX=4).
Parameters: val (int) – new value

storq.vasp.validate.
nbands
(calc, val)[source]¶ NBANDS determines the actual number of bands in the calculation.
Parameters: val (int) – new value

storq.vasp.validate.
ncore
(calc, val)[source]¶ NCORE determines the number of compute cores that work on an individual orbital.
Parameters: val (int) – new value

storq.vasp.validate.
nelm
(calc, val)[source]¶ NELM sets the maximum number of electronic SC (selfconsistency) steps which may be performed.
Parameters: val (int) – new value

storq.vasp.validate.
nsw
(calc, val)[source]¶ NSW sets the maximum number of ionic steps.
Parameters: val (int) – new value

storq.vasp.validate.
nupdown
(calc, val)[source]¶ NUPDOWN sets the difference between the number of spin up and down electrons.
This fixes the bulk magnetic moment. The VASP manual specifies this should be an integer, but it appears floats work too.
Parameters: val (int/float) – new value

storq.vasp.validate.
potim
(calc, val)[source]¶ POTIM sets the time step (MD) or step width scaling (ionic relaxations).
Parameters: val (float) – new value

storq.vasp.validate.
pp
(calc, val)[source]¶ Determines where POTCARS are retrieved from.
Parameters: val (string) – new value

storq.vasp.validate.
prec
(calc, val)[source]¶ Specifies the precision vasp_mode.
Parameters: val (string) – new value

storq.vasp.validate.
rwigs
(calc, val)[source]¶ RWIGS specifies the WignerSeitz radius for each atom type.
 in vasp.py you enter a dictionary of::
 {sym: radius}
Parameters: val (list) – new value

storq.vasp.validate.
setups
(calc, val)[source]¶ Sets up special setups for the POTCARS (list of (symbol/int, suffix)).
The first element of each pair of the list is either an integer index of the atom for the special setup, or a chemical symbol for all atoms of that type. The second element of the pair is a suffix to be appended to the symbol. For example, to use the O_s potcar set setups to: [[‘O’, ‘_s’]].
This is not a vasp keyword.

storq.vasp.validate.
sigma
(calc, val)[source]¶ SIGMA determines the width of the smearing in eV. (float)