pyspectools.qchem package

Submodules

pyspectools.qchem.analysis module

class pyspectools.qchem.analysis.CalculationResult(A: float = 0.0, B: float = 0.0, C: float = 0.0, success: bool = False, u_A: float = 0.0, u_B: float = 0.0, u_C: float = 0.0, id: int = 0, formula: str = '', smi: str = '', program: str = '', point_group: str = 'C1', method: str = '', basis: str = '', charge: int = 0, multi: int = 1, kappa: float = 0.0, DJ: float = 0.0, DJK: float = 0.0, DK: float = 0.0, delJ: float = 0.0, delK: float = 0.0, Iaa: float = 0.0, Ibb: float = 0.0, Icc: float = 0.0, defect: float = 0.0, scf: float = 0.0, cc: float = 0.0, correlation: float = 0.0, dboc: float = 0.0, rel: float = 0.0, coords: str = '', zpe: float = 0.0, anharm_zpe: float = 0.0, elec_zpe: float = 0.0, composite: float = 0.0, ts: bool = False, harm_freq: List[float] = <factory>, harm_int: List[float] = <factory>, harm_sym: List[str] = <factory>, anharm_freq: List[float] = <factory>, anharm_int: List[float] = <factory>, anharm_dipole: List[float] = <factory>, thermo_corrections: Dict = <factory>, alphas: List[float] = <factory>, G3: Dict = <factory>, opt_delta: float = 0.0, type: str = 'scf', filename: str = '', image_path: str = '')[source]

Bases: object

Class for handling individual calculations. The idea behind this class is to be as general as possible, handling the data that get parsed out by specific program parsers defined in qchem.parsers.

A: float = 0.0
B: float = 0.0
C: float = 0.0
DJ: float = 0.0
DJK: float = 0.0
DK: float = 0.0
G3: Dict
Iaa: float = 0.0
Ibb: float = 0.0
Icc: float = 0.0
alphas: List[float]
anharm_dipole: List[float]
anharm_freq: List[float]
anharm_int: List[float]
anharm_zpe: float = 0.0
basis: str = ''
cc: float = 0.0
charge: int = 0
composite: float = 0.0
coords: str = ''
correlation: float = 0.0
dboc: float = 0.0
defect: float = 0.0
delJ: float = 0.0
delK: float = 0.0
elec_zpe: float = 0.0
filename: str = ''
formula: str = ''
classmethod from_g16(filepath, parser=<function parse_g16>)[source]

Class method for parsing a Gaussian logfile, and converting the dictionary into a Calculation class.

Parameters

- str (filepath) – Filepath to the Gaussian output file.

Returns

Calculation object with the parsed Gaussian output.

Return type

Calculation - object

classmethod from_yml(filepath)[source]

Class method for reading in a YAML calculation dump created with the to_yml method.

Parameters

- str (filepath) – Filepath to the YAML file.

Returns

Instance of the Calculation object from parsing the YAML file.

Return type

Calculation - object

harm_freq: List[float]
harm_int: List[float]
harm_sym: List[str]
id: int = 0
image_path: str = ''
kappa: float = 0.0
method: str = ''
multi: int = 1
opt_delta: float = 0.0
point_group: str = 'C1'
program: str = ''
rel: float = 0.0
scf: float = 0.0
smi: str = ''
success: bool = False
thermo_corrections: Dict
to_multiwell(state='reac', comment='', delh=0.0)[source]

Convert the parsed results into Multiwell format. Wraps the function from the multiwell module, format_multiwell.

Parameters
  • state (str, optional) – Specify which part of the reaction this structure is.

  • comment (str, optional) – Comment line for the structure

  • delh (float, optional) – The 0 K heat of formation, or relative energy of this point in the units specified in the multiwell input file (usually kJ/mol)

Returns

mw_str – String containing the formatted output

Return type

str

to_png()[source]

Generate a PNG file by dumping the SMI to a temporary folder, converting, and copying back to the current working directory using obabel.

to_xyz()[source]
to_yml(filepath)[source]

Function to dump the Calculation to disk in YAML syntax.

Parameters

- str (filepath) – Filepath to the YAML file target.

