| 1 | --- |
| 2 | layout: default |
| 3 | title: custodian.vasp.jobs.md |
| 4 | nav_exclude: true |
| 5 | --- |
| 6 | |
| 7 | # custodian.vasp.jobs module |
| 8 | |
| 9 | This module implements basic kinds of jobs for VASP runs. |
| 10 | |
| 11 | ## *class* custodian.vasp.jobs.GenerateVaspInputJob(input_set, contcar_only=True, \*\*kwargs) |
| 12 | |
| 13 | Bases: [`Job`](custodian.custodian.md#custodian.custodian.Job) |
| 14 | |
| 15 | Generates a VASP input based on an existing directory. This is typically |
| 16 | used to modify the VASP input files before the next VaspJob. |
| 17 | |
| 18 | * **Parameters** |
| 19 | * **input_set** (*str*) – Full path to the input set. E.g., |
| 20 | “pymatgen.io.vasp.sets.MPNonSCFSet”. |
| 21 | * **contcar_only** (*bool*) – If True (default), only CONTCAR structures |
| 22 | are used as input to the input set. |
| 23 | |
| 24 | ### postprocess() |
| 25 | |
| 26 | Dummy postprocess. |
| 27 | |
| 28 | ### run() |
| 29 | |
| 30 | Run the calculation. |
| 31 | |
| 32 | ### setup() |
| 33 | |
| 34 | Dummy setup |
| 35 | |
| 36 | ## *class* custodian.vasp.jobs.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) |
| 37 | |
| 38 | Bases: [`Job`](custodian.custodian.md#custodian.custodian.Job) |
| 39 | |
| 40 | A basic vasp job. Just runs whatever is in the directory. But conceivably |
| 41 | can be a complex processing of inputs etc. with initialization. |
| 42 | |
| 43 | This constructor is necessarily complex due to the need for |
| 44 | flexibility. For standard kinds of runs, it’s often better to use one |
| 45 | of the static constructors. The defaults are usually fine too. |
| 46 | |
| 47 | * **Parameters** |
| 48 | * **vasp_cmd** (*str*) – Command to run vasp as a list of args. For example, |
| 49 | if you are using mpirun, it can be something like |
| 50 | [“mpirun”, “pvasp.5.2.11”] |
| 51 | * **output_file** (*str*) – Name of file to direct standard out to. |
| 52 | Defaults to “vasp.out”. |
| 53 | * **stderr_file** (*str*) – Name of file to direct standard error to. |
| 54 | Defaults to “std_err.txt”. |
| 55 | * **suffix** (*str*) – A suffix to be appended to the final output. E.g., |
| 56 | to rename all VASP output from say vasp.out to |
| 57 | vasp.out.relax1, provide “.relax1” as the suffix. |
| 58 | * **final** (*bool*) – Indicating whether this is the final vasp job in a |
| 59 | series. Defaults to True. |
| 60 | * **backup** (*bool*) – Whether to backup the initial input files. If True, |
| 61 | the INCAR, KPOINTS, POSCAR and POTCAR will be copied with a |
| 62 | “.orig” appended. Defaults to True. |
| 63 | * **auto_npar** (*bool*) – Whether to automatically tune NPAR to be sqrt( |
| 64 | number of cores) as recommended by VASP for DFT calculations. |
| 65 | Generally, this results in significant speedups. Defaults to |
| 66 | False. Set to False for HF, GW and RPA calculations. |
| 67 | * **auto_gamma** (*bool*) – Whether to automatically check if run is a |
| 68 | Gamma 1x1x1 run, and whether a Gamma optimized version of |
| 69 | VASP exists with “.gamma” appended to the name of the VASP |
| 70 | executable (typical setup in many systems). If so, run the |
| 71 | gamma optimized version of VASP instead of regular VASP. You |
| 72 | can also specify the gamma vasp command using the |
| 73 | gamma_vasp_cmd argument if the command is named differently. |
| 74 | * **settings_override** ( *[**dict**]*) – An ansible style list of dict to |
| 75 | override changes. For example, to set ISTART=1 for subsequent |
| 76 | runs and to copy the CONTCAR to the POSCAR, you will provide: |
| 77 | |
| 78 | ```default |
| 79 | [{"dict": "INCAR", "action": {"_set": {"ISTART": 1}}}, |
| 80 | {"file": "CONTCAR", |
| 81 | "action": {"_file_copy": {"dest": "POSCAR"}}}] |
| 82 | ``` |
| 83 | |
| 84 | * **gamma_vasp_cmd** (*str*) – Command for gamma vasp version when |
| 85 | auto_gamma is True. Should follow the list style of |
| 86 | subprocess. Defaults to None, which means “.gamma” is added |
| 87 | to the last argument of the standard vasp_cmd. |
| 88 | * **copy_magmom** (*bool*) – Whether to copy the final magmom from the |
| 89 | OUTCAR to the next INCAR. Useful for multi-relaxation runs |
| 90 | where the CHGCAR and WAVECAR are sometimes deleted (due to |
| 91 | changes in fft grid, etc.). Only applies to non-final runs. |
| 92 | * **auto_continue** (*bool*) – Whether to automatically continue a run |
| 93 | if a STOPCAR is present. This is very useful if using the |
| 94 | wall-time handler which will write a read-only STOPCAR to |
| 95 | prevent VASP from deleting it once it finishes |
| 96 | |
| 97 | ### *classmethod* constrained_opt_run(vasp_cmd, lattice_direction, initial_strain, atom_relax=True, max_steps=20, algo=’bfgs’, \*\*vasp_job_kwargs) |
| 98 | |
| 99 | Returns a generator of jobs for a constrained optimization run. Typical |
| 100 | use case is when you want to approximate a biaxial strain situation, |
| 101 | e.g., you apply a defined strain to a and b directions of the lattice, |
| 102 | but allows the c-direction to relax. |
| 103 | |
| 104 | Some guidelines on the use of this method: |
| 105 | i. It is recommended you do not use the Auto kpoint generation. The |
| 106 | |
| 107 | > grid generated via Auto may fluctuate with changes in lattice |
| 108 | > param, resulting in numerical noise. |
| 109 | 1. Make sure your EDIFF/EDIFFG is properly set in your INCAR. The |
| 110 | optimization relies on these values to determine convergence. |
| 111 | |
| 112 | * **Parameters** |
| 113 | * **vasp_cmd** (*str*) – Command to run vasp as a list of args. For example, |
| 114 | if you are using mpirun, it can be something like |
| 115 | [“mpirun”, “pvasp.5.2.11”] |
| 116 | * **lattice_direction** (*str*) – Which direction to relax. Valid values are |
| 117 | “a”, “b” or “c”. |
| 118 | * **initial_strain** (*float*) – An initial strain to be applied to the |
| 119 | lattice_direction. This can usually be estimated as the |
| 120 | negative of the strain applied in the other two directions. |
| 121 | E.g., if you apply a tensile strain of 0.05 to the a and b |
| 122 | directions, you can use -0.05 as a reasonable first guess for |
| 123 | initial strain. |
| 124 | * **atom_relax** (*bool*) – Whether to relax atomic positions. |
| 125 | * **max_steps** (*int*) – The maximum number of runs. Defaults to 20 ( |
| 126 | highly unlikely that this limit is ever reached). |
| 127 | * **algo** (*str*) – Algorithm to use to find minimum. Default is “bfgs”, |
| 128 | which is fast, but can be sensitive to numerical noise |
| 129 | in energy calculations. The alternative is “bisection”, |
| 130 | which is more robust but can be a bit slow. The code does fall |
| 131 | back on the bisection when bfgs gives a nonsensical result, |
| 132 | e.g., negative lattice params. |
| 133 | * **\*\*vasp_job_kwargs** – Passthrough kwargs to VaspJob. See |
| 134 | `custodian.vasp.jobs.VaspJob`. |
| 135 | * **Returns** |
| 136 | |
| 137 | Generator of jobs. At the end of the run, an “EOS.txt” is written |
| 138 | which provides a quick look at the E vs lattice parameter. |
| 139 | |
| 140 | ### *classmethod* double_relaxation_run(vasp_cmd, auto_npar=True, ediffg=-0.05, half_kpts_first_relax=False, auto_continue=False) |
| 141 | |
| 142 | Returns a list of two jobs corresponding to an AFLOW style double |
| 143 | relaxation run. |
| 144 | |
| 145 | * **Parameters** |
| 146 | * **vasp_cmd** (*str*) – Command to run vasp as a list of args. For example, |
| 147 | if you are using mpirun, it can be something like |
| 148 | [“mpirun”, “pvasp.5.2.11”] |
| 149 | * **auto_npar** (*bool*) – Whether to automatically tune NPAR to be sqrt( |
| 150 | number of cores) as recommended by VASP for DFT calculations. |
| 151 | Generally, this results in significant speedups. Defaults to |
| 152 | True. Set to False for HF, GW and RPA calculations. |
| 153 | * **ediffg** (*float*) – Force convergence criteria for subsequent runs ( |
| 154 | ignored for the initial run.) |
| 155 | * **half_kpts_first_relax** (*bool*) – Whether to halve the kpoint grid |
| 156 | for the first relaxation. Speeds up difficult convergence |
| 157 | considerably. Defaults to False. |
| 158 | * **auto_continue** (*bool*) – Whether to automatically continue a run |
| 159 | if a STOPCAR is present. This is very useful if using the |
| 160 | wall-time handler which will write a read-only STOPCAR to |
| 161 | prevent VASP from deleting it once it finishes. Defaults to |
| 162 | False. |
| 163 | * **Returns** |
| 164 | |
| 165 | List of two jobs corresponding to an AFLOW style run. |
| 166 | |
| 167 | ### *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) |
| 168 | |
| 169 | Returns a generator of jobs for a full optimization run. Basically, |
| 170 | this runs an infinite series of geometry optimization jobs until the |
| 171 | |
| 172 | <!-- vol change in a particular optimization is less than vol_change_tol. --> |
| 173 | * **Parameters** |
| 174 | * **vasp_cmd** (*str*) – Command to run vasp as a list of args. For example, |
| 175 | if you are using mpirun, it can be something like |
| 176 | [“mpirun”, “pvasp.5.2.11”] |
| 177 | * **vol_change_tol** (*float*) – The tolerance at which to stop a run. |
| 178 | Defaults to 0.05, i.e., 5%. |
| 179 | * **max_steps** (*int*) – The maximum number of runs. Defaults to 10 ( |
| 180 | highly unlikely that this limit is ever reached). |
| 181 | * **ediffg** (*float*) – Force convergence criteria for subsequent runs ( |
| 182 | ignored for the initial run.) |
| 183 | * **half_kpts_first_relax** (*bool*) – Whether to halve the kpoint grid |
| 184 | for the first relaxation. Speeds up difficult convergence |
| 185 | considerably. Defaults to False. |
| 186 | * **\*\*vasp_job_kwargs** – Passthrough kwargs to VaspJob. See |
| 187 | `custodian.vasp.jobs.VaspJob`. |
| 188 | * **Returns** |
| 189 | |
| 190 | Generator of jobs. |
| 191 | |
| 192 | ### *classmethod* metagga_opt_run(vasp_cmd, auto_npar=True, ediffg=-0.05, half_kpts_first_relax=False, auto_continue=False) |
| 193 | |
| 194 | Returns a list of thres jobs to perform an optimization for any |
| 195 | metaGGA functional. There is an initial calculation of the |
| 196 | GGA wavefunction which is fed into the initial metaGGA optimization |
| 197 | to precondition the electronic structure optimizer. The metaGGA |
| 198 | optimization is performed using the double relaxation scheme |
| 199 | |
| 200 | ### postprocess() |
| 201 | |
| 202 | Postprocessing includes renaming and gzipping where necessary. |
| 203 | Also copies the magmom to the incar if necessary |
| 204 | |
| 205 | ### run() |
| 206 | |
| 207 | Perform the actual VASP run. |
| 208 | |
| 209 | * **Returns** |
| 210 | |
| 211 | (subprocess.Popen) Used for monitoring. |
| 212 | |
| 213 | ### setup() |
| 214 | |
| 215 | Performs initial setup for VaspJob, including overriding any settings |
| 216 | and backing up. |
| 217 | |
| 218 | ### terminate() |
| 219 | |
| 220 | Ensure all vasp jobs are killed. |
| 221 | |
| 222 | ## *class* custodian.vasp.jobs.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) |
| 223 | |
| 224 | Bases: `VaspJob` |
| 225 | |
| 226 | A NEB vasp job, especially for CI-NEB running at PBS clusters. |
| 227 | The class is added for the purpose of handling a different folder |
| 228 | arrangement in NEB calculation. |
| 229 | |
| 230 | This constructor is a simplified version of VaspJob, which satisfies |
| 231 | the need for flexibility. For standard kinds of runs, it’s often |
| 232 | better to use one of the static constructors. The defaults are |
| 233 | usually fine too. |
| 234 | |
| 235 | * **Parameters** |
| 236 | * **vasp_cmd** (*str*) – Command to run vasp as a list of args. For example, |
| 237 | if you are using mpirun, it can be something like |
| 238 | [“mpirun”, “pvasp.5.2.11”] |
| 239 | * **output_file** (*str*) – Name of file to direct standard out to. |
| 240 | Defaults to “vasp.out”. |
| 241 | * **stderr_file** (*str*) – Name of file to direct standard error to. |
| 242 | Defaults to “std_err.txt”. |
| 243 | * **suffix** (*str*) – A suffix to be appended to the final output. E.g., |
| 244 | to rename all VASP output from say vasp.out to |
| 245 | vasp.out.relax1, provide “.relax1” as the suffix. |
| 246 | * **final** (*bool*) – Indicating whether this is the final vasp job in a |
| 247 | series. Defaults to True. |
| 248 | * **backup** (*bool*) – Whether to backup the initial input files. If True, |
| 249 | the INCAR, KPOINTS, POSCAR and POTCAR will be copied with a |
| 250 | “.orig” appended. Defaults to True. |
| 251 | * **auto_npar** (*bool*) – Whether to automatically tune NPAR to be sqrt( |
| 252 | number of cores) as recommended by VASP for DFT calculations. |
| 253 | Generally, this results in significant speedups. Defaults to |
| 254 | True. Set to False for HF, GW and RPA calculations. |
| 255 | * **half_kpts** (*bool*) – Whether to halve the kpoint grid for NEB. |
| 256 | Speeds up convergence considerably. Defaults to False. |
| 257 | * **auto_gamma** (*bool*) – Whether to automatically check if run is a |
| 258 | Gamma 1x1x1 run, and whether a Gamma optimized version of |
| 259 | VASP exists with “.gamma” appended to the name of the VASP |
| 260 | executable (typical setup in many systems). If so, run the |
| 261 | gamma optimized version of VASP instead of regular VASP. You |
| 262 | can also specify the gamma vasp command using the |
| 263 | gamma_vasp_cmd argument if the command is named differently. |
| 264 | * **auto_continue** (*bool*) – Whether to automatically continue a run |
| 265 | if a STOPCAR is present. This is very useful if using the |
| 266 | wall-time handler which will write a read-only STOPCAR to |
| 267 | prevent VASP from deleting it once it finishes. |
| 268 | * **gamma_vasp_cmd** (*str*) – Command for gamma vasp version when |
| 269 | auto_gamma is True. Should follow the list style of |
| 270 | subprocess. Defaults to None, which means “.gamma” is added |
| 271 | to the last argument of the standard vasp_cmd. |
| 272 | * **settings_override** ( *[**dict**]*) – An ansible style list of dict to |
| 273 | override changes. For example, to set ISTART=1 for subsequent |
| 274 | runs and to copy the CONTCAR to the POSCAR, you will provide: |
| 275 | |
| 276 | ```default |
| 277 | [{"dict": "INCAR", "action": {"_set": {"ISTART": 1}}}, |
| 278 | {"file": "CONTCAR", |
| 279 | "action": {"_file_copy": {"dest": "POSCAR"}}}] |
| 280 | ``` |
| 281 | |
| 282 | ### postprocess() |
| 283 | |
| 284 | Postprocessing includes renaming and gzipping where necessary. |
| 285 | |
| 286 | ### run() |
| 287 | |
| 288 | Perform the actual VASP run. |
| 289 | |
| 290 | * **Returns** |
| 291 | |
| 292 | (subprocess.Popen) Used for monitoring. |
| 293 | |
| 294 | ### setup() |
| 295 | |
| 296 | Performs initial setup for VaspNEBJob, including overriding any settings |
| 297 | and backing up. |