Package ffx.openmm

Class GayBerneForce

java.lang.Object
ffx.openmm.Force
ffx.openmm.GayBerneForce

public class GayBerneForce extends 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.

  • Constructor Details

    • GayBerneForce

      public GayBerneForce()
      Create a new GayBerneForce.
  • Method Details

    • addException

      public int addException(int particle1, int particle2, double sigma, double epsilon, int replace)
      Add an exception to the force.
      Parameters:
      particle1 - The index of the first particle.
      particle2 - The index of the second particle.
      sigma - The sigma parameter for the exception.
      epsilon - The epsilon parameter for the exception.
      replace - Whether to replace an existing exception.
      Returns:
      The index of the exception that was added.
    • addParticle

      public int addParticle(double sigma, double epsilon, int xparticle, int yparticle, double ex, double ey, double ez, double sx, double sy, double sz)
      Add a particle to the force.
      Parameters:
      sigma - The sigma parameter.
      epsilon - The epsilon parameter.
      xparticle - The x-axis particle type.
      yparticle - The y-axis particle type.
      ex - The x-axis shape parameter.
      ey - The y-axis shape parameter.
      ez - The z-axis shape parameter.
      sx - The x-axis strength parameter.
      sy - The y-axis strength parameter.
      sz - The z-axis strength parameter.
      Returns:
      The index of the particle that was added.
    • destroy

      public void destroy()
      Destroy the force.
      Specified by:
      destroy in class Force
    • getCutoffDistance

      public double getCutoffDistance()
      Get the cutoff distance.
      Returns:
      The cutoff distance, measured in nm.
    • getExceptionParameters

      public void getExceptionParameters(int index, com.sun.jna.ptr.IntByReference particle1, com.sun.jna.ptr.IntByReference particle2, com.sun.jna.ptr.DoubleByReference sigma, com.sun.jna.ptr.DoubleByReference epsilon)
      Get the parameters for an exception.
      Parameters:
      index - The index of the exception.
      particle1 - The index of the first particle (output).
      particle2 - The index of the second particle (output).
      sigma - The sigma parameter for the exception (output).
      epsilon - The epsilon parameter for the exception (output).
    • getExceptionParameters

      public void getExceptionParameters(int index, IntBuffer particle1, IntBuffer particle2, DoubleBuffer sigma, DoubleBuffer epsilon)
      Get the parameters for an exception.
      Parameters:
      index - The index of the exception.
      particle1 - The index of the first particle (output).
      particle2 - The index of the second particle (output).
      sigma - The sigma parameter for the exception (output).
      epsilon - The epsilon parameter for the exception (output).
    • getNonbondedMethod

      public int getNonbondedMethod()
      Get the nonbonded method.
      Returns:
      The nonbonded method.
    • getNumExceptions

      public int getNumExceptions()
      Get the number of exceptions.
      Returns:
      The number of exceptions.
    • getNumParticles

      public int getNumParticles()
      Get the number of particles.
      Returns:
      The number of particles.
    • getParticleParameters

      public void getParticleParameters(int index, com.sun.jna.ptr.DoubleByReference sigma, com.sun.jna.ptr.DoubleByReference epsilon, com.sun.jna.ptr.IntByReference xparticle, com.sun.jna.ptr.IntByReference yparticle, com.sun.jna.ptr.DoubleByReference ex, com.sun.jna.ptr.DoubleByReference ey, com.sun.jna.ptr.DoubleByReference ez, com.sun.jna.ptr.DoubleByReference sx, com.sun.jna.ptr.DoubleByReference sy, com.sun.jna.ptr.DoubleByReference sz)
      Get the parameters for a particle.
      Parameters:
      index - The index of the particle.
      sigma - The sigma parameter (output).
      epsilon - The epsilon parameter (output).
      xparticle - The x-axis particle type (output).
      yparticle - The y-axis particle type (output).
      ex - The x-axis shape parameter (output).
      ey - The y-axis shape parameter (output).
      ez - The z-axis shape parameter (output).
      sx - The x-axis strength parameter (output).
      sy - The y-axis strength parameter (output).
      sz - The z-axis strength parameter (output).
    • getParticleParameters

      public void getParticleParameters(int index, DoubleBuffer sigma, DoubleBuffer epsilon, IntBuffer xparticle, IntBuffer yparticle, DoubleBuffer ex, DoubleBuffer ey, DoubleBuffer ez, DoubleBuffer sx, DoubleBuffer sy, DoubleBuffer sz)
      Get the parameters for a particle.
      Parameters:
      index - The index of the particle.
      sigma - The sigma parameter (output).
      epsilon - The epsilon parameter (output).
      xparticle - The x-axis particle type (output).
      yparticle - The y-axis particle type (output).
      ex - The x-axis shape parameter (output).
      ey - The y-axis shape parameter (output).
      ez - The z-axis shape parameter (output).
      sx - The x-axis strength parameter (output).
      sy - The y-axis strength parameter (output).
      sz - The z-axis strength parameter (output).
    • getSwitchingDistance

      public double getSwitchingDistance()
      Get the switching distance.
      Returns:
      The switching distance, measured in nm.
    • getUseSwitchingFunction

      public int getUseSwitchingFunction()
      Get whether a switching function is used.
      Returns:
      1 if a switching function is used, 0 otherwise.
    • setCutoffDistance

      public void setCutoffDistance(double distance)
      Set the cutoff distance.
      Parameters:
      distance - The cutoff distance, measured in nm.
    • setExceptionParameters

      public void setExceptionParameters(int index, int particle1, int particle2, double sigma, double epsilon)
      Set the parameters for an exception.
      Parameters:
      index - The index of the exception.
      particle1 - The index of the first particle.
      particle2 - The index of the second particle.
      sigma - The sigma parameter for the exception.
      epsilon - The epsilon parameter for the exception.
    • setNonbondedMethod

      public void setNonbondedMethod(int method)
      Set the nonbonded method.
      Parameters:
      method - The nonbonded method.
    • setParticleParameters

      public void setParticleParameters(int index, double sigma, double epsilon, int xparticle, int yparticle, double ex, double ey, double ez, double sx, double sy, double sz)
      Set the parameters for a particle.
      Parameters:
      index - The index of the particle.
      sigma - The sigma parameter.
      epsilon - The epsilon parameter.
      xparticle - The x-axis particle type.
      yparticle - The y-axis particle type.
      ex - The x-axis shape parameter.
      ey - The y-axis shape parameter.
      ez - The z-axis shape parameter.
      sx - The x-axis strength parameter.
      sy - The y-axis strength parameter.
      sz - The z-axis strength parameter.
    • setSwitchingDistance

      public void setSwitchingDistance(double distance)
      Set the switching distance.
      Parameters:
      distance - The switching distance, measured in nm.
    • setUseSwitchingFunction

      public void setUseSwitchingFunction(int use)
      Set whether to use a switching function.
      Parameters:
      use - 1 to use a switching function, 0 otherwise.
    • updateParametersInContext

      public void updateParametersInContext(Context context)
      Update the parameters in a Context to match those stored in this Force object.
      Parameters:
      context - The Context in which to update the parameters.
    • usesPeriodicBoundaryConditions

      public boolean usesPeriodicBoundaryConditions()
      Check if the force uses periodic boundary conditions.
      Overrides:
      usesPeriodicBoundaryConditions in class Force
      Returns:
      True if the force uses periodic boundary conditions.