custodian.vasp package

Subpackages

Submodules

custodian.vasp.handlers module

This module implements specific error handlers for VASP runs. These handlers try to detect common errors in vasp runs and attempt to fix them on the fly by modifying the input files.

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]

Check for error.

correct()[source]

Perform corrections.

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

This class property indicates whether the error handler is a monitor, i.e., a handler that monitors a job as it is running. If a monitor-type handler notices an error, the job will be sent a termination signal, the error is then corrected, and then the job is restarted. This is useful for catching errors that occur early in the run but do not cause immediate failure.

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 combination with the StoppedRunHandler.

Initializes the handler with an interval.

Parameters
  • interval (int) – Interval at which to checkpoint in seconds.

  • 3600 (Defaults to) –

check()[source]

Check for error.

correct()[source]

Perform corrections.

is_monitor = True

This class property indicates whether the error handler is a monitor, i.e., a handler that monitors a job as it is running. If a monitor-type handler notices an error, the job will be sent a termination signal, the error is then corrected, and then the job is restarted. This is useful for catching errors that occur early in the run but do not cause immediate failure.

is_terminating = False

Whether this handler terminates a job upon error detection. By default, this is True, which means that the current Job will be terminated upon error detection, corrections applied, and restarted. In some instances, some errors may not need the job to be terminated or may need to wait for some other event to terminate a job. For example, a particular error may require a flag to be set to request a job to terminate gracefully once it finishes its current task. The handler to set the flag should be classified as is_terminating = False to not terminate the job.

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

check()[source]

Check for error.

correct()[source]

Perform corrections.

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]

Check for error.

correct()[source]

Perform corrections.

is_monitor = True

This class property indicates whether the error handler is a monitor, i.e., a handler that monitors a job as it is running. If a monitor-type handler notices an error, the job will be sent a termination signal, the error is then corrected, and then the job is restarted. This is useful for catching errors that occur early in the run but do not cause immediate failure.

class IncorrectSmearingHandler(output_filename='vasprun.xml')[source]

Bases: custodian.custodian.ErrorHandler

Check if a calculation is a metal (zero bandgap), has been run with ISMEAR=-5, and is not a static calculation, which is only appropriate for semiconductors. If this occurs, this handler will rerun the calculation using the smearing settings appropriate for metals (ISMEAR=2, SIGMA=0.2).

Initializes the handler with the output file to check.

Parameters

output_filename (str) – Filename for the vasprun.xml file. Change this only if it is different from the default (unlikely).

check()[source]

Check for error.

correct()[source]

Perform corrections.

is_monitor = False

This class property indicates whether the error handler is a monitor, i.e., a handler that monitors a job as it is running. If a monitor-type handler notices an error, the job will be sent a termination signal, the error is then corrected, and then the job is restarted. This is useful for catching errors that occur early in the run but do not cause immediate failure.

class LargeSigmaHandler[source]

Bases: custodian.custodian.ErrorHandler

When ISMEAR > 0 (Methfessel-Paxton), monitor the magnitude of the entropy term T*S in the OUTCAR file. If the entropy term is larger than 1 meV/atom, reduce the value of SIGMA. See VASP documentation for ISMEAR.

Initializes the handler with a buffer time.

check()[source]

Check for error.

correct()[source]

Perform corrections.

is_monitor = True

This class property indicates whether the error handler is a monitor, i.e., a handler that monitors a job as it is running. If a monitor-type handler notices an error, the job will be sent a termination signal, the error is then corrected, and then the job is restarted. This is useful for catching errors that occur early in the run but do not cause immediate failure.

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]

Check for error.

correct()[source]

Perform corrections.

error_msgs = {'lrf_comm': ['LRF_COMMUTATOR internal error']}
is_monitor = True

This class property indicates whether the error handler is a monitor, i.e., a handler that monitors a job as it is running. If a monitor-type handler notices an error, the job will be sent a termination signal, the error is then corrected, and then the job is restarted. This is useful for catching errors that occur early in the run but do not cause immediate failure.

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]

Check for error.

correct()[source]

Perform corrections.

is_monitor = False

This class property indicates whether the error handler is a monitor, i.e., a handler that monitors a job as it is running. If a monitor-type handler notices an error, the job will be sent a termination signal, the error is then corrected, and then the job is restarted. This is useful for catching errors that occur early in the run but do not cause immediate failure.

class NonConvergingErrorHandler(output_filename='OSZICAR', nionic_steps=10)[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 using a multi-step ladder scheme 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.

check()[source]

Check for error.

correct()[source]

Perform corrections.

classmethod from_dict(d)[source]

Custom from_dict method to preserve backwards compatibility with older versions of Custodian.

is_monitor = True

This class property indicates whether the error handler is a monitor, i.e., a handler that monitors a job as it is running. If a monitor-type handler notices an error, the job will be sent a termination signal, the error is then corrected, and then the job is restarted. This is useful for catching errors that occur early in the run but do not cause immediate failure.

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]

Check for error.

correct()[source]

Perform corrections.

is_monitor = True