ts: bool = False
type: str = 'scf'
u_A: float = 0.0
u_B: float = 0.0
u_C: float = 0.0
zpe: float = 0.0
class pyspectools.qchem.analysis.CalculationSet(paths: List[str] = <factory>, species: List = <factory>, total_energy: float = 0.0, atoms: str = '', energies: numpy.array = array([], dtype=float64), converted_energies: numpy.array = array([], dtype=float64), relative_energies: numpy.array = array([], dtype=float64), calculations: Dict = <factory>, products: List = <factory>, reactants: List = <factory>)[source]

Bases: object

A master handler of a set of calculations. This class works in two ways: to manage a bunch of calculations that together yield a closed set of thermochemistry, or a set of calculations that sum up to a single composite value.

atoms: str = ''
calculations: Dict
compare_energies(index=None, level='composite', conversion=None)[source]
converted_energies: numpy.array = array([], dtype=float64)
copy_species(indexes)[source]

Spawn a copy of the CalculationSet, only with the specified species in the set.

Parameters

indexes (list of int) – A list of indexes, corresponding to the species to be kept in the new copy

Returns

A deepcopy of this CalculationSet with only the specified species

Return type

new_instance

create_pes(width=5.0, x=None, **kwargs)[source]

Create a :param width: :param x: :param kwargs:

create_portrait(**kwargs)[source]

Create a collage of 2D depictions of each of the species within this set of data. Uses matplotlib imshow to show the images inline in a Jupyter notebook.

Parameters

kwargs – Additional keywords are passed to the subplots generation

Returns

Matplotlib figure and axis arrays

Return type

fig, axarray

energies: numpy.array = array([], dtype=float64)
eval_formula()[source]
classmethod from_folder(path, extension='log', program='g16')[source]
classmethod from_pkl(filepath)[source]
paths: List[str]
products: List
reactants: List
relative_energies: numpy.array = array([], dtype=float64)
save(filepath)[source]

Dump the current CalculationSet to disk as a pickle file.

Parameters

filepath (str) – Path to the file you wish to save to.

species: List
sum_energies(level='composite')[source]

Calculates the total energy of all the species in this CalculationSet.

Parameters

level (str) – Specifies the level of theory to make the comparison.

Returns

total_energy – The total energy in Hartrees

Return type

float

total_energy: float = 0.0

pyspectools.qchem.extrapolation module

extrapolation.py

Routines for performing SCF and correlation extrapolation.

pyspectools.qchem.extrapolation.exponential(x, a, b, cbs)[source]
pyspectools.qchem.extrapolation.extrapolate_SCF(energies, basis)[source]
pyspectools.qchem.extrapolation.extrapolate_correlation(energies, basis)[source]

Extrapolate the correlation energy to the CBS limit. Args: energies and basis are same length tuple-like, with the former corresponding to the correlation (post-SCF) energy and basis the cardinal values Returns: the extrapolated energy, and the results of the fit.

pyspectools.qchem.extrapolation.linear(x, a, cbs)[source]

pyspectools.qchem.heat_analysis module

heat_analysis.py

Routines for performing batch analysis on HEAT345(Q) calculations. The scripts are hardcoded to follow the filestructure produced by the heat345.py scripts, i.e.

top/ |—heat345.py |—heat345.yaml |—zmat.yaml |—correlation/

|—AUG-PCVXZ/

|—calcY-correlation-AUG-PCVXZ.log

and so on.

pyspectools.qchem.heat_analysis.anal_correlation(data_dict)[source]

Function for extrapolating the correlation and SCF energies to the CBS limit using their respective schemes. Takes the full dictionary as input, and returns the SCF/CBS and CCSD(T)/CBS energies as floats

pyspectools.qchem.heat_analysis.anal_dboc(data_dict)[source]

Returns the DBOC value

pyspectools.qchem.heat_analysis.anal_hlc(data_dict)[source]

Function for analyzing the non-perturbative corrections to the triple excitations.

Takes the frozen-core CCSDT and CCSD(T) values at two basis and extrapolates them to the CBS limit.

The end result is the difference between CCSDT/CBS and CCSD(T)/CBS

This function returns the correction, as well as the dataframes holding the answers

pyspectools.qchem.heat_analysis.anal_mvd(data_dict)[source]

Function for parsing the MVD1 + MVD2 out of the raw data dictionary. Takes the full dictionary as input, and returns the relativistic contributions to the energy.

