Package ffx.openmm

Class CustomVolumeForce

java.lang.Object
ffx.openmm.Force
ffx.openmm.CustomVolumeForce

public class CustomVolumeForce extends Force
This class computes an energy that depends only on the volume of the periodic box, or more generally on the box shape as specified by the elements of the box vectors. Because the energy does not depend on particle positions, it does not apply any forces to particles. It is primarily useful for constant pressure simulations, where the volume-dependent energy can influence the behavior of the barostat. Energy terms of this sort are often used for pressure matching in coarse grained force fields.

To use this class, create a CustomVolumeForce object, passing an algebraic expression to the constructor that defines the energy. The expression may depend on the following variables.

  • v: The volume of the periodic box in nm^3.
  • ax: The x component of the first box vector in nm. (The y and z components are always zero.)
  • bx, by: The x and y components of the second box vector in nm. (The z component is always zero.)
  • cx, cy, cz: The x, y and z components of the third box vector in nm.
  • Global parameters that you define by calling addGlobalParameter().

The initial value of a global parameter is specified in the call to addGlobalParameter(). Their values can be modified during a simulation by calling Context::setParameter().

Expressions may involve the operators + (add), - (subtract), * (multiply), / (divide), and ^ (power), and the following functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, atan2, sinh, cosh, tanh, erf, erfc, min, max, abs, floor, ceil, step, delta, select. All trigonometric functions are defined in radians, and log is the natural logarithm. step(x) = 0 if x < 0, 1 otherwise. delta(x) = 1 if x = 0, 0 otherwise. select(x,y,z) = z if x = 0, y otherwise.

  • Constructor Details

    • CustomVolumeForce

      public CustomVolumeForce(String energy)
      Create a CustomVolumeForce.
      Parameters:
      energy - an algebraic expression giving the energy as a function of the box shape
  • Method Details

    • addGlobalParameter

      public int addGlobalParameter(String name, double defaultValue)
      Add a new global parameter that the interaction may depend on. The default value provided to this method is the initial value of the parameter in newly created Contexts. You can change the value at any time by calling setParameter() on the Context.
      Parameters:
      name - the name of the parameter
      defaultValue - the default value of the parameter
      Returns:
      the index of the parameter that was added
    • addGlobalParameter

      public int addGlobalParameter(com.sun.jna.Pointer name, double defaultValue)
      Add a new global parameter that the energy may depend on.
      Parameters:
      name - The name of the parameter.
      defaultValue - The default value of the parameter.
      Returns:
      The index of the parameter that was added.
    • destroy

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

      public String getEnergyFunction()
      Get the algebraic expression that defines the energy.
      Returns:
      the energy expression
    • getGlobalParameterDefaultValue

      public double getGlobalParameterDefaultValue(int index)
      Get the default value of a global parameter.
      Parameters:
      index - the index of the parameter for which to get the default value
      Returns:
      the parameter default value
    • getGlobalParameterName

      public String getGlobalParameterName(int index)
      Get the name of a global parameter.
      Parameters:
      index - the index of the parameter for which to get the name
      Returns:
      the parameter name
    • getNumGlobalParameters

      public int getNumGlobalParameters()
      Get the number of global parameters that the energy depends on.
      Returns:
      The number of parameters.
    • setEnergyFunction

      public void setEnergyFunction(String energy)
      Set the algebraic expression that defines the energy.
      Parameters:
      energy - the energy expression
    • setEnergyFunction

      public void setEnergyFunction(com.sun.jna.Pointer energy)
      Set the algebraic expression that defines the energy.
      Parameters:
      energy - the energy expression
    • setGlobalParameterDefaultValue

      public void setGlobalParameterDefaultValue(int index, double defaultValue)
      Set the default value of a global parameter.
      Parameters:
      index - the index of the parameter for which to set the default value
      defaultValue - the default value of the parameter
    • setGlobalParameterName

      public void setGlobalParameterName(int index, String name)
      Set the name of a global parameter.
      Parameters:
      index - the index of the parameter for which to set the name
      name - the name of the parameter
    • setGlobalParameterName

      public void setGlobalParameterName(int index, com.sun.jna.Pointer name)
      Set the name of a global parameter.
      Parameters:
      index - the index of the parameter for which to set the name
      name - the name of the parameter
    • usesPeriodicBoundaryConditions

      public boolean usesPeriodicBoundaryConditions()
      Returns whether or not this force makes use of periodic boundary conditions. Because this class is only applicable to periodic systems, this always returns true.
      Overrides:
      usesPeriodicBoundaryConditions in class Force
      Returns:
      true if the force uses periodic boundary conditions