PeriodicBounds

class openxps.bounds.PeriodicBounds(lower, upper, unit)[source]

A periodic boundary condition. The dynamical variable is allowed to wrap around the upper and lower bounds.

Parameters:
  • lower (float) – The lower bound for the dynamical variable.

  • upper (float) – The upper bound for the dynamical variable.

  • unit (cvpack.units.units.Unit) – The unit of measurement of the bounds. If the bounds do not have a unit, use dimensionless.

Example

>>> import openxps as xps
>>> import yaml
>>> from openmm import unit
>>> bounds = xps.PeriodicBounds(-180, 180, unit.degree)
>>> print(bounds)
PeriodicBounds(lower=-180.0, upper=180.0, unit=deg)
>>> assert yaml.safe_load(yaml.safe_dump(bounds)) == bounds

Methods

leptonExpression(variable)[source]

Return a lepton expression representing the transformation from an unwrapped variable to a wrapped value under the boundary conditions.

Parameters:

variable (str) – The name of the variable in the expression.

Returns:

A string representing the transformation.

Return type:

str

Example

>>> import openxps as xps
>>> from openmm import unit
>>> periodic = xps.bounds.PeriodicBounds(-180, 180, unit.degree)
>>> print(periodic.leptonExpression("x"))
(scaled_x-floor(scaled_x))*360.0-180.0;
scaled_x=(x+180.0)/360.0
>>> reflective = xps.bounds.ReflectiveBounds(1, 10, unit.angstrom)
>>> print(reflective.leptonExpression("y"))
min(wrapped_y,1-wrapped_y)*18.0+1.0;
wrapped_y=scaled_y-floor(scaled_y);
scaled_y=(y-1.0)/18.0
wrap(value, rate)[source]

Wrap a value around the bounds and adjust its rate of change.

Parameters:
  • value (float) – The unwrapped value, in the same unit of measurement as the bounds.

  • rate (float) – The rate of change of the unwrapped value, in the same unit of measurement as the bounds divided by a time unit.

Returns:

  • float – The wrapped value, in the same unit of measurement as the bounds.

  • float – The adjusted rate of change of the wrapped value, in the same unit of measurement as the original rate.

Return type:

tuple[float, float]