pyspectools.qchem.heat_analysis.anal_q(data_dict)[source]

Try and get the CCSDT(Q) energy

pyspectools.qchem.heat_analysis.anal_zpe(data_dict)[source]

Function for parsing the ZPE out of the raw data dictionary. Takes the full dictionary as input, and returns the ZPE.

pyspectools.qchem.heat_analysis.analysis_lookup(method)[source]

Returns the function associated with the string based name of a function.

pyspectools.qchem.heat_analysis.analyze_molecule(mol_name, directory, methods=None)[source]

Automate analysis of a molecule by pointing to a directory containing all of the relevant calculations, as well as providing an identifier.

Optional argument is to specify what contributions to include in the calculation

Returns a dataframe containing the energy breakdown.

pyspectools.qchem.heat_analysis.calc_enthalpy(dataframe, reactants, products)[source]
pyspectools.qchem.heat_analysis.calc_reaction(dataframe, reactants, products, reactions)[source]
pyspectools.qchem.heat_analysis.check_analysis(analysis_dict, logger)[source]

Function for performing small sanity checks on the analysis results. Basic idea is to do some value comparisons to make sure the extrapolations have been performed sensibily. Args: dictionary containing the analysis values and a reference to the logger object used for debugging. The function will only print bad flags.

pyspectools.qchem.heat_analysis.get_hot(dataframe, species)[source]
pyspectools.qchem.heat_analysis.heat_analysis(mol_name, data_dict, methods=None, logger=None)[source]

Main driver function for analyzing HEAT contributions.

This version has been written to be completely modular with respect to the contributions that it can take.

Loops through a list of analysis functions and spits out a dataframe containing all of the resulting analysis.

pyspectools.qchem.heat_analysis.init_logger(log_name)[source]

Use logging module to provide debug data for HEAT analysis. All of the extraneous data (e.g. extraplation coefficients, etc) will be output with the logger.

Required input is the name of the log file including file extension. Returns a logger object.

pyspectools.qchem.heat_analysis.match_basis(basis)[source]

Converts a string representations of basis angular momenta to the cardinal number

pyspectools.qchem.heat_analysis.read_heat(dir_path)[source]

Function to parse in all of the calculations that consist of the HEAT scheme. Args: dir_path, path to top directory of the HEAT calculation which would end with the calcID

Returns a dictionary containing all of the parsed logfiles

pyspectools.qchem.heat_analysis.relative_energies(df, base, molecules)[source]

pyspectools.qchem.multiwell module

Scripts to perform rate calculations using Multiwell. The focus here is to take output from a pseudo-variational calculation performed using CFOUR, format the results (e.g. constants, frequencies, etc.) into ktools format

class pyspectools.qchem.multiwell.Species(mominert_str, name, parsed_data, species_type, dist, delh=0.0)[source]

Bases: object

calc_mominert()[source]
call_mominert()[source]
determine_rot(mode_num)[source]
format_dof()[source]
format_species()[source]
get_formula()[source]
class pyspectools.qchem.multiwell.Vtst(calc_root, reaction, ktools_yml_path)[source]

Bases: object

Class that handles a VTST calculation. This class is mainly designed for filepath handling, since the multiwell programs are extremely annoying about relative paths…

analyze_tst()[source]

Analysis function for transition state RRKM More or less the same as the VTST version, but simpler

analyze_vtst()[source]

Main analysis function Loops over all of the log files detected in __init__ and produces ktools input file format strings

call_ktools(inp_path)[source]
dump_ktools()[source]
init_ktools()[source]
temps

Set up paths management

classmethod tst_calc(data_dict, reaction, ktools_yml_path)[source]

Serialization method for conventional TST calculations using ktools.

The required inputs are: data_dict - dictionary holding paths to output files, with the keys corresponding to reactant, ts, product as well as reaction enthalpies reaction - str specification to name the reaction ktools_yml_path - path to ktools YAML input

format of data_dict should be like this: data_dict = {“reactant”: {“path”: , “E”}}

classmethod vtst_calc(calc_root, reaction, ktools_yml_path)[source]

Serialization method specifically for VTST calculations using ktools.

