GayBerneForce

class openmm.openmm.GayBerneForce(*args)

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.

__init__(self)GayBerneForce
__init__(self, other)GayBerneForce

Create a GayBerneForce.

Methods

__init__(-> GayBerneForce)

Create a GayBerneForce.

addException(self, particle1, particle2, …)

Add an interaction to the list of exceptions that should be calculated differently from other interactions.

addParticle(self, sigma, epsilon, xparticle, …)

Add the parameters for a particle.

getCutoffDistance(self)

Get the cutoff distance (in nm) being used for interactions.

getExceptionParameters(self, index)

Get the force field parameters for an interaction that should be calculated differently from others.

getForceGroup(self)

Get the force group this Force belongs to.

getName(self)

Get the name of this Force.

getNonbondedMethod(self)

Get the method used for handling long range interactions.

getNumExceptions(self)

Get the number of special interactions that should be calculated differently from other interactions.

getNumParticles(self)

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

getParticleParameters(self, index)

Get the parameters for a particle.

getSwitchingDistance(self)

Get the distance at which the switching function begins to reduce the interaction.

getUseSwitchingFunction(self)

Get whether a switching function is applied to the interaction.

setCutoffDistance(self, distance)

Set the cutoff distance (in nm) being used for interactions.

setExceptionParameters(self, index, …)

Set the force field parameters for an interaction that should be calculated differently from others.

setForceGroup(self, group)

Set the force group this Force belongs to.

setName(self, name)

Set the name of this Force.

setNonbondedMethod(self, method)

Set the method used for handling long range interactions.

setParticleParameters(self, index, sigma, …)

Set the parameters for a particle.

setSwitchingDistance(self, distance)

Set the distance at which the switching function begins to reduce the interaction.

setUseSwitchingFunction(self, use)

Set whether a switching function is applied to the interaction.

updateParametersInContext(self, context)

Update the particle and exception parameters in a Context to match those stored in this Force object.

usesPeriodicBoundaryConditions(self)

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

Attributes

CutoffNonPeriodic

CutoffPeriodic

NoCutoff

thisown

The membership flag

property thisown

The membership flag

getNumParticles(self)int

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

getNumExceptions(self)int

Get the number of special interactions that should be calculated differently from other interactions.

getNonbondedMethod(self)OpenMM::GayBerneForce::NonbondedMethod

Get the method used for handling long range interactions.

setNonbondedMethod(self, method)

Set the method used for handling long range interactions.

getCutoffDistance(self)double

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

Return type

double

