mod free_energy

module free_energy

Free-energy estimators (Bennett’s BAR + descendants). BarEstimator: Bennett’s acceptance-ratio estimator for the free-energy difference Delta F = F_B - F_A between two ensembles. The inputs use reduced energy differences, with inverse-temperature factors supplied for the two ensembles.

Pure observable: takes the two energy series and returns (Delta F, sigma^2). No kernel perturbation. The estimator is exposed as an observable so kernels can compare ensembles without changing the proposal or acceptance machinery.

Structs and Unions

struct BarEstimator

Bennett 1976 self-consistent free-energy estimator.

Given samples from ensembles A and B, du_a is U_B - U_A at points sampled from A, while du_b is U_B - U_A at points sampled from B. The implementation multiplies these by beta_a and beta_b, respectively. This raw-difference representation is exact for a shared energy scale; for arbitrary reduced potentials, callers must construct the reduced differences themselves because this API cannot encode both cross energies. The BAR estimate solves the equality between the two Fermi sums, where C = Delta F + log(N_A / N_B).

du_a: Vec<f64>

Samples of U_B - U_A evaluated at points drawn from A.

du_b: Vec<f64>

Samples of U_B - U_A evaluated at points drawn from B.

beta_a: f64

Inverse temperature multiplying the A-side difference.

beta_b: f64

Inverse temperature multiplying the B-side difference.

Implementations

impl BarEstimator

Functions

fn new(du_a: Vec<f64>, du_b: Vec<f64>, beta_a: f64, beta_b: f64) -> Self

Constructs from cross-energy lists and inverse temperatures.

fn solve(&self) -> (f64, f64)

Solves the BAR self-consistency by bisection. Returns the root C and the corresponding Delta F = C - log(N_A / N_B).

fn variance(&self) -> f64

Asymptotic variance of the BAR estimator (Shirts/Chodera 2008). Returns the sample variance of Delta F.