GayBerneForce¶

class
OpenMM::
GayBerneForce
¶ This class implements the GayBerne anisotropic potential. This is similar to a LennardJones potential, but it represents the particles as ellipsoids rather than point particles. In addition to the standard sigma and epsilon parameters, each particle has three widths sx, sy, and sz that give the diameter of the ellipsoid along each axis. It also has three scale factors ex, ey, and ez that scale the strength of the interaction along each axis. You can think of this force as a LennardJones interaction computed based on the distance between the nearest points on two ellipsoids. The scale factors act as multipliers for epsilon along each axis, so the strength of the interaction along the ellipsoid’s x axis is multiplied by ex, and likewise for the other axes. If two particles each have all their widths set to sigma and all their scale factors set to 1, the interaction simplifies to a standard LennardJones force between point particles.
The orientation of a particle’s ellipsoid is determined based on the positions of two other particles. The vector to the first particle sets the direction of the x axis. The vector to the second particle (after subtracting out any x component) sets the direction of the y axis. If the ellipsoid is axially symmetric (sy=sz and ey=ez), you can omit the second particle and define only an x axis direction. If the ellipsoid is a sphere (all three widths and all three scale factors are equal), both particles can be omitted.
To determine the values of sigma and epsilon for an interaction, this class uses LorentzBerthelot combining rules: it takes the arithmetic mean of the sigmas and the geometric mean of the epsilons for the two interacting particles. You also can specify “exceptions”, particular pairs of particles for which different values should be used.
To use this class, create a
GayBerneForce
object, then calladdParticle()
once for each particle in theSystem
to define its parameters. The number of particles for which you define parameters must be exactly equal to the number of particles in theSystem
, or else an exception will be thrown when you try to create aContext
. After a particle has been added, you can modify its force field parameters by callingsetParticleParameters()
. This will have no effect on Contexts that already exist unless you callupdateParametersInContext()
.When using a cutoff, by default interactions are sharply truncated at the cutoff distance. Optionally you can instead use a switching function to make the interaction smoothly go to zero over a finite distance range. To enable this, call
setUseSwitchingFunction()
. You must also callsetSwitchingDistance()
to specify the distance at which the interaction should begin to decrease. The switching distance must be less than the cutoff distance.Methods
GayBerneForce
Create a GayBerneForce
.getNumParticles
Get the number of particles for which force field parameters have been defined. getNumExceptions
Get the number of special interactions that should be calculated differently from other interactions. getNonbondedMethod
Get the method used for handling long range interactions. setNonbondedMethod
Set the method used for handling long range interactions. getCutoffDistance
Get the cutoff distance (in nm) being used for interactions. setCutoffDistance
Set the cutoff distance (in nm) being used for interactions. getUseSwitchingFunction
Get whether a switching function is applied to the interaction. setUseSwitchingFunction
Set whether a switching function is applied to the interaction. getSwitchingDistance
Get the distance at which the switching function begins to reduce the interaction. setSwitchingDistance
Set the distance at which the switching function begins to reduce the interaction. addParticle
Add the parameters for a particle. getParticleParameters
Get the parameters for a particle. setParticleParameters
Set the parameters for a particle. addException
Add an interaction to the list of exceptions that should be calculated differently from other interactions. getExceptionParameters
Get the force field parameters for an interaction that should be calculated differently from others. setExceptionParameters
Set the force field parameters for an interaction that should be calculated differently from others. updateParametersInContext
Update the particle and exception parameters in a Context
to match those stored in thisForce
object.usesPeriodicBoundaryConditions
Returns whether or not this force makes use of periodic boundary conditions. Enum: NonbondedMethod
NoCutoff No cutoff is applied to nonbonded interactions. The full set of N^2 interactions is computed exactly. This necessarily means that periodic boundary conditions cannot be used. This is the default. CutoffNonPeriodic Interactions beyond the cutoff distance are ignored. CutoffPeriodic Periodic boundary conditions are used, so that each particle interacts only with the nearest periodic copy of each other particle. Interactions beyond the cutoff distance are ignored. 
GayBerneForce
()¶ Create a
GayBerneForce()
.

