OrientationRestraintForce

class OrientationRestraintForce : public OpenMM::Force

This is an approximately harmonic restraint force for keeping a group of particles in a particular orientation. You specify a set of particles and reference positions for them. It finds the rigid transformation that optimally aligns the particles to the reference positions, consisting of a translation followed by a rotation. The interaction energy is 2*k*sin^2(theta/2), where theta is the rotation angle and k is a user defined force constant. When the particles are close to the target orientation, this approximately equals the harmonic form (k/2)*theta^2. For larger angles, the force is reduced from the harmonic form, and it goes to zero at theta=pi/2. This avoids the discontinuity in the force that would be present if the force were nonzero at pi/2.

Public Functions

explicit OrientationRestraintForce(double k, const std::vector<Vec3> &referencePositions, const std::vector<int> &particles = std::vector<int>())

Create an OrientationRestraintForce.

Parameters:
  • k – the force constant, measured in kJ/mol

  • referencePositions – the reference positions to compute the rotation from. The length of this vector must equal the number of particles in the system, even if not all particles are used in computing the rotation.

  • particles – the indices of the particles to use when computing the rotation. If this is empty (the default), all particles in the system will be used.

inline double getK() const

Get the force constant.

Returns:

the force constant in kJ/mol

void setK(double k)

Set the force constant.

Parameters:

k – the force constant, measured in kJ/mol

inline const std::vector<Vec3> &getReferencePositions() const

Get the reference positions to compute the rotation from.

void setReferencePositions(const std::vector<Vec3> &positions)

Set the reference positions to compute the rotation from.

inline const std::vector<int> &getParticles() const

Get the indices of the particles to use when computing the rotation. If this is empty, all particles in the system will be used.

void setParticles(const std::vector<int> &particles)

Set the indices of the particles to use when computing the rotation. If this is empty, all particles in the system will be used.

void updateParametersInContext(Context &context)

Update the reference positions and particle indices in a Context to match those stored in this Force object. This method provides an efficient method to update certain parameters in an existing Context without needing to reinitialize it. Simply call setReferencePositions() setParticles(), and setK() to modify this object’s parameters, then call updateParametersInContext() to copy them over to the Context.

inline virtual bool usesPeriodicBoundaryConditions() const

Returns whether or not this force makes use of periodic boundary conditions.

Returns:

true if force uses PBC and false otherwise