GayBerneForce

class GayBerneForce : public OpenMM::Force

This class implements the Gay-Berne anisotropic potential. This is similar to a Lennard-Jones 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 Lennard-Jones 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 Lennard-Jones 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 Lorentz-Berthelot 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 call addParticle() once for each particle in the System to define its parameters. The number of particles for which you define parameters must be exactly equal to the number of particles in the System, or else an exception will be thrown when you try to create a Context. After a particle has been added, you can modify its force field parameters by calling setParticleParameters(). This will have no effect on Contexts that already exist unless you call updateParametersInContext().

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 call setSwitchingDistance() to specify the distance at which the interaction should begin to decrease. The switching distance must be less than the cutoff distance.

Public Types

enum NonbondedMethod

This is an enumeration of the different methods that may be used for handling long range nonbonded forces.

Values:

enumerator 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.

enumerator CutoffNonPeriodic

Interactions beyond the cutoff distance are ignored.

enumerator 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.

Public Functions

GayBerneForce()

Create a GayBerneForce.

inline int getNumParticles() const

Get the number of particles for which force field parameters have been defined.

inline 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 this Force object. This method provides an efficient method to update certain parameters in an existing Context without needing to reinitialize it. Simply call setParticleParameters() and setExceptionParameters() to modify this object’s parameters, then call updateParametersInContext() to copy them over to the Context.

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 the Context. 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.

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