custodian.vasp package

Subpackages

Submodules

custodian.vasp.handlers module

class AliasingErrorHandler(output_filename='vasp.out')[source]

Bases: custodian.custodian.ErrorHandler

Master VaspErrorHandler class that handles a number of common errors that occur during VASP runs.

Initializes the handler with the output file to check.

Parameters:output_filename (str) – This is the file where the stdout for vasp is being redirected. The error messages that are checked are present in the stdout. Defaults to “vasp.out”, which is the default redirect used by custodian.vasp.jobs.VaspJob.
check()[source]
correct()[source]
error_msgs = {'aliasing': ['WARNING: small aliasing (wrap around) errors must be expected'], 'aliasing_incar': ['Your FFT grids (NGX,NGY,NGZ) are not sufficient for an accurate']}
is_monitor = True
class CheckpointHandler(interval=3600)[source]

Bases: custodian.custodian.ErrorHandler

This is not an error handler per se, but rather a checkpointer. What this does is that every X seconds, a STOPCAR and CHKPT will be written. This forces VASP to stop at the end of the next ionic step. The files are then copied into a subdir, and then the job is restarted. To use this proper, max_errors in Custodian must be set to a very high value, and you probably wouldn’t want to use any standard VASP error handlers. The checkpoint will be stored in subdirs chk_#. This should be used in combiantion with the StoppedRunHandler.

Initializes the handler with an interval.

Parameters:
  • interval (int) – Interval at which to checkpoint in seconds.
  • to 3600 (Defaults) –
check()[source]
correct()[source]
is_monitor = True
is_terminating = False
class DriftErrorHandler(max_drift=None, to_average=3, enaug_multiply=2)[source]

Bases: custodian.custodian.ErrorHandler

Corrects for total drift exceeding the force convergence criteria.

Initializes the handler with max drift :param max_drift: This defines the max drift. Leaving this at the default of None gets the max_drift from EDFIFFG :type max_drift: float

check()[source]
correct()[source]
class FrozenJobErrorHandler(output_filename='vasp.out', timeout=21600)[source]

Bases: custodian.custodian.ErrorHandler

Detects an error when the output file has not been updated in timeout seconds. Changes ALGO to Normal from Fast

Initializes the handler with the output file to check.

Parameters:
  • output_filename (str) – This is the file where the stdout for vasp is being redirected. The error messages that are checked are present in the stdout. Defaults to “vasp.out”, which is the default redirect used by custodian.vasp.jobs.VaspJob.
  • timeout (int) – The time in seconds between checks where if there is no activity on the output file, the run is considered frozen. Defaults to 3600 seconds, i.e., 1 hour.
check()[source]
correct()[source]
is_monitor = True
class LrfCommutatorHandler(output_filename='std_err.txt')[source]

Bases: custodian.custodian.ErrorHandler

Corrects LRF_COMMUTATOR errors by setting LPEAD=True if not already set. Note that switching LPEAD=T can slightly change results versus the default due to numerical evaluation of derivatives.

Initializes the handler with the output file to check.

Parameters:output_filename (str) – This is the file where the stderr for vasp is being redirected. The error messages that are checked are present in the stderr. Defaults to “std_err.txt”, which is the default redirect used by custodian.vasp.jobs.VaspJob.
check()[source]
correct()[source]
error_msgs = {'lrf_comm': ['LRF_COMMUTATOR internal error']}
is_monitor = True
class MaxForceErrorHandler(output_filename='vasprun.xml', max_force_threshold=0.25)[source]

Bases: custodian.custodian.ErrorHandler

Checks that the desired force convergence has been achieved. Otherwise restarts the run with smaller EDIFF. (This is necessary since energy and force convergence criteria cannot be set simultaneously)

Parameters:
  • input_filename (str) – name of the vasp INCAR file
  • output_filename (str) – name to look for the vasprun
  • max_force_threshold (float) – Threshold for max force for restarting the run. (typically should be set to the value that the creator looks for)
check()[source]
correct()[source]
is_monitor = False
class MeshSymmetryErrorHandler(output_filename='vasp.out', output_vasprun='vasprun.xml')[source]

Bases: custodian.custodian.ErrorHandler

