mod free_energy

module free_energy

Free-energy estimators (Bennett’s BAR + descendants). BarEstimator: Bennett 1976 acceptance-ratio estimator for the free-energy difference Delta F = F_B - F_A between two ensembles A, B. Optimal in the asymptotic-variance sense; tighter than FEP forward / backward by a provable factor under matched phase-space overlap.

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 two ensembles A (at beta_a = 1/T_a) and B (at beta_b = 1/T_b), and the two cross-energy lists du_a = beta_a * U_B(x) - beta_b * U_B(x_b) for x sampled from A (similar for du_b), the BAR estimate of Delta F = F_B - F_A solves the equality between the A-side and B-side Fermi-function sums. where C = Delta F + log(N_A / N_B). Iterate until C is fixed.

du_a: Vec<f64>

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

du_b: Vec<f64>

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

beta_a: f64

Inverse temperature at A.

beta_b: f64

Inverse temperature at B.

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 + 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.