tesliper.extraction.gaussian_parser
Paser for Gaussian output files.
Classes
Parser for extracting data from human-readable output files from Gaussian computational chemistry software (.log and .out files). |
- class tesliper.extraction.gaussian_parser.GaussianParser[source]
Parser for extracting data from human-readable output files from Gaussian computational chemistry software (.log and .out files).
This class implements methods for reading information about conducted calculations’ parameters, molecule energy, structure optimization, and calculation of spectral properties. It’s use is as straightforward as:
>>> parser = GaussianParser() >>> with open('path/to/file.out') as file: >>> data = parser.parse(file)
Dictionary with data extracted is also stored as
dataattribute of instance used for parsing. Each key in said dictionary is a name of its value data type, called from now on a ‘data genre’ (to avoid confusion with Python’s data type). Below is a full list of data genres recognized by this parser, with their description:- freqlist of floats, available from freq job
harmonic vibrational frequencies (cm^-1)
- masslist of floats, available from freq job
reduced masses (AMU)
- frclist of floats, available from freq job
force constants (mDyne/A)
- irilist of floats, available from freq job
IR intensities (KM/mole)
- diplist of floats, available from freq=VCD job
dipole strengths (10**-40 esu**2-cm**2)
- rotlist of floats, available from freq=VCD job
rotational strengths (10**-44 esu**2-cm**2)
- emanglist of floats, available from freq=VCD job
E-M angle = Angle between electric and magnetic dipole transition moments (deg)
- depolarplist of floats, available from freq=Raman job
depolarization ratios for plane incident light
- depolarulist of floats, available from freq=Raman job
depolarization ratios for unpolarized incident light
- ramanactivlist of floats, available from freq=Raman job
Raman scattering activities (A**4/AMU)
- ramactlist of floats, available from freq=ROA job
Raman scattering activities (A**4/AMU)
- depplist of floats, available from freq=ROA job
depolarization ratios for plane incident light
- depulist of floats, available from freq=ROA job
depolarization ratios for unpolarized incident light
- alpha2list of floats, available from freq=ROA job
Raman invariants Alpha2 = alpha**2 (A**4/AMU)
- beta2list of floats, available from freq=ROA job
Raman invariants Beta2 = beta(alpha)**2 (A**4/AMU)
- alphaglist of floats, available from freq=ROA job
ROA invariants AlphaG = alphaG’(10**4 A**5/AMU)
- gamma2list of floats, available from freq=ROA job
ROA invariants Gamma2 = beta(G’)**2 (10**4 A**5/AMU)
- delta2list of floats, available from freq=ROA job
ROA invariants Delta2 = beta(A)**2, (10**4 A**5/AMU)
- raman1list of floats, available from freq=ROA job
Far-From-Resonance Raman intensities =ICPu/SCPu(180) (K)
- roa1list of floats, available from freq=ROA job
ROA intensities =ICPu/SCPu(180) (10**4 K)
- cid1list of floats, available from freq=ROA job
CID=(ROA/Raman)*10**4 =ICPu/SCPu(180)
- raman2list of floats, available from freq=ROA job
Far-From-Resonance Raman intensities =ICPd/SCPd(90) (K)
- roa2list of floats, available from freq=ROA job
ROA intensities =ICPd/SCPd(90) (10**4 K)
- cid2list of floats, available from freq=ROA job
CID=(ROA/Raman)*10**4 =ICPd/SCPd(90)
- raman3list of floats, available from freq=ROA job
Far-From-Resonance Raman intensities =DCPI(180) (K)
- roa3list of floats, available from freq=ROA job
ROA intensities =DCPI(180) (10**4 K)
- cid3list of floats, available from freq=ROA job
CID=(ROA/Raman)*10**4 =DCPI(180)
- rc180list of floats, available from freq=ROA job
RC180 = degree of circularity
- wavelenlist of floats, available from td job
excitation energies (nm)
- ex_enlist of floats, available from td job
excitation energies (eV)
- eemanglist of floats, available from td job
E-M angle = Angle between electric and magnetic dipole transition moments (deg)
- vdiplist of floats, available from td job
dipole strengths (velocity)
- ldiplist of floats, available from td job
dipole strengths (length)
- vrotlist of floats, available from td job
rotatory strengths (velocity) in cgs (10**-40 erg-esu-cm/Gauss)
- lrotlist of floats, available from td job
rotatory strengths (length) in cgs (10**-40 erg-esu-cm/Gauss)
- vosclist of floats, available from td job
oscillator strengths
- losclist of floats, available from td job
oscillator strengths
- transitionslist of lists of lists of (int, int, float), available from td job
transitions (first to second) and their coefficients (third)
- scffloat, always available
SCF energy
- zpefloat, available from freq job
Sum of electronic and zero-point Energies (Hartree/Particle)
- tenfloat, available from freq job
Sum of electronic and thermal Energies (Hartree/Particle)
- entfloat, available from freq job
Sum of electronic and thermal Enthalpies (Hartree/Particle)
- gibfloat, available from freq job
Sum of electronic and thermal Free Energies (Hartree/Particle)
- zpecorrfloat, available from freq job
Zero-point correction (Hartree/Particle)
- tencorrfloat, available from freq job
Thermal correction to Energy (Hartree/Particle)
- entcorrfloat, available from freq job
Thermal correction to Enthalpy (Hartree/Particle)
- gibcorrfloat, available from freq job
Thermal correction to Gibbs Free Energy (Hartree/Particle)
- commandstr, always available
command used for calculations
- normal_terminationbool, always available
true if Gaussian job seem to exit normally, false otherwise
- optimization_completedbool, available from opt job
true if structure optimization was performed successfully
- versionstr, always available
version of Gaussian software used
- chargeint, always available
molecule’s charge
- multiplicityint, always available
molecule’s spin multiplicity
- input_atomslist of str, always available
input atoms as a list of atoms’ symbols
- input_geomlist of lists of floats, always available
input geometry as X, Y, Z coordinates of atoms
- stoichiometrystr, always available
molecule’s stoichiometry
- last_read_atomslist of ints, always available
molecule’s atoms as atomic numbers
- last_read_geomlist of lists of floats, always available
molecule’s geometry (last one found in file) as X, Y, Z coordinates of atoms
- optimized_atomslist of ints, available from successful opt job
molecule’s atoms read from optimized geometry as atomic numbers
- optimized_geomlist of lists of floats, available from successful opt job
optimized geometry as X, Y, Z coordinates of atoms
- data
Data extracted during last parsing.
- Type
dict
- parse(lines) dict[source]
Parses content of Gaussian output file and returns dictionary of found data.
- Parameters
lines (iterator) – Gaussian output file in a form iterable by lines of text. It may be a file handle, a list of strings, an io.StringIO instance, or similar. Please note that it should not be just a string instance, as it is normally iterated by a character, not by a line.
- Returns
Dictionary of extracted data.
- Return type
dict
- initial(line: str) None[source]
First step of parsing Gaussian output file. It populates parser.data dictionary with these data genes: ‘normal_termination’, ‘version’, ‘command’, ‘charge’, ‘multiplicity’, ‘input_geom’. Optionally, ‘optimization_completed’ genre is added if optimization was requested in calculation job.
- Parameters
line (str) – Line of text to parse.
- wait(line: str) None[source]
This function searches for lines of text triggering other parsing states. It also updates a parser.data dictionary with ‘normal_termination’, ‘scf’, ‘stoichiometry’ data genres.
- Parameters
line (str) – Line of text to parse.
- geometry(line: str) None[source]
Function for extracting information about molecule standard orientation geometry from Gaussian output files. It updates parser.data dictionary with ‘last_read_atoms’ and ‘last_read_geom’ data genres.
- Parameters
line (str) – Line of text to parse.
- optimization(line: str) None[source]
This method scans optimization data in Gaussian output file, updating parser.data dictionary with ‘stoichiometry’, ‘scf’, ‘optimization_completed’, ‘optimized_atoms’, and ‘optimized_geom’ data genres (last two via
geometry()method).- Parameters
line (str) – Line of text to parse.
- frequencies(line: str) None[source]
Responsible for extracting harmonic vibrations-related data and information about molecule’s energy.
- Parameters
line (str) – Line of text to parse.
- excited(line: str) None[source]
Responsible for extracting electronic transitions-related data from Gaussian output file. Updates parser.data dictionary with ‘ldip’, ‘losc’, ‘vdip’, ‘vosc’, ‘vrot’, ‘eemang’, ‘lrot’, ‘wavelen’, ‘ex_en’, and ‘transitions’ data genres.
- Parameters
line (str) – Line of text to parse.
- add_state(state: Callable, name: str = '', trigger: str = '')
Register callable as parser’s state.
This method registers a callable under name key in
statesdictionary. If trigger parameter is given, it is registered under the same key intriggersdictionary.- Parameters
state (Callable) – callable, that is to be registered as parser’s state
name (str, optional) – name under which the callable should be registered; defaults to callable.__name__
trigger (str, optional) – string with regular expression, that will be compiled with re module
- Returns
callable object registered as state
- Return type
Callable
- remove_state(name: str)
Removes the state from parser’s registered states.
- Parameters
name (str) – name of state, that should be unregistered
- Raises
InvalidStateError – if no callable was registered under the name ‘name’
- static state(state=None, trigger=None)
Convenience decorator for registering a method as parser’s state. It can be with or without ‘trigger’ parameter, like this:
>>> @ParserBase.state ... def method(self, arg): pass
or
>>> @ParserBase.state(trigger='triggering regex') ... def method(self, arg): pass
This function marks a method state as parser’s state by defining
is_stateattribute on said method and setting its values toTrue. If trigger is given, it is stored in method’s attribute trigger. During instantiation ofParserBase’s subclass, methods marked as states are registered undermethod.__name__key in itsstates(and possiblytriggers) attribute. It is meaningless if used outside ofParserBase’s subclass definition.- Parameters
state (Callable) – callable, that is to be registered as parser’s state
trigger (str, optional) – string with regular expression, that will be compiled with re module
- Returns
callable object registered as state if ‘state’ was given or decorator if only ‘trigger’ was given
- Return type
Callable
- Raises
TypeError – if no arguments given
InvalidStateError – if state argument is not callable
- property workhorse: Callable
Callable marked as a current state used by parser object.
Setter can take a callable or a string as a parameter. If name as string is passed to setter, it will be translated to a method registered as state. If no method was registered under this name,
InvalidStateErrorwill be raised. No other checks are performed when argument is callable.