Corrects the mesh symmetry error in VASP. This error is sometimes non-fatal. So this error handler only checks at the end of the run, and if the run has converged, no error is recorded.

Initializes the handler with the output files to check.

Parameters:
  • output_filename (str) – This is the file where the stdout for vasp is being redirected. The error messages that are checked are present in the stdout. Defaults to “vasp.out”, which is the default redirect used by custodian.vasp.jobs.VaspJob.
  • output_vasprun (str) – Filename for the vasprun.xml file. Change this only if it is different from the default (unlikely).
check()[source]
correct()[source]
is_monitor = False
class NonConvergingErrorHandler(output_filename='OSZICAR', nionic_steps=10, change_algo=False)[source]

Bases: custodian.custodian.ErrorHandler

Check if a run is hitting the maximum number of electronic steps at the last nionic_steps ionic steps (default=10). If so, change ALGO from Fast to Normal or kill the job.

Initializes the handler with the output file to check.

Parameters:
  • output_filename (str) – This is the OSZICAR file. Change this only if it is different from the default (unlikely).
  • nionic_steps (int) – The threshold number of ionic steps that needs to hit the maximum number of electronic steps for the run to be considered non-converging.
  • change_algo (bool) – Whether to attempt to correct the job by changing the ALGO from Fast to Normal.
check()[source]
correct()[source]
is_monitor = True
class PositiveEnergyErrorHandler(output_filename='OSZICAR')[source]

Bases: custodian.custodian.ErrorHandler

Check if a run has positive absolute energy. If so, change ALGO from Fast to Normal or kill the job.

Initializes the handler with the output file to check.

Parameters:output_filename (str) – This is the OSZICAR file. Change this only if it is different from the default (unlikely).
check()[source]
correct()[source]
is_monitor = True
class PotimErrorHandler(input_filename='POSCAR', output_filename='OSZICAR', dE_threshold=1)[source]

Bases: custodian.custodian.ErrorHandler

Check if a run has excessively large positive energy changes. This is typically caused by too large a POTIM. Runs typically end up crashing with some other error (e.g. BRMIX) as the geometry gets progressively worse.

Initializes the handler with the input and output files to check.

Parameters:
  • input_filename (str) – This is the POSCAR file that the run started from. Defaults to “POSCAR”. Change this only if it is different from the default (unlikely).
  • output_filename (str) – This is the OSZICAR file. Change this only if it is different from the default (unlikely).
  • dE_threshold (float) – The threshold energy change. Defaults to 1eV.
check()[source]
correct()[source]
is_monitor = True
class StdErrHandler(output_filename='std_err.txt')[source]

Bases: custodian.custodian.ErrorHandler

Master StdErr class that handles a number of common errors that occur during VASP runs with error messages only in the standard error.

Initializes the handler with the output file to check.

Parameters:output_filename (str) – This is the file where the stderr for vasp is being redirected. The error messages that are checked are present in the stderr. Defaults to “std_err.txt”, which is the default redirect used by custodian.vasp.jobs.VaspJob.
check()[source]
correct()[source]
error_msgs = {'kpoints_trans': ['internal error in GENERATE_KPOINTS_TRANS: number of G-vector changed in star'], 'out_of_memory': ['Allocation would exceed memory limit']}
is_monitor = True
class StoppedRunHandler[source]

Bases: custodian.custodian.ErrorHandler

This is not an error handler per se, but rather a checkpointer. What this does is that every X seconds, a STOPCAR will be written. This forces VASP to stop at the end of the next ionic step. The files are then copied into a subdir, and then the job is restarted. To use this proper, max_errors in Custodian must be set to a very high value, and you probably wouldn’t want to use any standard VASP error handlers. The checkpoint will be stored in subdirs chk_#. This should be used in combination with the StoppedRunHandler.

check()[source]
correct()[source]
is_monitor = False
is_terminating = False
class UnconvergedErrorHandler(output_filename='vasprun.xml')[source]

Bases: custodian.custodian.ErrorHandler

Check if a run is converged. Switches to ALGO = Normal.

Initializes the handler with the output file to check.

Parameters:output_vasprun (str) – Filename for the vasprun.xml file. Change this only if it is different from the default (unlikely).
check()[source]
correct()[source]
is_monitor = False
class VaspErrorHandler(output_filename='vasp.out', natoms_large_cell=100)[source]

