GPU code for solving the MBAR equations with a Newton–WHAM hybrid (BU-MBAR), plus example drivers:
- a synthetic energy-overlap benchmark
- a solvated alanine-dipeptide parallel-tempering simulation
- scripts to reweight that trajectory and plot the
$\phi,\psi$ free-energy surface
The solver lives in newton_wham_gpu.py. It builds a WHAM initial guess on a GPU histogram, then Newton-solves the MBAR equations and refines the free energies.
- Python 3
- NumPy
- PyTorch with CUDA (
newton_wham_gpu.pysets the default device tocuda) - For
alanine.py: OpenMM, openmmtools - For
extract_dihedrals.py: MDAnalysis - For
plot_alanine.py: Matplotlib, SciPy, and a working LaTeX installation (text.usetex)
A GPU is required for the solver.
| File | Role |
|---|---|
newton_wham_gpu.py |
BU-MBAR solver. perform_iteration(energies, betas, ...) returns relative free energies |
synthetic_benchmark_bumbar.py |
Draws unit-variance normal energies with a prescribed pairwise overlap and runs the solver. |
alanine.py |
NPT equilibration, then NVT parallel tempering of alanine dipeptide in TIP3P water. |
extract_dihedrals.py |
Reads solute DCDs and writes |
reweight_alanine.py |
Runs BU-MBAR on the PT energies and writes |
plot_alanine.py |
Reweights |
Energies and inverse temperatures are generated independently. Overlap only controls the energy distributions; beta_pref only scales the temperature set.
python synthetic_benchmark_bumbar.py TARGET_OVERLAP NUM_SAMPLES NUM_TEMPS BETA_PREF SEED
-
TARGET_OVERLAP: one of0.1, 0.2, …, 0.9 -
NUM_SAMPLES: samples per thermodynamic state -
NUM_TEMPS: number of states -
BETA_PREF: scale factor for$\beta_i = \mathtt{BETA_PREF} \times (5 - 0.1, i)$ -
SEED: RNG seed
Example (paper-like settings: overlap 0.8, beta_pref 10):
python synthetic_benchmark_bumbar.py 0.8 10000 50 10 0The run writes a timeseries file named
overlap{overlap}_samples{N}_temps{M}_betapref{beta}_seed{seed}
Each row is elapsed time (s), histogram resolution relative to the sample count, then the current free-energy estimates.
alanine.py loads alanine dipeptide from openmmtools.testsystems.AlanineDipeptideVacuum, solvates it (TIP3P, 1.5 nm padding, AMBER ff14SB), runs 1e6 NPT steps at 298 K, then parallel tempering:
- 50 replicas from 298 K to 600 K
- 50 Langevin steps (2 fs) between exchanges
- 20 000 equilibration iterations
- 2 000 000 production iterations, writing every 10 iterations
python alanine.pyOutputs are prefixed with a timestamp YYYYMMDD_HHMMSS:
| Output | Contents |
|---|---|
{timestamp}_alanine.py |
Copy of the script used for the run |
{timestamp}temps.dat |
Replica temperatures (K) |
{timestamp}pt_statistics.nc |
openmmtools multistate reporter |
{timestamp}topology.pdb |
Full solvated topology |
{timestamp}topology2.pdb |
Solute-only topology |
{timestamp}replica{k}.dcd |
Solute trajectory for thermodynamic state |
{timestamp}replica_zero_trajectory.dcd |
Full-system frames at the lowest temperature |
{timestamp}_potential_energies.dat |
Potential energies by thermodynamic state (kJ/mol) |
{timestamp}_permutation.dat |
Replica → thermodynamic-state map at each write |
NPT also writes initial_traj.dcd, initial_scalars.csv, initial.xml, and initial.chk.
Use the same timestamp prefix for all three scripts. extract_dihedrals.py and reweight_alanine.py can run independently; plot_alanine.py needs both.
python extract_dihedrals.py TIMESTAMP
python reweight_alanine.py TIMESTAMP
python plot_alanine.py TIMESTAMP| Script | Input | Output |
|---|---|---|
extract_dihedrals.py |
{timestamp}topology2.pdb, {timestamp}replica{k}.dcd
|
{timestamp}all_phi.dat, {timestamp}all_psi.dat
|
reweight_alanine.py |
{timestamp}_potential_energies.dat, {timestamp}temps.dat
|
{timestamp}_free_energies.dat |
plot_alanine.py |
dihedrals, energies, temperatures, and |
free_energy_plot.pdf |
reweight_alanine.py uses plot_alanine.py discards the first 10 001 frames, reweights to 298 K, and plots the
For license information, see LICENSE.txt.