alchemrs is a CLI-first tool for alchemical free energy analysis. The workspace includes the alchemrs command-line binary, a Rust library crate, and a local Python package backed by the alchemrs-py extension crate. The CLI covers parsing AMBER and GROMACS outputs, preprocessing time series, running TI/BAR/MBAR/IEXP/DEXP/NES estimators, and computing diagnostics such as overlap analysis and schedule advice. The library and Python bindings also expose UWHAM and ATM analysis building blocks, plus OpenMM-oriented helpers and examples. Fixtures and tests compare results against established reference implementations (alchemlyb, pymbar, and R UWHAM) to keep the numerical behavior grounded.
Native SVG plotting is available as an optional plotting feature.
The alchemrs binary is the primary entry point. Top-level commands are advise-schedule, ti, bar, mbar, nes, iexp, and dexp. Don't see your favorite estimator here? Submit an issue and I'd be happy to add it!
Pre-built binaries for tagged releases can be found at https://github.com/helmutcarter/alchemrs/releases.
If you want the current source version, or to compile it for your machine:
First, clone this repo
git clone https://github.com/helmutcarter/alchemrs.git
cd alchemrsthen you can either automatically compile and run the binary through cargo:
cargo run --release -- [command] [arguments]or compile using cargo and then call the binary:
cargo build --release
./target/release/alchemrs [command] [arguments]-
--threads <N>: set the Rayon worker-thread count for internal parallelism. -
--remove-burnin <N>: skip the firstNsamples in each window before analysis. -
--auto-equilibrate: usepymbar-style equilibration detection as described here. -
--decorrelate: subsample to reduce correlation before estimating.tiuses the parseddH/dlambdaseries.bar,iexp,dexp, andmbaruse the observable selected by--u-nk-observable <de|all|epot>.
-
--u-nk-observable <de|all|epot>: choose the scalar observable used foru_nkauto-equilibration and decorrelation onbar,iexp,dexp, andmbarruns. The default isde. -
--output-units <kt|kcal|kj>: output energy units (defaultkt). -
--output-format <text|json|csv>: output format for estimator results (defaulttext). -
--output <PATH>: write the formatted result to a file instead of stdout. -
--overlap-summary: include overlap scalar and overlap eigenvalues for BAR/IEXP/DEXP/MBAR runs. -
mbaruses the L-BFGS MBAR solver by default and automatically falls back to fixed-point for sparse sampled-count grids; pass--fixed-point-mbarto force the fixed-point solver.
The CLI also includes a lambda-schedule advisor. For u_nk workflows it analyzes adjacent edges and reports whether the current schedule looks healthy, should be monitored, needs more sampling, or likely needs an inserted window. For TI workflows, pass --input-kind dhdl to switch the same command over to dH/dlambda-based spacing diagnostics. For AMBER nonequilibrium switching workflows, pass --input-kind nes to get a Jarzynski convergence report, plus lambda-resolved dV/dλ profile and curvature diagnostics from the switching trajectories.
alchemrs advise-schedule \
--decorrelate \
--u-nk-observable de \
--report schedule-report.html \
--output-format json \
/path/to/*/prod.outFull CLI usage is documented in docs/src/cli.md.
The top-level alchemrs crate re-exports the common parse, prep, estimator, and analysis entry points used by the CLI and available for direct Rust integration:
use alchemrs::{
decorrelate_u_nk_with_observable, extract_u_nk_with_potential, DecorrelationOptions,
MbarEstimator, MbarOptions,
};
let (u_nk, epot) = extract_u_nk_with_potential("prod.out", 300.0)?;
let u_nk = decorrelate_u_nk_with_observable(&u_nk, &epot, &DecorrelationOptions::default())?;
let fit = MbarEstimator::new(MbarOptions::default()).fit(&[u_nk])?;
let result = fit.result_with_uncertainty()?;
if let Some(labels) = fit.lambda_labels() {
println!("lambda components = {:?}", labels);
}MbarOptions::default() uses MbarSolver::Lbfgs. Set solver: MbarSolver::FixedPoint
when you need to reproduce older fixed-point results or compare solver behavior.
Use the Rust API when you need embedding, custom orchestration, or tighter control than the CLI exposes. The repo also includes runnable top-level examples:
cargo run --example amber_ti -- 300 path/to/lambda0.out path/to/lambda1.outcargo run --example amber_mbar -- 300 path/to/lambda0.out path/to/lambda1.out path/to/lambda2.outcargo run --example openmm_u_kln_mbarcargo run --example export_uwham_reference -- ./target/uwham-reference
The OpenMM example shows how to convert a tutorial-style u_kln[k][l][n]
tensor of reduced potentials into UNkMatrix windows for direct MBAR analysis.
Library-only estimators currently include:
UwhamEstimatorfor pooled equilibrium-window analysis fromUNkMatrixAtmEstimatorfor ATM leg and paired binding analysis overAtmLogQMatrixorAtmSampleSet
The repository also includes a local Python package configured by pyproject.toml
and backed by the alchemrs-py extension crate.
Build and install it into the active Python environment with:
maturin developThere are also runnable Python/OpenMM toy-system examples under python/examples:
python/examples/amber_fixture_analysis.pypython/examples/atm_analysis.pypython/examples/openmm_u_kln_mbar.pypython/examples/openmm_nes.pypython/examples/openmm_atm.py
Python tests can be run with:
python -m pytest python/tests -qThe OpenMM examples additionally require openmm.
Optional plotting helpers can be enabled with:
cargo build --features plotting --releaseFor multidimensional GROMACS schedules, the parsed UNkMatrix, estimator DeltaFMatrix, and OverlapMatrix all preserve parser-derived lambda component names when available through .lambda_labels().
The CLI also includes a lambda-schedule advisor. For u_nk workflows it analyzes adjacent edges and reports whether the current schedule looks healthy, should be monitored, needs more sampling, or likely needs an inserted window. For TI workflows, pass --input-kind dhdl to switch the same command over to dH/dlambda-based spacing diagnostics. For AMBER nonequilibrium switching trajectories, pass --input-kind nes.
alchemrs advise-schedule \
--decorrelate \
--u-nk-observable de \
--report schedule-report.html \
--output-format json \
/path/to/*/prod.outUseful advisor-specific flags:
--estimator <mbar|bar>--input-kind <auto|u-nk|dhdl|nes>--overlap-min <VALUE>--block-cv-min <VALUE>--n-blocks <N>--no-midpoints--report <PATH>
For TI spacing diagnostics:
alchemrs advise-schedule \
--input-kind dhdl \
--decorrelate \
--report ti-schedule-report.html \
--output-format json \
/path/to/*/prod.outThe JSON output includes sample_counts, provenance, and suggestions, plus either edges for u_nk mode or windows and intervals for TI mode. u_nk edge diagnostics include neighbor-relative metrics, dominant changing components, and a priority score. TI interval diagnostics include mean_dhdl, slope, curvature, interval_uncertainty, and block-stability summaries. When --report is provided, the CLI also writes a standalone HTML report; the u_nk report includes the full SVG lambda-axis and multidimensional component breakdown, while the TI report also includes an integration-method shape gallery showing the applicable TI interpolants on the current lambda grid.
In NES mode, the structured output includes convergence, profile, curvature, high_curvature_regions, relative_uncertainty, recent_change, and the final suggestion. The HTML report adds:
- a free energy vs. number of switches scatterplot
- a TI-style mean
dV/dλprofile along the switching path - a TI-style curvature-magnitude plot over lambda
- a ranked list of high-curvature lambda regions
CSV output is useful for quick ingestion into spreadsheets or tabular tools:
alchemrs bar \
--output-format csv \
/path/to/*/prod.outCSV columns include estimator parameters after the result fields:
delta_f,uncertainty,from_lambda,to_lambda,units,overlap_scalar,overlap_eigenvalues,estimator,temperature_k,decorrelate,remove_burnin,auto_equilibrate,fast,conservative,nskip,u_nk_observable,ti_method,ti_method_reason,lambda_components,windows,samples_in,samples_after_burnin,samples_kept
alchemrs ti \
--method trapezoidal \
--remove-burnin 125 \
/path/to/*/prod.outti supports --method <trapezoidal|simpson|cubic-spline|pchip|akima|gaussian-quadrature>.
For more on picking an integration method, see the docs.
To let the CLI choose a method automatically and record why it was selected:
alchemrs ti \
--method auto \
--output-format json \
/path/to/*/prod.outTI outputs now include ti_method and, for --method auto, ti_method_reason in provenance.
alchemrs bar \
--decorrelate \
/path/to/*/prod.outBAR reports adjacent-edge uncertainties from the implicit BAR root equation and propagates cumulative endpoint uncertainty with the neighboring-edge covariance induced by shared intermediate windows.
alchemrs mbar \
--decorrelate \
/path/to/*/prod.outMBAR uses the L-BFGS solver by default. To force the fixed-point solver:
alchemrs mbar \
--fixed-point-mbar \
--decorrelate \
/path/to/*/prod.outalchemrs iexp \
/path/to/*/prod.out
alchemrs dexp \
/path/to/*/prod.outIEXP reports FEP results in the forward direction, DEXP reports FEP results in the reverse direction. Their reported uncertainties come from a delta-method propagation of the Jarzynski weights with an unbiased finite-sample variance estimate.
alchemrs nes \
--temperature 300 \
/path/to/run_*/fwd.outnes parses AMBER nonequilibrium switching outputs, integrates the switching work from the final Summary of dvdl values ... block, and applies the Jarzynski equality. Analytic uncertainty is used by default and is computed from the trajectory-level Jarzynski weights with an unbiased finite-sample variance estimate; pass --n-bootstrap <N> to request bootstrap uncertainty instead, or --no-uncertainty to suppress it.
Documentation is online at https://helmutcarter.github.io/alchemrs/. The source files are in docs/ and can be viewed locally:
cargo install mdbook
mdbook serve docsThe repository includes fixture-backed comparisons against alchemlyb, pymbar,
and committed R UWHAM reference data under tests/ and fixtures/.
This project is licensed under either of
- MIT license (LICENSE-MIT)
- Apache License, Version 2.0 (LICENSE-APACHE)
Copyright (c) 2026 Helmut Carter