Bases: custodian.custodian.ErrorHandler

Master VaspErrorHandler class that handles a number of common errors that occur during VASP runs.

Initializes the handler with the output file to check.

Parameters:output_filename (str) – This is the file where the stdout for vasp is being redirected. The error messages that are checked are present in the stdout. Defaults to “vasp.out”, which is the default redirect used by custodian.vasp.jobs.VaspJob.
check()[source]
correct()[source]
error_msgs = {'tet': ['Tetrahedron method fails for NKPT<4', 'Fatal error detecting k-mesh', 'Fatal error: unable to match k-point', 'Routine TETIRR needs special values'], 'inv_rot_mat': ['inverse of rotation matrix was not found (increase SYMPREC)'], 'brmix': ['BRMIX: very serious problems'], 'subspacematrix': ['WARNING: Sub-Space-Matrix is not hermitian in DAV'], 'tetirr': ['Routine TETIRR needs special values'], 'incorrect_shift': ['Could not get correct shifts'], 'real_optlay': ['REAL_OPTLAY: internal error', 'REAL_OPT: internal ERROR'], 'rspher': ['ERROR RSPHER'], 'dentet': ['DENTET'], 'too_few_bands': ['TOO FEW BANDS'], 'triple_product': ['ERROR: the triple product of the basis vectors'], 'rot_matrix': ['Found some non-integer element in rotation matrix'], 'brions': ['BRIONS problems: POTIM should be increased'], 'pricel': ['internal error in subroutine PRICEL'], 'zpotrf': ['LAPACK: Routine ZPOTRF failed'], 'amin': ['One of the lattice vectors is very long (>50 A), but AMIN'], 'zbrent': ['ZBRENT: fatal internal in', 'ZBRENT: fatal error in bracketing'], 'pssyevx': ['ERROR in subspace rotation PSSYEVX'], 'eddrmm': ['WARNING in EDDRMM: call to ZHEGV failed'], 'edddav': ['Error EDDDAV: Call to ZHEGV failed'], 'grad_not_orth': ['EDWAV: internal error, the gradient is not orthogonal'], 'nicht_konv': ['ERROR: SBESSELITER : nicht konvergent'], 'zheev': ['ERROR EDDIAG: Call to routine ZHEEV failed!'], 'elf_kpar': ['ELF: KPAR>1 not implemented'], 'elf_ncl': ['WARNING: ELF not implemented for non collinear case'], 'rhosyg': ['RHOSYG internal error'], 'posmap': ['POSMAP internal error: symmetry equivalent atom not found']}
is_monitor = True
class WalltimeHandler(wall_time=None, buffer_time=300, electronic_step_stop=False)[source]

Bases: custodian.custodian.ErrorHandler

