rdmc.external.logparser.base#
- class rdmc.external.logparser.base.BaseLog(path: str, job_type: list | None = None, ts: bool | None = None)#
Bases:
object
The base class helps to parse the log files and provides information helpful to analyze the calculation.
- auto_update_prop()#
A decorator to update the property automatically.
- Parameters:
update_fun (str) – The method name for the update function.
Examples
This decorator can be used as follows:
@property @auto_update_prop('update_prop1') def prop1(self): "docstring for prop1" def update_prop1(self): # define how to get the value of prop1 # and set the value to self._prop1
- property finished#
- property is_ts#
- property job_type#
- opt_criteria = []#
- require_job_type()#
A decorator to check the job type.
- require_ts()#
A decorator to check if the job involves ts.
- property schemes#
- property success#
- property termination_time#
- time_regex = ''#
- class rdmc.external.logparser.base.CclibLog(path: str, job_type: list | None = None, ts: bool | None = None)#
Bases:
BaseLog
This class parses the log files using cclib.
- property all_geometries#
Return all geometries in the file as a numpy array.
- Returns:
np.ndarray
- property cclib_results#
Get the cclib results.
- property charge#
The charge of the molecule.
- Returns:
int
- property converged_geometries#
Return converged geometries as a numpy array.
- Returns:
np.ndarray
- property freqs#
Return the frequency as a numpy array.
- get_best_opt_geom(*args, **kwargs)#
- get_converged_geom_idx(as_numbers: bool = False)#
Return the indexes of geometries that are converged. By default, a numpy array of True and False will be returned. But you can output numeric results by changing the argument.
- Parameters:
as_numbers (bool) – Whether returns a list of numbers. Defaults to
False
for better performance.- Returns:
np.array
- get_irc_midpoint(*args, **kwargs)#
- get_lowest_e_geometry(as_xyz: bool = False)#
Get the geometry with the lowest energy in a job. By default its ID is returned.
- Parameters:
as_xyz (bool) – if
True
, the xyz str is returned rather than ID.- Returns:
- int – the ID of the conformer
- str – the XYZ of the conformer
- get_mol(refid: int = -1, embed_conformers: bool = True, converged: bool = True, neglect_spin: bool = True, backend: str = 'openbabel', sanitize: bool | None = None) RDKitMol #
Perceive the xyzs in the file, create a
rdmc.mol.RDKitMol()
and convert the geometries to its conformers.- Parameters:
refid (int) –
The conformer ID in the log file to be used as the reference for mol perception. Defaults to
-1
, meaning it is determined by the following criteria:For opt, it is the last geometry if succeeded; otherwise, the initial geometry;
For freq, it is the geometry input;
For scan, it is the geometry input;
For IRC, uses the initial geometry if bidirectional job; uses the last converged geometry if uni-directional job.
embed_confs (bool) – Whether to embed intermediate conformers in the file to the obtained molecule. Defaults to
True
. To be clear, at least one conformer will be included in obtained mol, and its geometry is determined byrefid
.converged (bool) – Whether to only embed converged conformers to the obtained molecule. This option is only valid when
embed_confs
isTrue
.neglect_spin (bool) – Whether to neglect the error when spin multiplicity are different between the generated mol and the value in the output file. This can be useful for calculations involves TS. Defaults to
True
.backend (str) – The backend engine for parsing XYZ. Defaults to
'openbabel'
.sanitize (bool) – Whether to sanitize the generated molecule. Defaults to
True
. If a TS involved in the job, better to set itFalse
.
- Returns:
RDKitMol – a molecule generated from the output file.
- get_scannames(*args, **kwargs)#
- get_scanparams(*args, **kwargs)#
- get_scf_energies(converged: bool = True, only_opt: bool = False, relative: bool = False)#
Get SCF energies in kcal/mol.
- Parameters:
converged (bool) – Only get the SCF energies for converged geometries.’ Defaults to
True
.only_opt (bool) – For composite method like CBS-QB3, you can choose only to return SCF energies only for the optimization step. Defaults to
False
.relative (bool) – Only return the value relative to the minimum. Defaults to
False
.
- Returns:
np.array – The SCF energies.
- get_xyzs(converged: bool = True, initial_geom: bool = True)#
Get the xyz strings of geometries stored in the output file.
- Parameters:
converged (bool) – Only return the xyz strings for converged molecules. Defaults to True.
initial_geom (bool) – By default cclib_results will replace the geometry 1 (index 0) with the converged geometry. This options allows to keep the geometry 1 as the input geometry. Defaults to True.
- guess_rxn_from_irc(*args, **kwargs)#
- guess_rxn_from_normal_mode(amplitude: float = 0.25, atom_weighted: bool = False, inverse: bool = False, backend: str = 'openbabel')#
Guess the reactants and products from the mode of the imaginary frequency. Note: this result is not deterministic depending on the amplitude you use.
- Parameters:
amplitude (int) – The amplitude factor on the displacement matrix to generate the guess geometry for the reactant and the product. A smaller factor makes the geometry close to the TS, while a wildly large factor makes the geometry nonphysical. Can be either a float or a list of floats.
atom_weighted (bool) – If use the sqrt(atom mass) as a scaling factor to the displacement. The concern is that light atoms (e.g., H) tend to have larger motions than heavier atoms.
inverse (bool) – Inverse the direction of the reaction. Defaults to
False
.backend (str) – The backend engine for parsing XYZ. Defaults to
'openbabel'
.
- property initial_geometry#
Return the initial geometry of the job. For scan jobs and ircs jobs. Intermediate guesses will not be returned.
- interact_freq(**kwargs) ipywidget.interact #
Create a IPython interactive widget to investigate the frequency calculation.
- interact_irc(sanitize: bool = False, converged: bool = True, backend: str = 'openbabel', bothway: bool = False, continuous_update: bool = False, **kwargs)#
Create a IPython interactive widget to investigate the IRC results.
- Parameters:
sanitize (bool) – Whether to sanitize the molecule. Defaults to
False
.converged (bool) – Whether to only embed converged conformers to the mol. Defaults to
True
.backend (str) – The backend engine for parsing XYZ. Defaults to
'openbabel'
.continuous_update (bool) – Whether to update the widget continuously. Defaults to
False
.
- Returns:
interact
- interact_opt(sanitize: bool = True, backend: str = 'openbabel', continuous_update: bool = False, **kwargs) ipywidgets.interact #
Create a IPython interactive widget to investigate the optimization convergence.
- Parameters:
sanitize (bool, optional) – Whether to sanitize the molecule. Defaults to True.
backend (str) – The backend engine for parsing XYZ. Defaults to
'openbabel'
.continuous_update (bool) – Whether to update the widget continuously. Defaults to
False
.
- Returns:
interact
- interact_scan(*args, **kwargs)#
- property multiplicity#
Get the multiplicity.
- Returns:
int
- property neg_freqs#
Return the imaginary frequency as a numpy array.
- property num_all_geoms#
Return the number of all geometries.
- Returns:
int
- property num_converged_geoms#
Return the number of converged geometries. Useful in IRC and SCAN jobs.
- Returns:
int
- property num_neg_freqs#
Return the number of imaginary frequencies.
- Returns:
int
- property opt_convergence#
- property optstatus#
Return the geometry optimization status
- plot_irc_energies(converged: bool = True, relative: bool = True, highlight_index: int | None = None, ax: matplotlib.pyplot.axes = None)#
Plot the energy curve for the IRC trajectory. Note, the sequence may be altered if the IRC is a two-way calculation.
- Parameters:
converged (bool) – If only returns energies for converged geometries. Defaults to
True
.relative (bool) – If plot relative values (to the highest values). Defaults to
True
.highlight_index (int) – highlight the data corresponding to the given index.
ax (axes) – An existing matplotlib axes instance.
- plot_opt_convergence(logy: bool = True, relative: bool = True, highlight_index: int | None = None, ax=None)#
Plot the convergence curve from the convergence table.
- Parameters:
logy (bool) – If using log scale for the y axis. Defaults to
True
.relative (bool) – If plot relative values (to the target values). Defaults to
True
.highlight_index (int) – highlight the data corresponding to the given index.
() (ax) –
- plot_scan_energies(converged: bool = True, relative_x: bool = True, relative_y: bool = True, highlight_index: int | None = None, ax: matplotlib.pyplot.axes = None, draw_fit: bool = True)#
Plot the energy curve for the scan trajectory.
- Parameters:
converged (bool) – If only returns energies for converged geometries. Defaults to
True
.relative_x (bool) – If plot relative values (to the initial values). Only valid for scan trajectories. Defaults to
True
.relative_y (bool) – If plot relative values (to the lowest values). Defaults to
True
.highlight_index (int) – Highlight the data corresponding to the given index. Defaults to None, no hightlighting.
ax (axes) – Draw on an existing matplotlib axes instance. Defaults to None, creating a new axes.
draw_fit (bool, optional) – Whether to draw a Fouries series fitted to the energies. Only valid for dihedral scans. It will be drawn as an orange dotted curve. Defaults to True.
- view_freq(mode_idx: int = 0, frames: int = 10, amplitude: float = 1.0, *args, **kwargs) py3Dmol.view #
Create a Py3DMol viewer for the frequency mode.
- Parameters:
mode_idx (int) – The index of the frequency mode to display. Defaults to 0.
frames (int) – The number of frames of the animation. The larger the value, the slower the change of the animation. Defaults to 10.
amplitude (float) – The magnitude of the mode change. Defaults to 1.0.
- Returns:
interact
- view_mol(backend: str = 'openbabel', sanitize: bool = False, *args, **kwargs) py3Dmol.view #
Create a Py3DMol viewer for the molecule. By default, it will shows either the initial geometry or the converged geometry depending on what job type involved in the file.
- Parameters:
backend (str) – The backend engine for parsing XYZ. Defaults to
'openbabel'
.sanitize (bool) – Whether to sanitize the generated mol. Defaults to False.
- view_traj(align_scan: bool = True, align_frag_idx: int = 1, backend: str = 'openbabel', converged: bool = True, **kwargs) py3Dmol.view #
View the trajectory as a Py3DMol animation.
- Parameters:
align_scan (bool) – If align the molecule to make the animation cleaner. Defaults to
True
align_frag_idx (int) – Value should be either 1 or 2. Assign which of the part to be aligned. Defaults to
1
.backend (str) – The backend engine for parsing XYZ. Defaults to
'openbabel'
.