CustomVolumeForce¶
- class openmm.openmm.CustomVolumeForce(*args)¶
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(). Theire 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 is less than 0, 1 otherwise. delta(x) = 1 if x is 0, 0 otherwise. select(x,y,z) = z if x = 0, y otherwise.
- __init__(self, energy) CustomVolumeForce ¶
- __init__(self, other) CustomVolumeForce
Create a CustomVolumeForce.
- Parameters:
energy (str) – an algebraic expression giving the energy as a function of the box shape
Methods
__init__
(-> CustomVolumeForce)Create a CustomVolumeForce.
addGlobalParameter
(self, name, defaultValue)Add a new global parameter that the interaction may depend on.
getEnergyFunction
(self)Get the algebraic expression that defines the energy.
getForceGroup
(self)Get the force group this Force belongs to.
getGlobalParameterDefaultValue
(self, index)Get the default value of a global parameter.
getGlobalParameterName
(self, index)Get the name of a global parameter.
getName
(self)Get the name of this Force.
getNumGlobalParameters
(self)Get the number of global parameters that the energy depends on.
setEnergyFunction
(self, energy)Set the algebraic expression that defines the energy.
setForceGroup
(self, group)Set the force group this Force belongs to.
setGlobalParameterDefaultValue
(self, index, ...)Set the default value of a global parameter.
setGlobalParameterName
(self, index, name)Set the name of a global parameter.
setName
(self, name)Set the name of this Force.
Returns whether or not this force makes use of periodic boundary conditions.
Attributes
The membership flag
- property thisown¶
The membership flag
- getNumGlobalParameters(self) int ¶
Get the number of global parameters that the energy depends on.
- getEnergyFunction(self) str ¶
Get the algebraic expression that defines the energy.
- setEnergyFunction(self, energy)¶
Set the algebraic expression that defines the energy.
- addGlobalParameter(self, name, defaultValue) int ¶
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 (str) – the name of the parameter
defaultValue (float) – the default value of the parameter
- Returns:
the index of the parameter that was added
- Return type:
int
- getGlobalParameterName(self, index) str ¶
Get the name of a global parameter.
- Parameters:
index (int) – the index of the parameter for which to get the name
- Returns:
the parameter name
- Return type:
str
- setGlobalParameterName(self, index, name)¶
Set the name of a global parameter.
- Parameters:
index (int) – the index of the parameter for which to set the name
name (str) – the name of the parameter
- getGlobalParameterDefaultValue(self, index) float ¶
Get the default value of a global parameter.
- Parameters:
index (int) – the index of the parameter for which to get the default value
- Returns:
the parameter default value
- Return type:
float
- setGlobalParameterDefaultValue(self, index, defaultValue)¶
Set the default value of a global parameter.
- Parameters:
index (int) – the index of the parameter for which to set the default value
defaultValue (float) – the default value of the parameter
- usesPeriodicBoundaryConditions(self) bool ¶
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.
- getForceGroup(self) int ¶
Get the force group this Force belongs to.
- getName(self) str ¶
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.