Skip to content

Kinetic Monte Carlo for reaction networks ​

The second half of the v2.x reactivity workflow is a stochastic solver for an elementary-step network. The existing kinetics module already evaluates HTST rates and integrates a deterministic microkinetic ODE; the new module propagates integer species counts with the Gillespie direct method.

Status. Implemented and exposed on the Rust, Python, WASM and CLI surfaces for an explicit network. Rule-based discovery that feeds it is documented in reaction networks; surface kMC is pending. See the v2.x roadmap.

Feature. alpha-reaction-network (included in alpha-v2).

Why kMC ​

A deterministic ODE is the right tool for large, well-mixed populations. A surface reaction, a small cluster or a catalytic site can have populations of a few molecules, where fluctuations and rare events matter. kMC samples the same master equation stochastically:

P(n,t)→P(n,t+τ),

with integer counts and a waiting time drawn from the total propensity.

Rates and propensities ​

Each irreversible step j has an HTST forward rate k_j. Its propensity is

aj=kj∏r(nrνrj),

where n_r is the count of reactant r and ν its stoichiometric coefficient. The binomial factor is the number of ways to choose the reacting molecules from the available population.

The total propensity is

a0=∑jaj.

The waiting time is

τ=−ln⁡ua0,u∼Uniform(0,1),

and the firing step is chosen with probability a_j / a_0.

Algorithm ​

  1. Evaluate every HTST rate at the requested temperature and pressure.
  2. Compute the propensity of every step from the current integer counts.
  3. Draw τ and the firing step.
  4. Subtract reactants, add products, record the event.
  5. Repeat until max_events or max_time_s.

Reversible chemistry is represented by two irreversible steps. The solver does not guess a reverse direction from a reaction free energy; that keeps the network explicit and auditable.

API ​

rust
use sci_form::kinetics::{ElementaryStep, ThermodynamicState};
use sci_form::kmc::{KmcConfig, KmcSpecies, KmcStep};
use sci_form::run_kinetic_monte_carlo;

let config = KmcConfig {
    species: vec![
        KmcSpecies { id: "A".into(), initial_count: 100 },
        KmcSpecies { id: "B".into(), initial_count: 0 },
    ],
    steps: vec![KmcStep {
        step: ElementaryStep {
            step_id: "A->B".into(),
            activation_free_energy_ev: 0.05,
            reaction_free_energy_ev: -0.1,
            prefactor_s_inv: Some(1.0e12),
        },
        reactants: vec![(0, 1)],
        products: vec![(1, 1)],
    }],
    state: ThermodynamicState { temperature_k: 500.0, pressure_bar: 1.0 },
    max_events: 10_000,
    max_time_s: 10.0,
    seed: 7,
    frame_stride: 100,
};

let result = run_kinetic_monte_carlo(&config)?;
println!("{} events, final A={}, B={}",
    result.events.len(), result.final_counts[0], result.final_counts[1]);

Output ​

TypeMeaning
KmcEventEvent index, time, firing step, propensity and counts
KmcFrameSampled time, event index, species and counts
KmcResultEvents, frames, final counts, final time, stop reason and notes

Time is in seconds, rates in s⁻¹ and counts are dimensionless integers.

Validation ​

GateObservableResult
Mass conservationA + B after irreversible conversionunchanged
High barrierEvents in a 1 ps windownone; stops on time
Binomial coefficientC(5,0), C(5,1), C(5,2), C(2,3)1, 5, 10, 0
Invalid species indexNetwork validationrejected
Curated networksGRI-Mech/NIST/JPL five-network set5/5 recovered (F126)
kMC vs mean-field ODEFive networks, 8 seeds0.11 % max error (F127)
Seed determinismSame-seed replay + depth/species caps0 violations (F128)
Barrier accuracyExperimental torsional/inversion barriersMAE 0.575 kcal/mol (F133)

Malformed configurations are input errors: Python raises ValueError for max_events=0, frame_stride=0, max_time_s<=0/NaN, empty species/steps, unknown species indices, zero coefficients and a non-positive/non-finite temperature or pressure. WASM returns the canonical {"error": "..."}.

F133 validates the barrier engine on torsional and inversion barriers; the bimolecular curated networks still use literature barriers as rule inputs.

Bindings ​

SurfaceEntry point
CLIsci-form kmc '<KmcConfig-json>'
WASMrun_kinetic_monte_carlo(config_json)
Pythonrun_kinetic_monte_carlo(config_json)

Python returns the JSON encoding of KmcResult.

Limitations ​

  • The network is supplied by the caller; automatic reaction discovery is not implemented yet.
  • Only irreversible steps are accepted. Encode reversible steps explicitly.
  • Counts are integers; fractional populations and continuous concentrations belong to the deterministic solver.
  • The propensity uses binomial consumption, not a continuum mass-action term.
  • There is no spatial resolution, diffusion or surface lattice. A site-based kMC is a follow-up.
  • The RNG is seeded and deterministic for a single thread; parallel trajectories need one seed per replica.

Next steps ​

  1. Add rule-based network generation from SMIRKS and graph transforms.
  2. Add site-based surface kMC with adsorption, desorption and diffusion.
  3. Add uncertainty propagation from the barrier distribution.
  4. Compare against the deterministic microkinetic solver in the fast-rate limit.
  5. Add a curated catalytic network benchmark.

Released under the MIT License.