The required inputs are: calc_root - path to root of the calculation directory reaction - str specification to name the reaction ktools_yml_path - path to ktools YAML input

pyspectools.qchem.multiwell.fit_arrhenius(canonical_df, guess=None)[source]

Function to fit a modified Arrhenius rate model to a dataframe containing canonical rates extracted from the parse_canonical routine

pyspectools.qchem.multiwell.format_multiwell(molecule, state='reac', comment='', delh=0.0)[source]

Convert the output of an electronic structure program into the form used for a lot of the Multiwell programs; specifically for thermo.

Takes the parsed output as a dictionary, and the user can specify what state the structure is (e.g. reac, ctst, or prod).

Parameters
  • molecule (dict) – Dictionary containing parsed output from electronic structure programs. The format is that generated by the CalculationResult class.

  • state (str, optional) – Specify which part of the reaction this structure is.

  • comment (str, optional) – Comment line for the structure

  • delh (float, optional) – The 0 K heat of formation, or relative energy of this point in the units specified in the multiwell input file (usually kJ/mol)

Returns

mw_str – String containing the formatted output

Return type

str

pyspectools.qchem.multiwell.init_logger(log_name)[source]

Use logging module to provide debug data for HEAT analysis. All of the extraneous data (e.g. extraplation coefficients, etc) will be output with the logger.

Required input is the name of the log file including file extension. Returns a logger object.

pyspectools.qchem.multiwell.mod_arrhenius(T, a, b, g)[source]
pyspectools.qchem.multiwell.parse_canonical(filecontents)[source]

Function to parse data out of a .canonical file from ktools Returns a dataframe containing the recommended thermal rate constants along with the temperature and inverse temperature.

pyspectools.qchem.multiwell.parse_ktools(ktoolslog_path)[source]

ktools_path corresponds to the logfile for the ktools calculation.

The routine will parse canonical rate constants from the file with extension .canonical, and J-resolved microcanonical constants from .kej

pyspectools.qchem.multiwell.parse_mominert(momout_path)[source]

pyspectools.qchem.parsers module

parsers.py

This module contains routines for parsing data out of electronic structure outputs. Everything will be centered around a Calculation dataclass, with specific parsing methods written for each program. The result should be a homogenized Pythonization of calculations, regardless of program used.

pyspectools.qchem.parsers.parseG3(filepath)[source]

Function for parsing a G3 calculation from a Gaussian output file. This function does not generate an object, and instead returns all of the data as a dictionary.

Parameters

- str (filepath) – Filepath to the G3 Gaussian output file.

Returns

Dictionary containing the G3 output

Return type

results - dict

pyspectools.qchem.parsers.parseW1(filepath)[source]
pyspectools.qchem.parsers.parse_cfour(filepath)[source]
pyspectools.qchem.parsers.parse_g16(filepath)[source]

Parse in the output of a Gaussian 16 calculation. To optimize the output format, make sure the calculation route includes the Output=Pickett keyword, which ensures the coordinates are actually in the principal axis orientation.

Parameters

- str (filepath) – Filepath to Gaussian logfile

pyspectools.qchem.utils module

Contains all of the auxillary functions for CFOURviewer; i.e. file I/O, storage to HDF5, copying and pasting, etc.

The scope of HDF5 will be to store the parsed data, as well as the full output file as a string.

Settings will be stored in a dot folder in the user’s home directory; this includes templates for the PBS script as well as CFOURviewer settings.

pyspectools.qchem.utils.clean_string(string)[source]
pyspectools.qchem.utils.obabel_png(filepath, format='xyz')[source]

Call open-babel to convert a obabel readable format file into a PNG. The conversion requires that obabel linked to libcairo, and will dump the image in the current working directory.

Parameters

filepath (str) – Filepath to the target file

pyspectools.qchem.utils.obabel_smi(filepath, format='xyz')[source]
pyspectools.qchem.utils.obabel_xyz(filepath, format='g09')[source]

Call open-babel to convert a specified file into an XYZ.

Parameters
  • filepath (str) – Filepath to save the XYZ file to. Extension is not mandated, but can be included.

  • format (str) – File format to convert from. Must be supported by open-babel

pyspectools.qchem.utils.split_zmat(zmat_list)[source]

Function that will convert a ZMAT into a dictionary.

Module contents