Skip to main content

A Python CLI toolkit for chemical reaction kinetics analysis

Project description

rxnkinetics

Python 3.8+ License: MIT

A Python CLI toolkit for chemical reaction kinetics analysis. Solve rate equations, fit experimental data, determine reaction orders, and perform Arrhenius analysis — all from the command line.

Features

Command Description
solve Simulate concentration–time profiles by solving d[X]/dt = −k[X]ⁿ numerically
fit Determine the rate constant k from experimental data via nonlinear least-squares fitting
order Test multiple candidate orders and rank by to identify the best-fit reaction order
halflife Calculate t₁/₂ for any reaction order (0, 1, 2, fractional)
arrhenius Compute activation energy Eₐ and pre-exponential factor A from temperature-dependent rate data
gasfit Analyze gas evolution kinetics — estimate V∞ and extract k via linearization

Installation

git clone https://github.com/emreyilmazcode/ReactionKinetics.git
cd ReactionKinetics
pip install -e .

After installation, rxnkinetics is available as a command:

rxnkinetics solve --order 1 --x0 1.0 --k 0.1 --t 50

Or run directly without installing:

python -m rxnkinetics.cli solve --order 1 --x0 1.0 --k 0.1 --t 50

Quick Start

Simulate a first-order decay

rxnkinetics solve --order 1 --x0 1.0 --k 0.1 --t 50
============================================
  REACTION KINETICS SIMULATION
============================================
  Reaction Order   : 1.0
  Initial [X]₀     : 1.0 M
  Rate Constant k  : 0.1
  Time Elapsed     : 50.0 s
--------------------------------------------
  → Remaining [X]  : 0.006738 M
  → Conversion     : 99.33 %
============================================

Fit rate constant from experimental data

rxnkinetics fit --file examples/first_order.csv --order 1

Determine reaction order automatically

rxnkinetics order --file examples/first_order.csv --plot

Calculate half-life

rxnkinetics halflife --order 1 --k 0.1
rxnkinetics halflife --order 2 --k 0.05 --x0 1.0

Arrhenius analysis

rxnkinetics arrhenius --file examples/arrhenius.csv

Gas volume kinetics

rxnkinetics gasfit --file examples/gas_volume.csv

Input Data Format

All commands expecting a --file argument use two-column CSV files:

Command Column 1 Column 2
fit, order Time (s) Concentration (M)
arrhenius Temperature (K) Rate constant (k)
gasfit Time Volume (mL)

Header rows are automatically detected and skipped.

Theory

Rate Law Integration

The tool numerically integrates the general rate law:

$$\frac{d[X]}{dt} = -k[X]^n$$

using scipy.integrate.odeint. Rate constant fitting uses scipy.optimize.curve_fit with the ODE solution as the model function.

Arrhenius Equation

Temperature dependence is analyzed via the linearized Arrhenius equation:

$$\ln k = \ln A - \frac{E_a}{RT}$$

A linear regression of ln(k) vs 1/T yields the activation energy Eₐ and pre-exponential factor A.

Half-Life Expressions

Order t₁/₂
0 [X]₀ / 2k
1 ln(2) / k
2 1 / (k[X]₀)
n (2ⁿ⁻¹ − 1) / [k(n−1)[X]₀ⁿ⁻¹]

Project Structure

ReactionKinetics/
├── rxnkinetics/
│   ├── __init__.py      # Package metadata
│   ├── core.py          # ODE solver, fitting, analysis functions
│   ├── cli.py           # Command-line interface
│   └── plotting.py      # Matplotlib visualization
├── examples/            # Sample CSV datasets
├── tests/               # Unit tests
├── setup.py             # Package configuration
├── requirements.txt
├── LICENSE
└── README.md

Running Tests

pip install pytest
pytest tests/ -v

Requirements

  • Python ≥ 3.8
  • NumPy ≥ 1.20
  • SciPy ≥ 1.7
  • Matplotlib ≥ 3.4

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rxnkinetics-1.0.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rxnkinetics-1.0.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file rxnkinetics-1.0.0.tar.gz.

File metadata

  • Download URL: rxnkinetics-1.0.0.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for rxnkinetics-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9e5109adedc054ceb7e9dc283986355b5e182b24d0d28ad10b30e2d77ddcc150
MD5 704946b90bca776d74e7c6c3dcb1accb
BLAKE2b-256 2902d75743e63b2ff2c590975ae713aef48ca1ff9cf9280d3423a1a24a21c195

See more details on using hashes here.

File details

Details for the file rxnkinetics-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: rxnkinetics-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for rxnkinetics-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ff4e8266558ce2236a7c8ca159cd7099736e624bf8411dd2e6751cafb318e6b
MD5 b5e8a21120a42e7e54006e1789c4a4b7
BLAKE2b-256 7a929784aa500a71308f4459c7e90adcf420a4d24313e681d9693869fa860fee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page