# Main class¶

class storq.vasp.core.Vasp(label, atoms=None, restart=True, **kwargs)[source]

Class for doing VASP calculations.

This is the VASP calculator class. While it does not strictly adhere to the ASE Calculator interface (and hence does not inherit from it) it should still be compatible with all other ASE modules which use calculators.

Parameters: label (str) – the directory where the calculation files will be and the calculation run. **kwargs – Any VASP INCAR keyword can be used, e.g., encut=450. Python types will be converted to a format appropriate for the INCAR file, e.g. True / False becomes .TRUE. / .FALSE. xc (str) – exchange-correlation functional to use; it is expanded from Vasp._xc_defaults to the relevant VASP tags. kpts (list/dict) – In the simplest case this is just a list with 3 elements containing the k-point mesh divisions. More control can be achieved by passing a dict, which admits the following key-value pairs: size (list) spacing (float) auto (float) list (list) lines (list): gamma (bool): if False use Monkhorst-Pack else Gamma-centered shift (list): shift of the k-point grid intersections: number of intersections used in line vasp_mode cartesian (bool) setups (list) – Special setups for the POTCARS. It is a list of the following items (atom_index, suffix) for example: (2, '_sv') (atom_symbol, suffix) for example ('Zr', '_sv') If (atom_index, suffix) is used then only that atom index will have a POTCAR defined by '{}{}'.format(atoms[atom_index].symbol, suffix) If (atom_symbol, suffix) is used then atoms with that symbol (except any identified by (atom_index, suffix) will use a POTCAR defined by '{}{}'.format(atom_symbol, suffix) This syntax has changed from the old dictionary format. The reason for this is that this sorting must be deterministic. Getting keys in a dictionary is not deterministic. ldau_luj (dict) – This is a dictionary to set the DFT+U tags. For example, to put U=4 on the d-orbitals (L=2) of Cu, and nothing on the oxygen atoms in a calculation use: ldau_luj={'Cu':{'L': 2, 'U':4.0, 'J':0.0}, 'O': {'L':-1, 'U':0.0, 'J':0.0}}, 
CONVERGED = 7
EMPTY = 0
EMPTYCONTCAR = 6
FINISHED = 4
NEW = 1
PARSED = 9
QUEUED = 2
RUNNING = 3
UNCONVERGED = 8
UNFINISHED = 5
UNKNOWN = 100
calculation_required()[source]

Checks whether a calculation is needed.

Uses the internal state of the calculator to judge whether a calculation should be run. The result will be influenced by the calculator settings, e.g., whether strict convergence checks are enforced or not.

Returns: True if calculation needs to be run bool
check_changes(atoms)[source]

Checks if any changes exist that require new calculations.

Parameters: atoms (Atoms) – configuration to compare with, typically read from disk
check_convergence()[source]

Checks whether a calculation has converged.

Performs a strict convergence checks in the sense that electronic as well as ionic convergence is explicitly checked for by comparing their magnitude to EDIFF and EDIFFG.

Returns: True if calculation is converged bool
check_outcar()[source]

Checks if VASP finished properly.

If VASP itself is canceled (batch_walltime or explicitly by user) or encounters certain errors it won’t output the typical Voluntary context switch count on the last line.

Returns: True if VASP finished properly bool
clone(newdir)[source]
config_file = '/root/.config/storq/site.json'
configure(**kwargs)[source]

Changes the configuration of the VASP calculator.

Only allows changes to the calculator and not the site configurations relating to the cluster resource manager. Note that any changes made to the configuration will be written to a database and persist until changed. Note that there exists allowed shorthands for certain options.

Parameters: **kwargs – One or more kwargs corresponding to settings to be changed.
describe_parameters(long=False)[source]

Describes the parameters using docstrings from vasp_validate.

get_atoms()[source]

Gets a copy of the calculators Atoms object.

Some ASE functions may rely on the calculator having this method.

Returns: copy of the configuration associated with the calculator Atoms
get_forces(atoms=None)[source]

Gets the forces acting on the ions.

This method triggers a new calculation if necessary. Some ASE functions rely on the calculator having this method with this particular signature.

Parameters: atoms (Atoms) – Not used but required by ASE. Array with forces acting on the ions. np.ndarray
get_potential_energy(atoms=None, force_consistent=False)[source]

Gets the potential energy of the system.

This method triggers a new calculation if necessary. Some ASE functions rely on the calculator having this method with this particular signature.

Parameters: atoms (Atoms) – Not used but required by ASE. force_consistent (bool) – Toggle parsing of free energy. Energy or the free energy if force_consistent=True. float
get_property(name, atoms=None, allow_calculation=True)[source]

Gets a property from the self.results dict.

Some ASE functions may relay on the calculator having this method.

Parameters: name (str) – name of property to get atoms (Atoms) – ignored but required by the ASE interface allow_calculation (bool) – ignored but required by the ASE interface The object representing the desired result. object
get_state()[source]

Determines calculation state based on directory contents.

This method is only responsible for determining the state and does not act upon it. Other methods that cause a transition to a known state should alter the state themselves.

Returns: An integer corresponding to the internal state of the calculator. int
get_stress(atoms=None)[source]

Gets the stress.

This method triggers a new calculation if necessary. Some ASE functions rely on the calculator having this method with this particular signature.

Parameters: atoms (Atoms) – Not used but required by ASE. The stress. np.ndarray
name = 'VASP'
ready()[source]

Checks if the calculation is ready to be parsed.

The outcome will be heavily dependent on the calculator configuration. For instance if the highest level of convergence check is enabled this will be enforced when checking for readiness.

Returns: True if the calculation is ready bool
run()[source]

Convenience function for running the calculator.

set_label(label)[source]

Sets working directory.

Note that With regards to the ASE FileIOCalculator interface there is no prefix, only a working directory.

Parameters: label (string) – Absolute or relative path to the VASP calculation directory, i.e. where all input/output files related to VASP are put.
siteconf = None
sort_atoms(atoms)[source]

Generates resorted list and list of POTCAR files to use.

This sets the atoms attribute along with atoms_sorted, which is the actual Atoms object that is written to the POSCAR file.

Parameters: atoms (Atoms) – configuration to sort
stop_if(condition)[source]

Stops the program based on the boolean evaluation of condition.

todict(skip_default=True)[source]

.

Parameters: skip_default (bool) – …
traj

Gets a trajectory.

This reads Atoms objects from vasprun.xml. By default all images are returned. If index is an integer, returns that image.

Technically, this is just a list of atoms with a SinglePointCalculator attached to them.

This is usually only relevant if you have done a relaxation. If the calculation is an NEB, the images are returned.

Returns: Atoms objects representing the trajectory list
version = '1.0.0'
view(index=None)[source]

Visualizes the calculation using the ASE gui.

Parameters: index (int) – Index of a particular snapshot to view. ASE gui view of the trajectory.