setCutoffDistance(self, 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 (double) – the cutoff distance, measured in nm

getUseSwitchingFunction(self)bool

Get whether a switching function is applied to the interaction. If the nonbonded method is set to NoCutoff, this option is ignored.

setUseSwitchingFunction(self, use)

Set whether a switching function is applied to the interaction. If the nonbonded method is set to NoCutoff, this option is ignored.

getSwitchingDistance(self)double

Get the distance at which the switching function begins to reduce the interaction. This must be less than the cutoff distance.

setSwitchingDistance(self, distance)

Set the distance at which the switching function begins to reduce the interaction. This must be less than the cutoff distance.

addParticle(self, sigma, epsilon, xparticle, yparticle, sx, sy, sz, ex, ey, ez)int

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 (double) – the sigma parameter (corresponding to the van der Waals radius of the particle), measured in nm

  • epsilon (double) – the epsilon parameter (corresponding to the well depth of the van der Waals interaction), measured in kJ/mol

  • xparticle (int) – the index of the particle whose position defines the ellipsoid’s x axis, or -1 if the ellipsoid is a sphere

  • yparticle (int) – the index of the particle whose position defines the ellipsoid’s y axis, or -1 if the ellipsoid is axially symmetric

  • sx (double) – the diameter of the ellipsoid along its x axis

  • sy (double) – the diameter of the ellipsoid along its y axis

  • sz (double) – the diameter of the ellipsoid along its z axis

  • ex (double) – the factor by which epsilon is scaled along the ellipsoid’s x axis

  • ey (double) – the factor by which epsilon is scaled along the ellipsoid’s y axis

  • ez (double) – the factor by which epsilon is scaled along the ellipsoid’s z axis

Returns

the index of the particle that was added

Return type

int

getParticleParameters(self, index)

Get the parameters for a particle.

Parameters

index (int) – the index of the particle for which to get parameters

Returns

  • sigma (double) – the sigma parameter (corresponding to the van der Waals radius of the particle), measured in nm

  • epsilon (double) – the epsilon parameter (corresponding to the well depth of the van der Waals interaction), measured in kJ/mol

  • xparticle (int) – the index of the particle whose position defines the ellipsoid’s x axis, or -1 if the ellipsoid is a sphere

  • yparticle (int) – the index of the particle whose position defines the ellipsoid’s y axis, or -1 if the ellipsoid is axially symmetric

  • sx (double) – the diameter of the ellipsoid along its x axis

  • sy (double) – the diameter of the ellipsoid along its y axis

  • sz (double) – the diameter of the ellipsoid along its z axis

  • ex (double) – the factor by which epsilon is scaled along the ellipsoid’s x axis

  • ey (double) – the factor by which epsilon is scaled along the ellipsoid’s y axis

  • ez (double) – the factor by which epsilon is scaled along the ellipsoid’s z axis

setParticleParameters(self, index, sigma, epsilon, xparticle, yparticle, sx, sy, sz, ex, ey, ez)

Set the parameters for a particle.

Parameters
  • index (int) – the index of the particle for which to set parameters

  • sigma (double) – the sigma parameter (corresponding to the van der Waals radius of the particle), measured in nm

  • epsilon (double) – the epsilon parameter (corresponding to the well depth of the van der Waals interaction), measured in kJ/mol

  • xparticle (int) – the index of the particle whose position defines the ellipsoid’s x axis, or -1 if the ellipsoid is a sphere

  • yparticle (int) – the index of the particle whose position defines the ellipsoid’s y axis, or -1 if the ellipsoid is axially symmetric

  • sx (double) – the diameter of the ellipsoid along its x axis

  • sy (double) – the diameter of the ellipsoid along its y axis

  • sz (double) – the diameter of the ellipsoid along its z axis

  • ex (double) – the factor by which epsilon is scaled along the ellipsoid’s x axis

  • ey (double) – the factor by which epsilon is scaled along the ellipsoid’s y axis

  • ez (double) – the factor by which epsilon is scaled along the ellipsoid’s z axis

addException(self, particle1, particle2, sigma, epsilon, replace=False)int

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 (int) – the index of the first particle involved in the interaction

  • particle2 (int) – the index of the second particle involved in the interaction

  • sigma (double) – the sigma parameter (corresponding to the van der Waals radius of the particle), measured in nm

  • epsilon (double) – the epsilon parameter (corresponding to the well depth of the van der Waals interaction), measured in kJ/mol

  • replace (bool) – 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

Return type

int

getExceptionParameters(self, index)

Get the force field parameters for an interaction that should be calculated differently from others.

Parameters

index (int) – the index of the interaction for which to get parameters

Returns

  • particle1 (int) – the index of the first particle involved in the interaction

  • particle2 (int) – the index of the second particle involved in the interaction

  • sigma (double) – the sigma parameter (corresponding to the van der Waals radius of the particle), measured in nm

  • epsilon (double) – the epsilon parameter (corresponding to the well depth of the van der Waals interaction), measured in kJ/mol

setExceptionParameters(self, index, particle1, particle2, sigma, 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 (int) – the index of the interaction for which to get parameters

  • particle1 (int) – the index of the first particle involved in the interaction

  • particle2 (int) – the index of the second particle involved in the interaction

  • sigma (double) – the sigma parameter (corresponding to the van der Waals radius of the particle), measured in nm

  • epsilon (double) – the epsilon parameter (corresponding to the well depth of the van der Waals interaction), measured in kJ/mol

updateParametersInContext(self, 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.

usesPeriodicBoundaryConditions(self)bool

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

Returns

true if force uses PBC and false otherwise

Return type

bool

__copy__(self)Force
getForceGroup(self)int

Get the force group this Force belongs to.

getName(self)std::string const &

Get the name of this Force. This is an arbitrary, user modifiable identifier. By default it equals the class name, but you can change it to anything useful.

setForceGroup(self, group)

Set the force group this Force belongs to.

Parameters

group (int) – the group index. Legal values are between 0 and 31 (inclusive).

setName(self, name)

Set the name of this Force. This is an arbitrary, user modifiable identifier. By default it equals the class name, but you can change it to anything useful.