CollectiveVariable

class ufedmm.CollectiveVariable(id, force)[source]

A function of the particle coordinates, evaluated by means of an openmm.Force object.

Quoting the manual entry for openmm.CustomCVForce:

“Each collective variable is defined by a Force object. The Force’s potential energy is computed, and that becomes the value of the variable. This provides enormous flexibility in defining collective variables, especially by using custom forces. Anything that can be computed as a potential function can also be used as a collective variable.”

Parameters:
  • id (str) – A valid identifier string for this collective variable.

  • force (openmm.Force) – An openmm.Force object whose energy function is used to evaluate this collective variable.

Example

>>> import openmm
>>> import ufedmm
>>> from openmm import unit
>>> cv = ufedmm.CollectiveVariable('psi', openmm.CustomTorsionForce('theta'))
>>> cv.force.addTorsion(0, 1, 2, 3, [])
0

Methods

effective_mass(system, positions, cv_unit=None)[source]

Computes the effective mass of the collective variable for a given system and a given set of particle coordinates.

The effective mass of a collective variable \(q(\mathbf{r})\) is defined as [2]:

\[m_\mathrm{eff} = \left( \sum_{j=1}^N \frac{1}{m_j} \left\| \frac{dq}{d\mathbf{r}_j} \right\|^2 \right)^{-1}\]
Parameters:
  • system (openmm.System) – The system for which the collective variable will be evaluated.

  • positions (list of openmm.Vec3) – A list whose size equals the number of particles in the system and which contains the coordinates of these particles.

Keyword Arguments:

cv_unit (unit.Unit, default=None) – The unity of measurement of the collective variable. If this is None, then a numerical value is returned based on the OpenMM default units.

Return type:

float or unit.Quantity

Example

>>> import ufedmm
>>> from openmm import unit
>>> model = ufedmm.AlanineDipeptideModel()
>>> model.phi.effective_mass(model.system, model.positions)
0.04795887...
>>> model.psi.effective_mass(model.system, model.positions)
0.05115582...
evaluate(system, positions, cv_unit=None)[source]

Computes the value of the collective variable for a given system and a given set of particle coordinates.

Parameters:
  • system (openmm.System) – The system for which the collective variable will be evaluated.

  • positions (list of openmm.Vec3) – A list whose size equals the number of particles in the system and which contains the coordinates of these particles.

Keyword Arguments:

cv_unit (unit.Unit, default=None) – The unity of measurement of the collective variable. If this is None, then a numerical value is returned based on the OpenMM default units.

Return type:

float or unit.Quantity

Example

>>> import ufedmm
>>> from openmm import unit
>>> model = ufedmm.AlanineDipeptideModel()
>>> model.phi.evaluate(model.system, model.positions)
3.141592653589793
>>> model.psi.evaluate(model.system, model.positions)
3.141592653589793