This class property indicates whether the error handler is a monitor, i.e., a handler that monitors a job as it is running. If a monitor-type handler notices an error, the job will be sent a termination signal, the error is then corrected, and then the job is restarted. This is useful for catching errors that occur early in the run but do not cause immediate failure.

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]

Check for error.

correct()[source]

Perform corrections.

is_monitor = True

This class property indicates whether the error handler is a monitor, i.e., a handler that monitors a job as it is running. If a monitor-type handler notices an error, the job will be sent a termination signal, the error is then corrected, and then the job is restarted. This is useful for catching errors that occur early in the run but do not cause immediate failure.

class ScanMetalHandler(output_filename='vasprun.xml')[source]

Bases: custodian.custodian.ErrorHandler

Check if a SCAN calculation is a metal (zero bandgap) but has been run with a KSPACING value appropriate for semiconductors. If this occurs, this handler will rerun the calculation using the KSPACING setting appropriate for metals (KSPACING=0.22). Note that this handler depends on values set in MPScanRelaxSet.

Initializes the handler with the output file to check.

Parameters

output_filename (str) – Filename for the vasprun.xml file. Change this only if it is different from the default (unlikely).

check()[source]

Check for error.

correct()[source]

Perform corrections.

is_monitor = False

This class property indicates whether the error handler is a monitor, i.e., a handler that monitors a job as it is running. If a monitor-type handler notices an error, the job will be sent a termination signal, the error is then corrected, and then the job is restarted. This is useful for catching errors that occur early in the run but do not cause immediate failure.

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]

Check for error.

correct()[source]

Perform corrections.

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

This class property indicates whether the error handler is a monitor, i.e., a handler that monitors a job as it is running. If a monitor-type handler notices an error, the job will be sent a termination signal, the error is then corrected, and then the job is restarted. This is useful for catching errors that occur early in the run but do not cause immediate failure.

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.

Dummy init.

check()[source]

Check for error.

correct()[source]

Perform corrections.

is_monitor = False

This class property indicates whether the error handler is a monitor, i.e., a handler that monitors a job as it is running. If a monitor-type handler notices an error, the job will be sent a termination signal, the error is then corrected, and then the job is restarted. This is useful for catching errors that occur early in the run but do not cause immediate failure.

is_terminating = False

Whether this handler terminates a job upon error detection. By default, this is True, which means that the current Job will be terminated upon error detection, corrections applied, and restarted. In some instances, some errors may not need the job to be terminated or may need to wait for some other event to terminate a job. For example, a particular error may require a flag to be set to request a job to terminate gracefully once it finishes its current task. The handler to set the flag should be classified as is_terminating = False to not terminate the job.

class UnconvergedErrorHandler(output_filename='vasprun.xml')[source]

Bases: custodian.custodian.ErrorHandler

Check if a run is converged.

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]

Check for error.

correct()[source]

Perform corrections.

is_monitor = False

This class property indicates whether the error handler is a monitor, i.e., a handler that monitors a job as it is running. If a monitor-type handler notices an error, the job will be sent a termination signal, the error is then corrected, and then the job is restarted. This is useful for catching errors that occur early in the run but do not cause immediate failure.

