Parsing Outputs
The parser implementation supports AMBER outputs in alchemrs::parse::amber and GROMACS dhdl.xvg outputs in alchemrs::parse::gromacs.
The top-level parser entry points alchemrs::extract_dhdl, alchemrs::extract_nes_trajectory, alchemrs::extract_u_nk, and alchemrs::extract_u_nk_with_potential auto-detect between the supported formats where appropriate.
Available entry points
extract_dhdl(path, temperature_k)extract_nes_trajectory(path, temperature_k)extract_u_nk(path, temperature_k)extract_u_nk_with_potential(path, temperature_k)
extract_dhdl
Returned value:
DhdlSeries
AMBER parser behavior:
- extracts
temp0,clambda,dt,ntpr, thebegin timecoordinate, andDV/DLvalues from the finalSummary of dvdl values over ... steps:block - reconstructs the sampled
dH/dλseries on the saved-output stride rather than keeping every dense summary value - converts gradients to reduced units by multiplying by
beta = 1 / (k_B T)
GROMACS parser behavior:
- reads
dhdl.xvgheaders to identify the simulation temperature and lambda - extracts the
dH/dlambdaseries from the legend tagged withdHwhen the file contains exactly one derivative component - keeps the x-axis values as the returned
time_psvalues - rejects multidimensional schedules with multiple
dH/dlambdacomponents becauseDhdlSeriesis still scalar
Common failure modes:
- missing temperature or lambda metadata
- missing
dH/dlambdasamples - temperature mismatch between the file and the requested temperature
extract_nes_trajectory
Returned value:
SwitchingTrajectory
AMBER parser behavior:
- extracts
temp0,clambda,dynlmb, andntave - parses the final
Summary of dvdl values over ... steps:block - converts each
dV/dλsample to reduced units - reconstructs the lambda path using
Δλ = dynlmb / ntave - integrates the reduced work as the discrete sum over the switching path
- stores the full lambda-resolved profile in the returned
SwitchingTrajectory
Common failure modes:
- missing switching metadata such as
dynlmborntave - missing or truncated
DV/DLsummary blocks - temperature mismatch between the file and the requested temperature
extract_u_nk
Returned value:
UNkMatrix
AMBER parser behavior:
- reads MBAR output blocks and constructs a
UNkMatrix - requires a valid MBAR lambda list in the file header
- requires
clambdato be present in the evaluated-state grid - keeps sample rows with positive infinity values
- fails if no finite MBAR samples remain after filtering unusable rows
GROMACS parser behavior:
- reads
dhdl.xvgDelta H columns and maps them into reduced-energy rows, including multidimensional lambda tuples from legends liketo (coul, vdw) - inserts the sampled lambda state explicitly with zero reduced energy
- sorts the evaluated-state grid by lambda before building the matrix
- requires at least one foreign-lambda Delta H column
extract_u_nk_with_potential
Returned value:
(UNkMatrix, Vec<f64>)
AMBER parser behavior:
- does everything
extract_u_nkdoes and additionally extractsEPtotfromNSTEPblocks - requires the number of
EPtotsamples to match the retained MBAR sample count exactly
GROMACS parser behavior:
- does everything
extract_u_nkdoes and additionally extracts thePotential Energylegend fromdhdl.xvg - requires that potential-energy observable to be present when this entry point is used
This function exists because an external energy observable is often useful for:
- auto-equilibration
- decorrelation
especially when the u_nk matrix contains positive infinity values that make DE-based preprocessing invalid.
Temperature validation
The parser checks the temperature in the AMBER file against the temperature passed by the caller and fails if they differ by more than a small tolerance.
This is deliberate: parser output is temperature-dependent because reduced energies depend on beta.
Current scope
The public parser surface in this repository supports:
- AMBER equilibrium
.outfiles fordH/dλandu_nk - AMBER nonequilibrium switching
.outfiles for NES trajectories - GROMACS
dhdl.xvgfiles fordH/dλandu_nk
The architecture still leaves room for additional engines later.