nvalchemi.enhanced_sampling.FlatBottomRestraint#

class nvalchemi.enhanced_sampling.FlatBottomRestraint(cv, lower, upper, stiffness=10.0, *, name='flat_bottom', exponent=2.0, compute_stress=True)[source]#

Confine the CV to an interval, with no force inside it.

\[E_b = \frac{k}{p}\left[ \max(s - s_\mathrm{hi},\,0)^p + \max(s_\mathrm{lo} - s,\,0)^p \right]\]

Equivalent to registering a LowerWall and an UpperWall with the same stiffness, but as one bias — which matters because the proposal’s rule is that intentionally coupled terms belong in a single bias object rather than being summed by the runner.

Parameters:
  • cv (Callable[[Batch], Tensor]) – Differentiable cv(batch) -> Tensor[B, D].

  • lower (Tensor | float) – Lower bound s_lo.

  • upper (Tensor | float) – Upper bound s_hi.

  • stiffness (Tensor | float) – Penalty prefactor k. Default 10.0.

  • name (str) – Unique bias identifier. Default "flat_bottom".

  • exponent (float) – Power p. Default 2.0.

  • compute_stress (bool) – Passed through to ConservativeBias.

Raises:

ValueError – If any lower bound is not strictly below its upper bound.

energy(current)[source]#

Return the two-sided confinement energy [B, 1] in eV.

Parameters:

current (Batch) – Batch with strained positions supplied by ConservativeBias.forward().

Returns:

Shape [B, 1]; exactly zero inside [lower, upper].

Return type:

Tensor

extra_repr()#

Format the model config for nn.Module.__repr__.

Parameters:

self (Any)

Return type:

str