class VaspErrorHandler(output_filename='vasp.out', natoms_large_cell=None, errors_subset_to_catch=None, vtst_fixes=False)[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.

  • natoms_large_cell (int) – Number of atoms threshold to treat cell as large. Affects the correction of certain errors. Defaults to None (not used). Deprecated.

  • errors_subset_to_detect (list) – A subset of errors to catch. The default is None, which means all supported errors are detected. Use this to only catch only a subset of supported errors. E.g., [“eddrrm”, “zheev”] will only catch the eddrmm and zheev errors, and not others. If you wish to only excluded one or two of the errors, you can create this list by the following lines:

  • vtst_fixes (bool) –

    Whether to consider VTST optimizers. Defaults to False for compatibility purposes.

    ``` subset = list(VaspErrorHandler.error_msgs.keys()) subset.pop(“eddrrm”)

    handler = VaspErrorHandler(errors_subset_to_catch=subset) ```

check()[source]

Check for error.

correct()[source]

Perform corrections.

error_msgs = {'algo_tet': ['ALGO=A and IALGO=5X tend to fail'], 'amin': ['One of the lattice vectors is very long (>50 A), but AMIN'], 'bravais': ['Inconsistent Bravais lattice'], 'brions': ['BRIONS problems: POTIM should be increased'], 'brmix': ['BRMIX: very serious problems'], 'coef': ['while reading plane'], 'dentet': ['DENTET'], 'dfpt_ncore': ['PEAD routines do not work for NCORE', 'remove the tag NPAR from the INCAR file'], 'edddav': ['Error EDDDAV: Call to ZHEGV failed'], 'eddrmm': ['WARNING in EDDRMM: call to ZHEGV failed'], 'elf_kpar': ['ELF: KPAR>1 not implemented'], 'elf_ncl': ['WARNING: ELF not implemented for non collinear case'], 'grad_not_orth': ['EDWAV: internal error, the gradient is not orthogonal'], 'hnform': ['HNFORM: k-point generating'], 'incorrect_shift': ['Could not get correct shifts'], 'inv_rot_mat': ['rotation matrix was not found (increase SYMPREC)'], 'nbands_not_sufficient': ['number of bands is not sufficient'], 'nicht_konv': ['ERROR: SBESSELITER : nicht konvergent'], 'point_group': ['group operation missing'], 'posmap': ['POSMAP'], 'pricel': ['internal error in subroutine PRICEL'], 'pssyevx': ['ERROR in subspace rotation PSSYEVX'], 'real_optlay': ['REAL_OPTLAY: internal error', 'REAL_OPT: internal ERROR'], 'rhosyg': ['RHOSYG'], 'rot_matrix': ['Found some non-integer element in rotation matrix', 'SGRCON'], 'rspher': ['ERROR RSPHER'], 'subspacematrix': ['WARNING: Sub-Space-Matrix is not hermitian in DAV'], 'symprec_noise': ['determination of the symmetry of your systems shows a strong'], 'tet': ['Tetrahedron method fails', 'tetrahedron method fails', 'Fatal error detecting k-mesh', 'Fatal error: unable to match k-point', 'Routine TETIRR needs special values', 'Tetrahedron method fails (number of k-points < 4)', 'BZINTS'], 'tetirr': ['Routine TETIRR needs special values'], 'too_few_bands': ['TOO FEW BANDS'], 'triple_product': ['ERROR: the triple product of the basis vectors'], 'zbrent': ['ZBRENT: fatal internal in', 'ZBRENT: fatal error in bracketing'], 'zheev': ['ERROR EDDIAG: Call to routine ZHEEV failed!'], 'zpotrf': ['LAPACK: Routine ZPOTRF failed', 'Routine ZPOTRF ZTRTRI']}
is_monitor = True

This class property indicates whether the error handler is a monitor, i.e., a handler that monitors a job as it is running. If a monitor-type handler notices an error, the job will be sent a termination signal, the error is then corrected, and then the job is restarted. This is useful for catching errors that occur early in the run but do not cause immediate failure.

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]

Check for error.

correct()[source]

Perform corrections.

is_monitor = True

This class property indicates whether the error handler is a monitor, i.e., a handler that monitors a job as it is running. If a monitor-type handler notices an error, the job will be sent a termination signal, the error is then corrected, and then the job is restarted. This is useful for catching errors that occur early in the run but do not cause immediate failure.

is_terminating = False

Whether this handler terminates a job upon error detection. By default, this is True, which means that the current Job will be terminated upon error detection, corrections applied, and restarted. In some instances, some errors may not need the job to be terminated or may need to wait for some other event to terminate a job. For example, a particular error may require a flag to be set to request a job to terminate gracefully once it finishes its current task. The handler to set the flag should be classified as is_terminating = False to not terminate the job.

raises_runtime_error = False

Whether this handler causes custodian to raise a runtime error if it cannot handle the error (i.e. if correct returns a dict with “actions”:None, or “actions”:[])

custodian.vasp.interpreter module

Implements various interpreters and modders for VASP.

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

Bases: custodian.ansible.interpreter.Modder

A Modder for VaspInputSets.

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

This module implements basic kinds of jobs for VASP runs.

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]

Dummy postprocess.

run()[source]

Run the calculation.

setup()[source]

Dummy setup

class VaspJob(vasp_cmd, output_file='vasp.out', stderr_file='std_err.txt', suffix='', final=True, backup=True, auto_npar=False, 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 False. 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 useful 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.

  • 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. 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.

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

Returns a list of thres jobs to perform an optimization for any metaGGA functional. There is an initial calculation of the GGA wavefunction which is fed into the initial metaGGA optimization to precondition the electronic structure optimizer. The metaGGA optimization is performed using the double relaxation scheme

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.

terminate()[source]

Ensure all vasp jobs are killed.

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.vasp.jobs.VaspJob

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

Implements various validatiors, e.g., check if vasprun.xml is valid, for VASP.

class VaspAECCARValidator[source]

Bases: custodian.custodian.Validator

Check if the data in the AECCAR is corrupted

Dummy init

check()[source]

Check for error.

class VaspFilesValidator[source]

Bases: custodian.custodian.Validator

Check for existence of some of the files that VASP

normally create upon running.

Dummy init

check()[source]

Check for error.

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.

Dummy init.

check()[source]

Check for error.

class VasprunXMLValidator(output_file='vasp.out', stderr_file='std_err.txt')[source]

Bases: custodian.custodian.Validator

Checks that a valid vasprun.xml was generated

Parameters
  • output_file (str) – Name of file VASP standard output is directed to. Defaults to “vasp.out”.

  • stderr_file (str) – Name of file VASP standard error is direct to. Defaults to “std_err.txt”.

check()[source]

Check for error.

check_broken_chgcar(chgcar, diff_thresh=None)[source]

Check if the charge density file is corrupt :param chgcar: Chgcar-like object. :type chgcar: Chgcar :param diff_thresh: Threshold for diagonal difference.

None means we won’t check for this.

Module contents

This package implements various VASP Jobs and Error Handlers.