RRKM
Calculate unimolecular reaction rates using Rice-Rammsperger-Kassel-Marcus (RRKM) theory in Python.
The Graph Kinetic Monte Carlo simulator depends on reaction rates. The RRKM tool calculates these rates from the reactant density of states and transition-state sum of states:[1]
\[k(E) = \frac{\sigma N^\dagger(E-E_0)}{h\rho(E)}\]
The RRKM module is supplied with the GKMC repository in the tools/rrkm/ subdirectory. There is a Python API (rrkm.py) and command-line interface (CLI; rrkm_cli.py).
Contents
Command-line interface
Installation
See Additional tools > Installation for installation instructions.
Usage
Instructions for the command-line interface can be retrieved with:
uv run tools/rrkm_cli.py --helpThe CLI reads quantum-chemistry output files from --input-directory and writes JSON rate files to --output-directory. Both default to the current directory. The output directory is created when it does not exist.
For example:
uv run tools/rrkm_cli.py D 1 --destination 2 --type scramble \
--input-directory path/to/calculations \
--output-directory path/to/ratesThis writes D1to2.json to path/to/rates. For dissociation:
uv run tools/rrkm_cli.py D 1 --type dissociate \
--input-directory path/to/calculations \
--output-directory path/to/ratesThis writes D1diss.json to the output directory. Use --reverse to also write the reverse scrambling rate and --suffix to select a suffixed dissociation transition-state file.
How it works
The RRKM API provides two functions:
rrkm.scramble()calculates rates for isotope scrambling between two aliphatic sites.rrkm.dissociate()calculates rates for isotope dissociation from an aliphatic site.
Both functions return a dictionary that follows the ratefile.schema.json.
Input files
The functions read quantum-chemistry output files using cclib. Each file must contain vibrational frequencies, electronic energies, and zero-point vibrational energy. The calculation must have completed successfully.
The directory argument is the parent directory of the following layout:
For a scrambling reaction:
directory/
├── Stable/
│ ├── {isotope}{source}.log
│ └── {isotope}{destination}.log
└── TS/
└── {isotope}{source}to{destination}.logFor a dissociation reaction:
directory/
├── Stable/
│ └── {isotope}{source}.log
├── Dissociation/
│ └── {isotope}{source}diss{suffix}.log
└── {isotope}-Dissociated.logFor scrambling, the threshold is $E_0=E_\mathrm{TS}-E_\mathrm{reactant}$ and the reaction energy is $\Delta=E_\mathrm{product}-E_\mathrm{reactant}$. For dissociation, the threshold is calculated as $E_0=E_\mathrm{product}+E_\mathrm{atom}-E_\mathrm{reactant}$, where atom_energy_eV defaults to $-13.6\ \mathrm{eV}$. The dissociation reaction energy is reported as $\Delta=0$.
The reactant must have no imaginary frequencies, and the transition state must have exactly one. The imaginary transition-state mode is excluded automatically from the state-count calculation. Frequencies are scaled by scaling_factor before they are discretized.
Public API
scramble(isotope, source, destination, ...)
| Parameter | Type | Units | Default | Description |
|---|---|---|---|---|
isotope | str | - | Required | The isotope ("H" or "D") that is moving between aliphatic sites |
source | str/int | - | Required | The position of the isotope aliphatic site in the reactant |
destination | str/int | - | Required | The position of the isotope aliphatic site in the product |
reverse | bool | - | False | Whether to calculate the reverse direction using the same transition-state file |
directory | str | - | "" | Parent directory containing the Stable/ and TS/ subdirectories |
scaling_factor | float | - | 0.97 | Scaling factor to correct vibrational frequencies for systemic quantum-chemical overestimation |
energy_grain_eV | float | eV | 0.001 | Step size of the energy grid for which the rates are calculated |
energy_max_eV | float | eV | 30 | Upper bound of the energy grid which runs from 0 to energy_max_eV in steps of energy_grain_eV |
Returns:
A dict containing:
| Key | Type | Units | Description |
|---|---|---|---|
reactionId | str | - | Reaction identifier |
reactionType | str | - | Reaction type ("scramble") |
scaling_factor | float | - | Frequency scaling factor |
E0 | float | eV | Reaction threshold energy |
Delta | float | eV | Reaction energy change |
energy_eV | list[float] | eV | Energy grid |
rate_s_inv | list[float] | $\text{s}^{-1}$ | Rate at each energy-grid point |
The energy_eV and rate_s_inv lists have equal lengths.
Raises:
ValueErrorifisotopeis not"H"or"D".ValueErrorif a log file is missing required data.ValueErrorif a quantum-chemistry calculation was unsuccessful.ValueErrorif energies or frequencies are non-finite.ValueErrorif the starting structure has imaginary frequencies.ValueErrorif the transition state does not have exactly one imaginary frequency.ValueErrorif the threshold energy is negative or non-finite.ValueErrorifscaling_factor,energy_grain_eV, orenergy_max_eVis invalid.ValueErrorif a frequency rounds to zero energy quanta.OverflowErrorif the state counts overflow.FloatingPointErrorif calculated rates are non-finite or negative.
dissociate(isotope, source, ...)
| Parameter | Type | Units | Default | Description |
|---|---|---|---|---|
isotope | str | - | Required | The isotope (H or D) that is dissociating from the aliphatic site |
source | str/int | - | Required | The position of the isotope aliphatic site in the reactant |
directory | str | - | "" | Parent directory containing the Stable/ and Dissociation/ subdirectories and dissociated product file |
scaling_factor | float | - | 0.97 | Scaling factor to correct vibrational frequencies for systemic quantum-chemical overestimation |
energy_grain_eV | float | eV | 0.001 | Step size of the energy grid for which the rates are calculated |
energy_max_eV | float | eV | 30 | Upper bound of the energy grid which runs from 0 to energy_max_eV in steps of energy_grain_eV |
suffix | str | - | "" | Suffix appended to the transition-state filename |
atom_energy_eV | float | eV | -13.6 | Energy assigned to the dissociated atom |
transition_state | str | - | None | Transition state file to use instead of {isotope}diss{suffix} |
Returns the same rate-file dictionary as scramble(), with "reactionType": "dissociate" and "Delta": 0.0. Raises the same calculation errors as scramble().
- 1Baer, T. & Mayer, P. M. J. Am. Soc. Mass Spectrom. 8, 103–115 (1997). DOI: 10.1016/S1044-0305(96)00212-7