Main class

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

Class for doing VASP calculations.

This is the core Vasp calculator class. While it does not striclty adhere to the ASE IOCalculator interface (and hence does not inherit from it) it should still be compatible with all other ASE modules which uses 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 an incar appropriate fh FORMAT, e.g. True / False becomes .TRUE. / .FALSE.
  • xc (string) – 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 exampe: (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 calculators internal state 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.

Parameters:
  • atoms (Atoms) – Required by the ASE interface
  • properties (list) – Required by the ASE interface
Returns:

True if calculationn needs to be run

Return type:

bool

check_changes(atoms)[source]

Check if any changes exist that require new calculations. atoms : Atoms

Atoms to compare with, typically atoms 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 chechked for by comparing their magnitude to EDIFF and EDIFFG.

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

Check if VASP finished properly.

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

Returns:True if VASP finished properly.
Return type: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 resourse 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]

Describe the parameters used with docstrings in vasp_validate.

get_atoms()[source]

Get a copy of the calculators Atoms object.

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

Returns:A copy of the Atoms object associated with the calculator.
Return type: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.
Returns:Array with forces acting on the ions.
Return type: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.
Returns:

Energy or the free energy if force_consistent=True.

Return type:

float

get_property(name, atoms=None, allow_calculation=True)[source]

Get a property from the self.results dict.

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

Parameters:
  • name (str) – Name of the property to get.
  • atoms (Atoms) – Ignored, but required by the ASE interface.
  • allow_calculation (bool) – Ignored, but required by the ASE interface.
Returns:

The object representing the desired result.

Return type:

object

get_state()[source]

Determine 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.
Return type: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.
Returns:The stress.
Return type:np.ndarray
name = 'VASP'
ready()[source]

Check 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.
Return type:bool
run()[source]

Convenience function to run calculators.

set_label(label)[source]

Set 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]

Generate resort list, and make list of POTCARs to use.

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

Parameters:atoms (Atoms) – Atoms object 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) –
Returns:
Return type:
traj

Get a trajectory.

This reads Atoms objects from vasprun.xml. By default returns all images. If index is an integer, return 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
Return type:list
version = '1.0.0'
view(index=None)[source]

Visualize the calculation.

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