int
getNumParticles
() const¶ Get the number of particles for which force field parameters have been defined.

int
getNumExceptions
() const¶ Get the number of special interactions that should be calculated differently from other interactions.

NonbondedMethod
getNonbondedMethod
() const¶ Get the method used for handling long range interactions.

void
setNonbondedMethod
(NonbondedMethod method)¶ Set the method used for handling long range interactions.

double
getCutoffDistance
() const¶ Get the cutoff distance (in nm) being used for interactions. If the NonbondedMethod in use is NoCutoff, this value will have no effect.
Returns: the cutoff distance, measured in nm

void
setCutoffDistance
(double distance)¶ Set the cutoff distance (in nm) being used for interactions. If the NonbondedMethod in use is NoCutoff, this value will have no effect.
Parameters:  distance – the cutoff distance, measured in nm

bool
getUseSwitchingFunction
() const¶ Get whether a switching function is applied to the interaction. If the nonbonded method is set to NoCutoff, this option is ignored.

void
setUseSwitchingFunction
(bool use)¶ Set whether a switching function is applied to the interaction. If the nonbonded method is set to NoCutoff, this option is ignored.

double
getSwitchingDistance
() const¶ Get the distance at which the switching function begins to reduce the interaction. This must be less than the cutoff distance.

void
setSwitchingDistance
(double distance)¶ Set the distance at which the switching function begins to reduce the interaction. This must be less than the cutoff distance.

int
addParticle
(double sigma, double epsilon, int xparticle, int yparticle, double sx, double sy, double sz, double ex, double ey, double ez)¶ Add the parameters for a particle. This should be called once for each particle in the
System
. When it is called for the i’th time, it specifies the parameters for the i’th particle.Parameters:  sigma – the sigma parameter (corresponding to the van der Waals radius of the particle), measured in nm
 epsilon – the epsilon parameter (corresponding to the well depth of the van der Waals interaction), measured in kJ/mol
 xparticle – the index of the particle whose position defines the ellipsoid’s x axis, or 1 if the ellipsoid is a sphere
 yparticle – the index of the particle whose position defines the ellipsoid’s y axis, or 1 if the ellipsoid is axially symmetric
 sx – the diameter of the ellipsoid along its x axis
 sy – the diameter of the ellipsoid along its y axis
 sz – the diameter of the ellipsoid along its z axis
 ex – the factor by which epsilon is scaled along the ellipsoid’s x axis
 ey – the factor by which epsilon is scaled along the ellipsoid’s y axis
 ez – the factor by which epsilon is scaled along the ellipsoid’s z axis
Returns: the index of the particle that was added

void
getParticleParameters
(int index, double &sigma, double &epsilon, int &xparticle, int &yparticle, double &sx, double &sy, double &sz, double &ex, double &ey, double &ez) const¶ Get the parameters for a particle.
Parameters:  index – the index of the particle for which to get parameters
 sigma – [out] the sigma parameter (corresponding to the van der Waals radius of the particle), measured in nm
 epsilon – [out] the epsilon parameter (corresponding to the well depth of the van der Waals interaction), measured in kJ/mol
 xparticle – [out] the index of the particle whose position defines the ellipsoid’s x axis, or 1 if the ellipsoid is a sphere
 yparticle – [out] the index of the particle whose position defines the ellipsoid’s y axis, or 1 if the ellipsoid is axially symmetric
 sx – [out] the diameter of the ellipsoid along its x axis
 sy – [out] the diameter of the ellipsoid along its y axis
 sz – [out] the diameter of the ellipsoid along its z axis
 ex – [out] the factor by which epsilon is scaled along the ellipsoid’s x axis
 ey – [out] the factor by which epsilon is scaled along the ellipsoid’s y axis
 ez – [out] the factor by which epsilon is scaled along the ellipsoid’s z axis