Check if a run is nearing the walltime. If so, write a STOPCAR with LSTOP or LABORT = .True.. You can specify the walltime either in the init ( which is unfortunately necessary for SGE and SLURM systems. If you happen to be running on a PBS system and the PBS_WALLTIME variable is in the run environment, the wall time will be automatically determined if not set.

Initializes the handler with a buffer time.

Parameters:
  • wall_time (int) – Total walltime in seconds. If this is None and the job is running on a PBS system, the handler will attempt to determine the walltime from the PBS_WALLTIME environment variable. If the wall time cannot be determined or is not set, this handler will have no effect.
  • buffer_time (int) – The min amount of buffer time in secs at the end that the STOPCAR will be written. The STOPCAR is written when the time remaining is < the higher of 3 x the average time for each ionic step and the buffer time. Defaults to 300 secs, which is the default polling time of Custodian. This is typically sufficient for the current ionic step to complete. But if other operations are being performed after the run has stopped, the buffer time may need to be increased accordingly.
  • electronic_step_stop (bool) – Whether to check for electronic steps instead of ionic steps (e.g. for static runs on large systems or static HSE runs, …). Be careful that results such as density or wavefunctions might not be converged at the electronic level. Should be used with LWAVE = .True. to be useful. If this is True, the STOPCAR is written with LABORT = .TRUE. instead of LSTOP = .TRUE.
check()[source]
correct()[source]
is_monitor = True
is_terminating = False
raises_runtime_error = False

custodian.vasp.interpreter module

class VaspModder(actions=None, strict=True, vi=None)[source]

Bases: custodian.ansible.interpreter.Modder

Initializes a Modder for VaspInput sets

Parameters:
  • actions ([Action]) – A sequence of supported actions. See custodian.ansible.actions. Default is None, which means DictActions and FileActions are supported.
  • strict (bool) – Indicating whether to use strict mode. In non-strict mode, unsupported actions are simply ignored without any errors raised. In strict mode, if an unsupported action is supplied, a ValueError is raised. Defaults to True.
  • vi (VaspInput) – A VaspInput object from the current directory. Initialized automatically if not passed (but passing it will avoid having to reparse the directory).
apply_actions(actions)[source]

Applies a list of actions to the Vasp Input Set and rewrites modified files. :param actions [dict]: A list of actions of the form {‘file’: filename,

‘action’: moddermodification} or {‘dict’: vaspinput_key, ‘action’: moddermodification}

custodian.vasp.jobs module

class GenerateVaspInputJob(input_set, contcar_only=True, **kwargs)[source]

Bases: custodian.custodian.Job

Generates a VASP input based on an existing directory. This is typically used to modify the VASP input files before the next VaspJob.

Parameters:
  • input_set (str) – Full path to the input set. E.g., “pymatgen.io.vasp.sets.MPNonSCFSet”.
  • contcar_only (bool) – If True (default), only CONTCAR structures are used as input to the input set.
postprocess()[source]
run()[source]
setup()[source]
class VaspJob(vasp_cmd, output_file='vasp.out', stderr_file='std_err.txt', suffix='', final=True, backup=True, auto_npar=True, auto_gamma=True, settings_override=None, gamma_vasp_cmd=None, copy_magmom=False, auto_continue=False)[source]

Bases: custodian.custodian.Job

A basic vasp job. Just runs whatever is in the directory. But conceivably can be a complex processing of inputs etc. with initialization.

This constructor is necessarily complex due to the need for flexibility. For standard kinds of runs, it’s often better to use one of the static constructors. The defaults are usually fine too.

Parameters:
  • vasp_cmd (str) – Command to run vasp as a list of args. For example, if you are using mpirun, it can be something like [“mpirun”, “pvasp.5.2.11”]
  • output_file (str) – Name of file to direct standard out to. Defaults to “vasp.out”.
  • stderr_file (str) – Name of file to direct standard error to. Defaults to “std_err.txt”.
  • suffix (str) – A suffix to be appended to the final output. E.g., to rename all VASP output from say vasp.out to vasp.out.relax1, provide “.relax1” as the suffix.
  • final (bool) – Indicating whether this is the final vasp job in a series. Defaults to True.
  • backup (bool) – Whether to backup the initial input files. If True, the INCAR, KPOINTS, POSCAR and POTCAR will be copied with a “.orig” appended. Defaults to True.
  • auto_npar (bool) – Whether to automatically tune NPAR to be sqrt( number of cores) as recommended by VASP for DFT calculations. Generally, this results in significant speedups. Defaults to True. Set to False for HF, GW and RPA calculations.
  • auto_gamma (bool) – Whether to automatically check if run is a Gamma 1x1x1 run, and whether a Gamma optimized version of VASP exists with “.gamma” appended to the name of the VASP executable (typical setup in many systems). If so, run the gamma optimized version of VASP instead of regular VASP. You can also specify the gamma vasp command using the gamma_vasp_cmd argument if the command is named differently.
  • settings_override ([dict]) –

    An ansible style list of dict to override changes. For example, to set ISTART=1 for subsequent runs and to copy the CONTCAR to the POSCAR, you will provide:

    [{"dict": "INCAR", "action": {"_set": {"ISTART": 1}}},
     {"file": "CONTCAR",
      "action": {"_file_copy": {"dest": "POSCAR"}}}]
    
  • gamma_vasp_cmd (str) – Command for gamma vasp version when auto_gamma is True. Should follow the list style of subprocess. Defaults to None, which means “.gamma” is added to the last argument of the standard vasp_cmd.
  • copy_magmom (bool) – Whether to copy the final magmom from the OUTCAR to the next INCAR. Useful for multi-relaxation runs where the CHGCAR and WAVECAR are sometimes deleted (due to changes in fft grid, etc.). Only applies to non-final runs.
  • auto_continue (bool) – Whether to automatically continue a run if a STOPCAR is present. This is very usefull if using the wall-time handler which will write a read-only STOPCAR to prevent VASP from deleting it once it finishes
classmethod constrained_opt_run(vasp_cmd, lattice_direction, initial_strain, atom_relax=True, max_steps=20, algo='bfgs', **vasp_job_kwargs)[source]

Returns a generator of jobs for a constrained optimization run. Typical use case is when you want to approximate a biaxial strain situation, e.g., you apply a defined strain to a and b directions of the lattice, but allows the c-direction to relax.

Some guidelines on the use of this method: i. It is recommended you do not use the Auto kpoint generation. The

grid generated via Auto may fluctuate with changes in lattice param, resulting in numerical noise.
  1. Make sure your EDIFF/EDIFFG is properly set in your INCAR. The optimization relies on these values to determine convergence.
Parameters:
  • vasp_cmd (str) – Command to run vasp as a list of args. For example, if you are using mpirun, it can be something like [“mpirun”, “pvasp.5.2.11”]
  • lattice_direction (str) – Which direction to relax. Valid values are “a”, “b” or “c”.
  • initial_strain (float) – An initial strain to be applied to the lattice_direction. This can usually be estimated as the negative of the strain applied in the other two directions. E.g., if you apply a tensile strain of 0.05 to the a and b directions, you can use -0.05 as a reasonable first guess for initial strain.
  • atom_relax (bool) – Whether to relax atomic positions.
  • max_steps (int) – The maximum number of runs. Defaults to 20 ( highly unlikely that this limit is ever reached).
  • algo (str) – Algorithm to use to find minimum. Default is “bfgs”, which is fast, but can be sensitive to numerical noise in energy calculations. The alternative is “bisection”, which is more robust but can be a bit slow. The code does fall back on the bisection when bfgs gives a non-sensical result, e.g., negative lattice params.
  • **vasp_job_kwargs – Passthrough kwargs to VaspJob. See custodian.vasp.jobs.VaspJob.
Returns:

Generator of jobs. At the end of the run, an “EOS.txt” is written which provides a quick look at the E vs lattice parameter.

classmethod double_relaxation_run(vasp_cmd, auto_npar=True, ediffg=-0.05, half_kpts_first_relax=False, auto_continue=False)[source]

Returns a list of two jobs corresponding to an AFLOW style double relaxation run.

Parameters:
  • vasp_cmd (str) – Command to run vasp as a list of args. For example, if you are using mpirun, it can be something like [“mpirun”, “pvasp.5.2.11”]
  • auto_npar (bool) – Whether to automatically tune NPAR to be sqrt( number of cores) as recommended by VASP for DFT calculations. Generally, this results in significant speedups. Defaults to True. Set to False for HF, GW and RPA calculations.
  • ediffg (float) – Force convergence criteria for subsequent runs ( ignored for the initial run.)
  • half_kpts_first_relax (bool) – Whether to halve the kpoint grid for the first relaxation. Speeds up difficult convergence considerably. Defaults to False.
Returns:

List of two jobs corresponding to an AFLOW style run.

classmethod full_opt_run(vasp_cmd, vol_change_tol=0.02, max_steps=10, ediffg=-0.05, half_kpts_first_relax=False, **vasp_job_kwargs)[source]

Returns a generator of jobs for a full optimization run. Basically, this runs an infinite series of geometry optimization jobs until the % vol change in a particular optimization is less than vol_change_tol.

Parameters:
  • vasp_cmd (str) – Command to run vasp as a list of args. For example, if you are using mpirun, it can be something like [“mpirun”, “pvasp.5.2.11”]
  • vol_change_tol (float) – The tolerance at which to stop a run. Defaults to 0.05, i.e., 5%.
  • max_steps (int) – The maximum number of runs. Defaults to 10 ( highly unlikely that this limit is ever reached).
  • ediffg (float) – Force convergence criteria for subsequent runs ( ignored for the initial run.)
  • half_kpts_first_relax (bool) – Whether to halve the kpoint grid for the first relaxation. Speeds up difficult convergence considerably. Defaults to False.
  • **vasp_job_kwargs – Passthrough kwargs to VaspJob. See custodian.vasp.jobs.VaspJob.
Returns:

Generator of jobs.

postprocess()[source]

Postprocessing includes renaming and gzipping where necessary. Also copies the magmom to the incar if necessary

run()[source]

Perform the actual VASP run.

Returns:(subprocess.Popen) Used for monitoring.
setup()[source]

Performs initial setup for VaspJob, including overriding any settings and backing up.

class VaspNEBJob(vasp_cmd, output_file='neb_vasp.out', stderr_file='neb_std_err.txt', suffix='', final=True, backup=True, auto_npar=True, half_kpts=False, auto_gamma=True, auto_continue=False, gamma_vasp_cmd=None, settings_override=None)[source]

Bases: custodian.custodian.Job

A NEB vasp job, especially for CI-NEB running at PBS clusters. The class is added for the purpose of handling a different folder arrangement in NEB calculation.

This constructor is a simplified version of VaspJob, which satisfies the need for flexibility. For standard kinds of runs, it’s often better to use one of the static constructors. The defaults are usually fine too.

Parameters:
  • vasp_cmd (str) – Command to run vasp as a list of args. For example, if you are using mpirun, it can be something like [“mpirun”, “pvasp.5.2.11”]
  • output_file (str) – Name of file to direct standard out to. Defaults to “vasp.out”.
  • stderr_file (str) – Name of file to direct standard error to. Defaults to “std_err.txt”.
  • suffix (str) – A suffix to be appended to the final output. E.g., to rename all VASP output from say vasp.out to vasp.out.relax1, provide “.relax1” as the suffix.
  • final (bool) – Indicating whether this is the final vasp job in a series. Defaults to True.
  • backup (bool) – Whether to backup the initial input files. If True, the INCAR, KPOINTS, POSCAR and POTCAR will be copied with a “.orig” appended. Defaults to True.
  • auto_npar (bool) – Whether to automatically tune NPAR to be sqrt( number of cores) as recommended by VASP for DFT calculations. Generally, this results in significant speedups. Defaults to True. Set to False for HF, GW and RPA calculations.
  • half_kpts (bool) – Whether to halve the kpoint grid for NEB. Speeds up convergence considerably. Defaults to False.
  • auto_gamma (bool) – Whether to automatically check if run is a Gamma 1x1x1 run, and whether a Gamma optimized version of VASP exists with “.gamma” appended to the name of the VASP executable (typical setup in many systems). If so, run the gamma optimized version of VASP instead of regular VASP. You can also specify the gamma vasp command using the gamma_vasp_cmd argument if the command is named differently.
  • auto_continue (bool) – Whether to automatically continue a run if a STOPCAR is present. This is very useful if using the wall-time handler which will write a read-only STOPCAR to prevent VASP from deleting it once it finishes.
  • gamma_vasp_cmd (str) – Command for gamma vasp version when auto_gamma is True. Should follow the list style of subprocess. Defaults to None, which means “.gamma” is added to the last argument of the standard vasp_cmd.
  • settings_override ([dict]) –

    An ansible style list of dict to override changes. For example, to set ISTART=1 for subsequent runs and to copy the CONTCAR to the POSCAR, you will provide:

    [{"dict": "INCAR", "action": {"_set": {"ISTART": 1}}},
     {"file": "CONTCAR",
      "action": {"_file_copy": {"dest": "POSCAR"}}}]
    
postprocess()[source]

Postprocessing includes renaming and gzipping where necessary.

run()[source]

Perform the actual VASP run.

Returns:(subprocess.Popen) Used for monitoring.
setup()[source]

Performs initial setup for VaspNEBJob, including overriding any settings and backing up.

custodian.vasp.validators module

class VaspFilesValidator[source]

Bases: custodian.custodian.Validator

Check for existence of some of the files that VASP
normally create upon running.
check()[source]
class VaspNpTMDValidator[source]

Bases: custodian.custodian.Validator

Check NpT-AIMD settings is loaded by VASP compiled with -Dtbdyn. Currently, VASP only have Langevin thermostat (MDALGO = 3) for NpT ensemble.

check()[source]
class VasprunXMLValidator[source]

Bases: custodian.custodian.Validator

Checks that a valid vasprun.xml was generated

check()[source]

Module contents