|
| 1 | +--- |
| 2 | +layout: default |
| 3 | +title: custodian.gaussian.handlers.md |
| 4 | +nav_exclude: true |
| 5 | +--- |
| 6 | + |
| 7 | +# custodian.gaussian.handlers module |
| 8 | + |
| 9 | +This module implements error handlers for Gaussian runs. |
| 10 | + |
| 11 | +### *class* custodian.gaussian.handlers.GaussianErrorHandler(input_file: str, output_file: str, stderr_file: str = 'stderr.txt', cart_coords: bool = True, scf_max_cycles: int = 100, opt_max_cycles: int = 100, job_type: str = 'normal', lower_functional: str | None = None, lower_basis_set: str | None = None, prefix: str = 'error', check_convergence: bool = True) |
| 12 | + |
| 13 | +Bases: `ErrorHandler` |
| 14 | + |
| 15 | +Master GaussianErrorHandler class that handles a number of common errors that occur |
| 16 | +during Gaussian runs. |
| 17 | + |
| 18 | +Initialize the GaussianErrorHandler class. |
| 19 | + |
| 20 | +* **Parameters:** |
| 21 | + * **input_file** (*str*) – The name of the input file for the Gaussian job. |
| 22 | + * **output_file** (*str*) – The name of the output file for the Gaussian job. |
| 23 | + * **stderr_file** (*str*) – The name of the standard error file for the Gaussian job. |
| 24 | + Defaults to ‘stderr.txt’. |
| 25 | + * **cart_coords** (*bool*) – Whether the coordinates are in cartesian format. |
| 26 | + Defaults to True. |
| 27 | + * **scf_max_cycles** (*int*) – The maximum number of SCF cycles. Defaults to 100. |
| 28 | + * **opt_max_cycles** (*int*) – The maximum number of optimization cycles. Defaults to |
| 29 | + 100. |
| 30 | + * **job_type** (*str*) – The type of job to run. Supported options are ‘normal’ and |
| 31 | + ‘better_guess’. Defaults to ‘normal’. If ‘better_guess’ is chosen, the |
| 32 | + job will be rerun at a lower level of theory to get a better initial |
| 33 | + guess of molecular orbitals or geometry, if needed. |
| 34 | + * **lower_functional** (*str*) – The lower level of theory to use for a better guess. |
| 35 | + * **lower_basis_set** (*str*) – The lower basis set to use for a better guess. |
| 36 | + * **prefix** (*str*) – The prefix to use for the backup files. Defaults to error, |
| 37 | + which means a series of error.1.tar.gz, error.2.tar.gz, … will be |
| 38 | + generated. |
| 39 | + * **check_convergence** (*bool*) – Whether to check for convergence during an |
| 40 | + optimization job. Defaults to True. If True, the convergence data will |
| 41 | + be monitored and plotted (convergence criteria versus cycle number) and |
| 42 | + saved to a file called ‘convergence.png’. |
| 43 | + |
| 44 | +#### GRID_NAMES *= ('finegrid', 'fine', 'superfinegrid', 'superfine', 'coarsegrid', 'coarse', 'sg1grid', 'sg1', 'pass0grid', 'pass0')* |
| 45 | + |
| 46 | +#### MEM_UNITS *= ('kb', 'mb', 'gb', 'tb', 'kw', 'mw', 'gw', 'tw')* |
| 47 | + |
| 48 | +#### activate_better_guess *= False* |
| 49 | + |
| 50 | +#### check(directory: str = './') |
| 51 | + |
| 52 | +Check for errors in the Gaussian output file. |
| 53 | + |
| 54 | +#### conv_criteria*: ClassVar* *= {'max_disp': re.compile('\\\\s+(Maximum Displacement)\\\\s+(-?\\\\d+.?\\\\d\*|.\*)\\\\s+(-?\\\\d+.?\\\\d\*)'), 'max_force': re.compile('\\\\s+(Maximum Force)\\\\s+(-?\\\\d+.?\\\\d\*|.\*)\\\\s+(-?\\\\d+.?\\\\d\*)'), 'rms_disp': re.compile('\\\\s+(RMS {5}Displacement)\\\\s+(-?\\\\d+.?\\\\d\*|.\*)\\\\s+(-?\\\\d+.?\\\\d\*)'), 'rms_force': re.compile('\\\\s+(RMS {5}Force)\\\\s+(-?\\\\d+.?\\\\d\*|.\*)\\\\s+(-?\\\\d+.?\\\\d\*)')}* |
| 55 | + |
| 56 | +#### *static* convert_mem(mem: float, unit: str) |
| 57 | + |
| 58 | +Convert memory size between different units to megabytes (MB). |
| 59 | + |
| 60 | +* **Parameters:** |
| 61 | + * **mem** (*float*) – The memory size to convert. |
| 62 | + * **unit** (*str*) – The unit of the input memory size. Supported units include |
| 63 | + ‘kb’, ‘mb’, ‘gb’, ‘tb’, and word units (‘kw’, ‘mw’, ‘gw’, ‘tw’), or an |
| 64 | + empty string for default conversion (from words). |
| 65 | +* **Returns:** |
| 66 | + The memory size in MB. |
| 67 | +* **Return type:** |
| 68 | + float |
| 69 | + |
| 70 | +#### correct(directory: str = './') |
| 71 | + |
| 72 | +Perform necessary actions to correct the errors in the Gaussian output. |
| 73 | + |
| 74 | +#### error_defs*: ClassVar* *= {'A syntax error was detected in the input line.': 'syntax', 'Atom specifications unexpectedly found in input stream.': 'found_coords', 'Bad file opened by FileIO': 'bad_file', 'Convergence failure': 'scf_convergence', 'End of file in ZSymb': 'zmatrix', 'End of file reading connectivity.': 'coords', 'Error in internal coordinate system': 'internal_coords', 'FileIO operation on non-existent file.': 'missing_file', 'FormBX had a problem': 'linear_bend', 'Inv3 failed in PCMMkU': 'solute_solvent_surface', 'Linear angle in Tors.': 'linear_bend', 'No data on chk file.': 'empty_file', 'Optimization stopped': 'opt_steps', 'Out-of-memory error in routine': 'insufficient_mem', 'The combination of multiplicity ([0-9]+) and \\\\s+? ([0-9]+) electrons is impossible.': 'charge', 'There are no atoms in this input structure !': 'missing_mol', 'Z-matrix optimization but no Z-matrix variables.': 'coord_inputs'}* |
| 75 | + |
| 76 | +#### error_patt *= re.compile('Optimization stopped|Convergence failure|FormBX had a problem|Linear angle in Tors.|Inv3 failed in PCMMkU|Error in internal coordinate system|End of file in ZSymb|There are no atoms in this input str)* |
| 77 | + |
| 78 | +#### grid_patt *= re.compile('(-?\\\\d{5})')* |
| 79 | + |
| 80 | +#### recom_mem_patt *= re.compile('Use %mem=([0-9]+)MW to provide the minimum amount of memory required to complete this step.')* |
| 81 | + |
| 82 | +### *class* custodian.gaussian.handlers.WallTimeErrorHandler(wall_time: int, buffer_time: int, input_file: str, output_file: str, stderr_file: str = 'stderr.txt', prefix: str = 'error') |
| 83 | + |
| 84 | +Bases: `ErrorHandler` |
| 85 | + |
| 86 | +Check if a run is nearing the walltime. If so, terminate the job and restart from |
| 87 | +the last .rwf file. A job is considered to be nearing the walltime if the remaining |
| 88 | +time is less than or equal to the buffer time. |
| 89 | + |
| 90 | +Initialize the WalTimeErrorHandler class. |
| 91 | + |
| 92 | +* **Parameters:** |
| 93 | + * **wall_time** (*int*) – The total wall time for the job in seconds. |
| 94 | + * **buffer_time** (*int*) – The buffer time in seconds. If the remaining time is less |
| 95 | + than or equal to the buffer time, the job is considered to be nearing the |
| 96 | + walltime and will be terminated. |
| 97 | + * **input_file** (*str*) – The name of the input file for the Gaussian job. |
| 98 | + * **output_file** (*str*) – The name of the output file for the Gaussian job. |
| 99 | + * **stderr_file** (*str*) – The name of the standard error file for the Gaussian job. |
| 100 | + Defaults to ‘stderr.txt’. |
| 101 | + * **prefix** (*str*) – The prefix to use for the backup files. Defaults to error, |
| 102 | + which means a series of error.1.tar.gz, error.2.tar.gz, … will be |
| 103 | + generated. |
| 104 | + |
| 105 | +#### check(directory: str = './') |
| 106 | + |
| 107 | +Check if the job is nearing the walltime. If so, return True, else False. |
| 108 | + |
| 109 | +#### correct(directory: str = './') |
| 110 | + |
| 111 | +Perform the corrections. |
| 112 | + |
| 113 | +#### is_monitor*: bool* *= True* |
| 114 | + |
| 115 | +This class property indicates whether the error handler is a monitor, |
| 116 | +i.e., a handler that monitors a job as it is running. If a |
| 117 | +monitor-type handler notices an error, the job will be sent a |
| 118 | +termination signal, the error is then corrected, |
| 119 | +and then the job is restarted. This is useful for catching errors |
| 120 | +that occur early in the run but do not cause immediate failure. |
0 commit comments