void
setParticleParameters
(int index, double sigma, double epsilon, int xparticle, int yparticle, double sx, double sy, double sz, double ex, double ey, double ez)¶ Set the parameters for a particle.
Parameters:  index – the index of the particle for which to set parameters
 sigma – the sigma parameter (corresponding to the van der Waals radius of the particle), measured in nm
 epsilon – the epsilon parameter (corresponding to the well depth of the van der Waals interaction), measured in kJ/mol
 xparticle – the index of the particle whose position defines the ellipsoid’s x axis, or 1 if the ellipsoid is a sphere
 yparticle – the index of the particle whose position defines the ellipsoid’s y axis, or 1 if the ellipsoid is axially symmetric
 sx – the diameter of the ellipsoid along its x axis
 sy – the diameter of the ellipsoid along its y axis
 sz – the diameter of the ellipsoid along its z axis
 ex – the factor by which epsilon is scaled along the ellipsoid’s x axis
 ey – the factor by which epsilon is scaled along the ellipsoid’s y axis
 ez – the factor by which epsilon is scaled along the ellipsoid’s z axis

int
addException
(int particle1, int particle2, double sigma, double epsilon, bool replace = false)¶ Add an interaction to the list of exceptions that should be calculated differently from other interactions. If epsilon is equal to 0, this will cause the interaction to be completely omitted from force and energy calculations.
Parameters:  particle1 – the index of the first particle involved in the interaction
 particle2 – the index of the second particle involved in the interaction
 sigma – the sigma parameter (corresponding to the van der Waals radius of the particle), measured in nm
 epsilon – the epsilon parameter (corresponding to the well depth of the van der Waals interaction), measured in kJ/mol
 replace – determines the behavior if there is already an exception for the same two particles. If true, the existing one is replaced. If false, an exception is thrown.
Returns: the index of the exception that was added

void
getExceptionParameters
(int index, int &particle1, int &particle2, double &sigma, double &epsilon) const¶ Get the force field parameters for an interaction that should be calculated differently from others.
Parameters:  index – the index of the interaction for which to get parameters
 particle1 – [out] the index of the first particle involved in the interaction
 particle2 – [out] the index of the second particle involved in the interaction
 sigma – [out] the sigma parameter (corresponding to the van der Waals radius of the particle), measured in nm
 epsilon – [out] the epsilon parameter (corresponding to the well depth of the van der Waals interaction), measured in kJ/mol

void
setExceptionParameters
(int index, int particle1, int particle2, double sigma, double epsilon)¶ Set the force field parameters for an interaction that should be calculated differently from others. If epsilon is equal to 0, this will cause the interaction to be completely omitted from force and energy calculations.
Parameters:  index – the index of the interaction for which to get parameters
 particle1 – the index of the first particle involved in the interaction
 particle2 – the index of the second particle involved in the interaction
 sigma – the sigma parameter (corresponding to the van der Waals radius of the particle), measured in nm
 epsilon – the epsilon parameter (corresponding to the well depth of the van der Waals interaction), measured in kJ/mol

void
updateParametersInContext
(Context &context)¶ Update the particle and exception parameters in a
Context
to match those stored in thisForce
object. This method provides an efficient method to update certain parameters in an existingContext
without needing to reinitialize it. Simply callsetParticleParameters()
andsetExceptionParameters()
to modify this object’s parameters, then callupdateParametersInContext()
to copy them over to theContext
.This method has several limitations. The only information it updates is the parameters of particles and exceptions. All other aspects of the
Force
(the nonbonded method, the cutoff distance, etc.) are unaffected and can only be changed by reinitializing theContext
. Furthermore, only the sigma and epsilon values of an exception can be changed; the pair of particles involved in the exception cannot change. Likewise, the xparticle and yparticle defining the orientation of an ellipse cannot be changed. Finally, this method cannot be used to add new particles or exceptions, only to change the parameters of existing ones.

bool
usesPeriodicBoundaryConditions
() const¶ Returns whether or not this force makes use of periodic boundary conditions.
Returns: true if force uses PBC and false otherwise
