Variational committor, MFPT, rate-matrix, and KMC utilities for weighted trajectory data
Project description
committor-kmc
committor-kmc is a small Python library for estimating committors, MFPTs,
rate matrices, and kinetic Monte Carlo trajectories from weighted trajectory
data in collective-variable space.
The core workflow is:
- load weighted trajectory segments;
- estimate a local Kramers-Moyal diffusion tensor from short increments;
- build a variational Dirichlet form in a chosen basis;
- solve committor and MFPT boundary-value problems;
- assemble a CTMC rate matrix and run KMC/TPT diagnostics.
Install
Editable install from this repository:
cd committor_kmc
python -m pip install -e ".[test]"
For notebooks:
python -m pip install -e ".[notebooks,test]"
Minimal Example
import numpy as np
from committor_kmc import (
BoxState,
CosineTensorBasis,
build_dirichlet_model,
empirical_quadrature,
estimate_binned_diffusion,
load_lineage_dat_segments,
solve_committor,
transition_pairs,
)
domain = np.array([[-2.0, 2.0], [-1.5, 2.5]])
segments = load_lineage_dat_segments(
["lineage_0.dat", "lineage_1.dat", "lineage_2.dat", "lineage_3.dat"]
)
pairs = transition_pairs(segments, lag_steps=1, domain=domain)
diffusion = estimate_binned_diffusion(
pairs,
frame_interval=1.0,
bins=(64, 64),
domain=domain,
)
quad_points, quad_weights = empirical_quadrature(pairs, size=100_000, seed=0)
basis = CosineTensorBasis(domain, (12, 10))
model = build_dirichlet_model(quad_points, quad_weights, basis, diffusion)
A = BoxState([-1.2, -0.2], [-0.8, 0.2], name="A")
B = BoxState([-0.1, 1.4], [0.1, 1.6], name="B")
q = solve_committor(model, basis, A, B)
values = q.evaluate(basis, quad_points)
KMC Example
import numpy as np
from committor_kmc import (
gillespie,
mfpt_matrix,
sample_first_passage_times,
stationary_distribution,
tpt_reactive_flux,
)
K = np.array([
[-0.21, 0.10, 0.11],
[0.41, -0.81, 0.40],
[0.11, 0.10, -0.21],
])
pi = stationary_distribution(K)
tau = mfpt_matrix(K)
trajectory = gillespie(K, start_state=0, t_max=50_000, rng=np.random.default_rng(0))
fpts = sample_first_passage_times(K, 0, 1, n_samples=20_000)
tpt = tpt_reactive_flux(K, pi, source_state=0, sink_state=1)
The diagonal entries of K are negative by construction:
K[i, i] = -sum(K[i, j] for j != i)
Only off-diagonal entries are physical transition rates.
Repository Layout
src/committor_kmc/: reusable package code.scripts/alanine_dipeptide/: final alanine dipeptide analysis scripts.scripts/double_well/: final Muller-Brown/double-well analysis and KMC scripts.notebooks/: example notebooks.tests/: package tests.docs/: extended usage notes.
Large trajectory inputs and generated paper figures are kept outside the PyPI package.
Final Analysis Scripts
Alanine dipeptide:
python scripts/alanine_dipeptide/compute_committor.py
python scripts/alanine_dipeptide/compute_rates.py
Muller-Brown / double well:
python scripts/double_well/compute_committor.py
python scripts/double_well/compute_rates.py
python scripts/double_well/run_kmc.py
The rate scripts produce rate matrices and summaries. The double-well KMC script
uses the learned calibrated rate matrix produced by compute_rates.py.
Publishing
Publishing is handled by GitHub Actions:
.github/workflows/publish-pypi.yml
On every push to main, the workflow:
- installs the package with test dependencies;
- runs
pytest; - builds the source distribution and wheel;
- checks the distributions with Twine;
- publishes to PyPI via trusted publishing.
Configure PyPI trusted publishing for this repository and the pypi
environment in GitHub. PyPI does not allow re-uploading the same version, so
bump version in pyproject.toml before merging a new release to main.
For a local build/check without publishing:
python -m pip install -e ".[publish,test]"
python -m pytest
python -m build
python -m twine check dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file committor_kmc-0.1.0.tar.gz.
File metadata
- Download URL: committor_kmc-0.1.0.tar.gz
- Upload date:
- Size: 19.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60dab78b453ff47b24f48774af59ee005212e7668d373b11dd734bc4189fa803
|
|
| MD5 |
80beb9405ba2163608aed162f6341e38
|
|
| BLAKE2b-256 |
815cbfa12da53b2dddfe4c3ff9ce8373e7797dab6870f9e2a6619cbfce37024f
|
Provenance
The following attestation bundles were made for committor_kmc-0.1.0.tar.gz:
Publisher:
publish.yml on sripkunda/committor_kmc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
committor_kmc-0.1.0.tar.gz -
Subject digest:
60dab78b453ff47b24f48774af59ee005212e7668d373b11dd734bc4189fa803 - Sigstore transparency entry: 2130336591
- Sigstore integration time:
-
Permalink:
sripkunda/committor_kmc@da0506980129c5eed59cfe8e9e0f11f2776eaf55 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/sripkunda
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@da0506980129c5eed59cfe8e9e0f11f2776eaf55 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file committor_kmc-0.1.0-py3-none-any.whl.
File metadata
- Download URL: committor_kmc-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
378a9b0b502e19fae6e8ceff0fe445de1748aa625f84fd34478d95f46b4d7b54
|
|
| MD5 |
770ade752fee97f4692fdab5973c58e0
|
|
| BLAKE2b-256 |
263a010056a5b35fdb69902380f5922600019e082f04ba9d4df8cb4ec0716c58
|
Provenance
The following attestation bundles were made for committor_kmc-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on sripkunda/committor_kmc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
committor_kmc-0.1.0-py3-none-any.whl -
Subject digest:
378a9b0b502e19fae6e8ceff0fe445de1748aa625f84fd34478d95f46b4d7b54 - Sigstore transparency entry: 2130336765
- Sigstore integration time:
-
Permalink:
sripkunda/committor_kmc@da0506980129c5eed59cfe8e9e0f11f2776eaf55 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/sripkunda
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@da0506980129c5eed59cfe8e9e0f11f2776eaf55 -
Trigger Event:
workflow_dispatch
-
Statement type: