kups.mcmc.widom
¶
Widom test-particle method.
A ghost move runs the full propose/patch/log-ratio pipeline and discards the resulting state patch; the log acceptance ratio is accumulated into running statistics.
Contents:
- widom_test: per-system \(\ln\alpha\) for a ghost move
- GhostProbe: propagator wrapper accumulating the ratio via a lens + update callback
- WidomStatistics: running-sum accumulator reduced to \(\mu^\mathrm{ex}\), \(K_H\), \(q_\mathrm{st}\) by the post-hoc analyzer.
References
Widom, B. (1963). J. Chem. Phys., 39, 2808. Vlugt, T. J. H. et al. (2008). J. Chem. Theory Comput., 4, 1107.
Energy = Array
¶
Potential energy [energy].
LogAcceptanceRatio = Array
¶
Log Metropolis acceptance ratio \(\ln\alpha\) [dimensionless].
GhostProbe
¶
Bases: Propagator[State]
Propagator running one ghost move and updating a lens-accessed statistic.
Attributes:
| Name | Type | Description |
|---|---|---|
propose_fn |
/ patch_fn / log_probability_ratio_fn
|
standard MCMC trio
(:class: |
stat_lens |
Lens[State, Stat]
|
where in |
update_fn |
Callable[[State, Stat, Array], Stat]
|
|
Source code in src/kups/mcmc/widom.py
WidomStatistics
¶
Online accumulator for plain Widom insertion sums.
Attributes:
| Name | Type | Description |
|---|---|---|
sum_boltzmann |
Array
|
\(\sum \exp(-\beta \Delta U) = \sum W\) [dimensionless]. |
sum_delta_u_boltzmann |
Array
|
\(\sum \Delta U \cdot \exp(-\beta \Delta U)\) [energy], with \(\Delta U\) the ghost insertion (host-guest) energy, not the cell's total potential energy. |
n_samples |
Array
|
Number of evaluations accumulated. |
Source code in src/kups/mcmc/widom.py
reset()
¶
update(ln_alpha, delta_u)
¶
Accumulate one ghost insertion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ln_alpha
|
LogAcceptanceRatio
|
Per-system log Metropolis ratio. |
required |
delta_u
|
Energy
|
Per-system ghost insertion energy. With a zero-move-log insertion proposal and a bare Boltzmann log-ratio, \(\Delta U = -k_BT \ln\alpha\) exactly. |
required |
Source code in src/kups/mcmc/widom.py
zeros(n_systems)
staticmethod
¶
Zero-initialize.
Source code in src/kups/mcmc/widom.py
widom_test(key, state, propose_fn, patch_fn, log_probability_ratio_fn)
¶
Evaluate per-system \(\ln\alpha\) for a ghost move without modifying state.
Runs the full MCMC proposal \(\to\) patch \(\to\) log-ratio pipeline and intentionally discards the resulting state patch. The physical state is untouched --- this is the Widom test-particle method applied as a reusable subroutine. The returned value is raw \(\ln\alpha\), not clamped by \(\min(1, \cdot)\); callers decide how to consume it:
- Excess chemical potential: average \(\exp\ln\alpha\), take \(-k_BT \ln\langle\cdot\rangle\).
- Henry coefficient: same average evaluated at \(N = 0\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Array
|
JAX PRNG key. |
required |
state
|
State
|
Current simulation state. Not modified. |
required |
propose_fn
|
ChangesFn[State, Changes]
|
Move proposal (e.g. insertion or deletion). |
required |
patch_fn
|
PatchFn[State, Changes, Move]
|
Converts proposal to a state patch. |
required |
log_probability_ratio_fn
|
LogProbabilityRatioFn[State, Move]
|
Evaluates the acceptance log-ratio against the proposed patch. |
required |
Returns:
| Type | Description |
|---|---|
Table[SystemId, LogAcceptanceRatio]
|
Per-system log acceptance ratio as |