OpenMM
|
This class implements nonbonded interactions between particles. More...
Public Member Functions | |
def | getNumParticles |
getNumParticles(CustomNonbondedForce self) -> int | |
def | getNumExclusions |
getNumExclusions(CustomNonbondedForce self) -> int | |
def | getNumPerParticleParameters |
getNumPerParticleParameters(CustomNonbondedForce self) -> int | |
def | getNumGlobalParameters |
getNumGlobalParameters(CustomNonbondedForce self) -> int | |
def | getNumFunctions |
getNumFunctions(CustomNonbondedForce self) -> int | |
def | getEnergyFunction |
getEnergyFunction(CustomNonbondedForce self) -> std::string const & | |
def | setEnergyFunction |
setEnergyFunction(CustomNonbondedForce self, std::string const & energy) | |
def | getNonbondedMethod |
getNonbondedMethod(CustomNonbondedForce self) -> OpenMM::CustomNonbondedForce::NonbondedMethod | |
def | setNonbondedMethod |
setNonbondedMethod(CustomNonbondedForce self, OpenMM::CustomNonbondedForce::NonbondedMethod method) | |
def | getCutoffDistance |
getCutoffDistance(CustomNonbondedForce self) -> double | |
def | setCutoffDistance |
setCutoffDistance(CustomNonbondedForce self, double distance) | |
def | addPerParticleParameter |
addPerParticleParameter(CustomNonbondedForce self, std::string const & name) -> int | |
def | getPerParticleParameterName |
getPerParticleParameterName(CustomNonbondedForce self, int index) -> std::string const & | |
def | setPerParticleParameterName |
setPerParticleParameterName(CustomNonbondedForce self, int index, std::string const & name) | |
def | addGlobalParameter |
addGlobalParameter(CustomNonbondedForce self, std::string const & name, double defaultValue) -> int | |
def | getGlobalParameterName |
getGlobalParameterName(CustomNonbondedForce self, int index) -> std::string const & | |
def | setGlobalParameterName |
setGlobalParameterName(CustomNonbondedForce self, int index, std::string const & name) | |
def | getGlobalParameterDefaultValue |
getGlobalParameterDefaultValue(CustomNonbondedForce self, int index) -> double | |
def | setGlobalParameterDefaultValue |
setGlobalParameterDefaultValue(CustomNonbondedForce self, int index, double defaultValue) | |
def | addParticle |
addParticle(CustomNonbondedForce self, vectord parameters) -> int | |
def | getParticleParameters |
getParticleParameters(CustomNonbondedForce self, int index) | |
def | setParticleParameters |
setParticleParameters(CustomNonbondedForce self, int index, vectord parameters) | |
def | addExclusion |
addExclusion(CustomNonbondedForce self, int particle1, int particle2) -> int | |
def | getExclusionParticles |
getExclusionParticles(CustomNonbondedForce self, int index) | |
def | setExclusionParticles |
setExclusionParticles(CustomNonbondedForce self, int index, int particle1, int particle2) | |
def | addFunction |
addFunction(CustomNonbondedForce self, std::string const & name, vectord values, double min, double max) -> int | |
def | getFunctionParameters |
getFunctionParameters(CustomNonbondedForce self, int index) | |
def | setFunctionParameters |
setFunctionParameters(CustomNonbondedForce self, int index, std::string const & name, vectord values, double min, double max) | |
def | updateParametersInContext |
updateParametersInContext(CustomNonbondedForce self, Context context) | |
def | __init__ |
init(OpenMM::CustomNonbondedForce self, std::string const & energy) -> CustomNonbondedForce init(OpenMM::CustomNonbondedForce self, CustomNonbondedForce other) -> CustomNonbondedForce | |
def | __del__ |
del(OpenMM::CustomNonbondedForce self) | |
Public Member Functions inherited from Force | |
def | __init__ |
def | __del__ |
del(OpenMM::Force self) | |
def | getForceGroup |
getForceGroup(Force self) -> int | |
def | setForceGroup |
setForceGroup(Force self, int group) | |
def | __copy__ |
def | __deepcopy__ |
Public Attributes | |
this | |
Static Public Attributes | |
NoCutoff _openmm.CustomNonbondedForce_NoCutoff | |
CutoffNonPeriodic _openmm.CustomNonbondedForce_CutoffNonPeriodic | |
CutoffPeriodic _openmm.CustomNonbondedForce_CutoffPeriodic | |
This class implements nonbonded interactions between particles.
Unlike NonbondedForce, the functional form of the interaction is completely customizable, and may involve arbitrary algebraic expressions and tabulated functions. It may depend on the distance between particles, as well as on arbitrary global and per-particle parameters. It also optionally supports periodic boundary conditions and cutoffs for long range interactions.
To use this class, create a CustomNonbondedForce object, passing an algebraic expression to the constructor that defines the interaction energy between each pair of particles. The expression may depend on r, the distance between the particles, as well as on any parameters you choose. Then call addPerParticleParameter() to define per-particle parameters, and addGlobalParameter() to define global parameters. The values of per-particle parameters are specified as part of the system definition, while values of global parameters may be modified during a simulation by calling Context::setParameter().
Next, call addParticle() once for each particle in the System to set the values of its per-particle parameters. The number of particles for which you set 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 parameters by calling setParticleParameters(). This will have no effect on Contexts that already exist unless you call updateParametersInContext().
CustomNonbondedForce also lets you specify "exclusions", particular pairs of particles whose interactions should be omitted from force and energy calculations. This is most often used for particles that are bonded to each other.
As an example, the following code creates a CustomNonbondedForce that implements a 12-6 Lennard-Jones potential:
CustomNonbondedForce* force = new CustomNonbondedForce("4*epsilon*((sigma/r)^12-(sigma/r)^6); sigma=0.5*(sigma1+sigma2); epsilon=sqrt(epsilon1*epsilon2)");
This force depends on two parameters: sigma and epsilon. The following code defines these as per-particle parameters:
force->addPerParticleParameter("sigma"); force->addPerParticleParameter("epsilon");
The expression must be symmetric with respect to the two particles. It typically will only be evaluated once for each pair of particles, and no guarantee is made about which particle will be identified as "particle 1". In the above example, the energy only depends on the products sigma1*sigma2 and epsilon1*epsilon2, both of which are unchanged if the labels 1 and 2 are reversed. In contrast, if it depended on the difference sigma1-sigma2, the results would be undefined, because reversing the labels 1 and 2 would change the energy.
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, sinh, cosh, tanh, erf, erfc, min, max, abs, step, delta. 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. The names of per-particle parameters have the suffix "1" or "2" appended to them to indicate the values for the two interacting particles. As seen in the above example, the expression may also involve intermediate quantities that are defined following the main expression, using ";" as a separator.
In addition, you can call addFunction() to define a new function based on tabulated values. You specify a vector of values, and a natural spline is created from them. That function can then appear in the expression.
def __init__ | ( | self, | |
args | |||
) |
init(OpenMM::CustomNonbondedForce self, std::string const & energy) -> CustomNonbondedForce init(OpenMM::CustomNonbondedForce self, CustomNonbondedForce other) -> CustomNonbondedForce
Create a CustomNonbondedForce.
energy | an algebraic expression giving the interaction energy between two particles as a function of r, the distance between them, as well as any global and per-particle parameters |
def __del__ | ( | self | ) |
del(OpenMM::CustomNonbondedForce self)
def addExclusion | ( | self, | |
args | |||
) |
addExclusion(CustomNonbondedForce self, int particle1, int particle2) -> int
Add a particle pair to the list of interactions that should be excluded.
particle1 | the index of the first particle in the pair |
particle2 | the index of the second particle in the pair |
def addFunction | ( | self, | |
args | |||
) |
addFunction(CustomNonbondedForce self, std::string const & name, vectord values, double min, double max) -> int
Add a tabulated function that may appear in the energy expression.
name | the name of the function as it appears in expressions |
values | the tabulated values of the function f(x) at uniformly spaced values of x between min and max. The function is assumed to be zero for x < min or x > max. |
min | the value of the independent variable corresponding to the first element of values |
max | the value of the independent variable corresponding to the last element of values |
def addGlobalParameter | ( | self, | |
args | |||
) |
addGlobalParameter(CustomNonbondedForce self, std::string const & name, double defaultValue) -> int
Add a new global parameter that the interaction may depend on.
name | the name of the parameter |
defaultValue | the default value of the parameter |
def addParticle | ( | self, | |
args | |||
) |
addParticle(CustomNonbondedForce self, vectord parameters) -> int
Add the nonbonded force 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 | the list of parameters for the new particle |
def addPerParticleParameter | ( | self, | |
args | |||
) |
addPerParticleParameter(CustomNonbondedForce self, std::string const & name) -> int
Add a new per-particle parameter that the interaction may depend on.
name | the name of the parameter |
def getCutoffDistance | ( | self | ) |
getCutoffDistance(CustomNonbondedForce self) -> double
Get the cutoff distance (in nm) being used for nonbonded interactions. If the NonbondedMethod in use is NoCutoff, this value will have no effect.
def getEnergyFunction | ( | self | ) |
getEnergyFunction(CustomNonbondedForce self) -> std::string const &
Get the algebraic expression that gives the interaction energy between two particles
def getExclusionParticles | ( | self, | |
args | |||
) |
getExclusionParticles(CustomNonbondedForce self, int index)
Get the particles in a pair whose interaction should be excluded.
index | the index of the exclusion for which to get particle indices |
particle1 | the index of the first particle in the pair |
particle2 | the index of the second particle in the pair |
def getFunctionParameters | ( | self, | |
args | |||
) |
getFunctionParameters(CustomNonbondedForce self, int index)
Get the parameters for a tabulated function that may appear in the energy expression.
index | the index of the function for which to get parameters |
name | the name of the function as it appears in expressions |
values | the tabulated values of the function f(x) at uniformly spaced values of x between min and max. The function is assumed to be zero for x < min or x > max. |
min | the value of the independent variable corresponding to the first element of values |
max | the value of the independent variable corresponding to the last element of values |
def getGlobalParameterDefaultValue | ( | self, | |
args | |||
) |
getGlobalParameterDefaultValue(CustomNonbondedForce self, int index) -> double
Get the default value of a global parameter.
index | the index of the parameter for which to get the default value |
def getGlobalParameterName | ( | self, | |
args | |||
) |
getGlobalParameterName(CustomNonbondedForce self, int index) -> std::string const &
Get the name of a global parameter.
index | the index of the parameter for which to get the name |
def getNonbondedMethod | ( | self | ) |
getNonbondedMethod(CustomNonbondedForce self) -> OpenMM::CustomNonbondedForce::NonbondedMethod
Get the method used for handling long range nonbonded interactions.
def getNumExclusions | ( | self | ) |
getNumExclusions(CustomNonbondedForce self) -> int
Get the number of particle pairs whose interactions should be excluded.
def getNumFunctions | ( | self | ) |
getNumFunctions(CustomNonbondedForce self) -> int
Get the number of tabulated functions that have been defined.
def getNumGlobalParameters | ( | self | ) |
getNumGlobalParameters(CustomNonbondedForce self) -> int
Get the number of global parameters that the interaction depends on.
def getNumParticles | ( | self | ) |
getNumParticles(CustomNonbondedForce self) -> int
Get the number of particles for which force field parameters have been defined.
def getNumPerParticleParameters | ( | self | ) |
getNumPerParticleParameters(CustomNonbondedForce self) -> int
Get the number of per-particle parameters that the interaction depends on.
def getParticleParameters | ( | self, | |
args | |||
) |
getParticleParameters(CustomNonbondedForce self, int index)
Get the nonbonded force parameters for a particle.
index | the index of the particle for which to get parameters |
parameters | the list of parameters for the specified particle |
def getPerParticleParameterName | ( | self, | |
args | |||
) |
getPerParticleParameterName(CustomNonbondedForce self, int index) -> std::string const &
Get the name of a per-particle parameter.
index | the index of the parameter for which to get the name |
def setCutoffDistance | ( | self, | |
args | |||
) |
setCutoffDistance(CustomNonbondedForce self, double distance)
Set the cutoff distance (in nm) being used for nonbonded interactions. If the NonbondedMethod in use is NoCutoff, this value will have no effect.
distance | the cutoff distance, measured in nm |
def setEnergyFunction | ( | self, | |
args | |||
) |
setEnergyFunction(CustomNonbondedForce self, std::string const & energy)
Set the algebraic expression that gives the interaction energy between two particles
def setExclusionParticles | ( | self, | |
args | |||
) |
setExclusionParticles(CustomNonbondedForce self, int index, int particle1, int particle2)
Set the particles in a pair whose interaction should be excluded.
index | the index of the exclusion for which to set particle indices |
particle1 | the index of the first particle in the pair |
particle2 | the index of the second particle in the pair |
def setFunctionParameters | ( | self, | |
args | |||
) |
setFunctionParameters(CustomNonbondedForce self, int index, std::string const & name, vectord values, double min, double max)
Set the parameters for a tabulated function that may appear in algebraic expressions.
index | the index of the function for which to set parameters |
name | the name of the function as it appears in expressions |
values | the tabulated values of the function f(x) at uniformly spaced values of x between min and max. The function is assumed to be zero for x < min or x > max. |
min | the value of the independent variable corresponding to the first element of values |
max | the value of the independent variable corresponding to the last element of values |
def setGlobalParameterDefaultValue | ( | self, | |
args | |||
) |
setGlobalParameterDefaultValue(CustomNonbondedForce self, int index, double defaultValue)
Set the default value of a global parameter.
index | the index of the parameter for which to set the default value |
name | the default value of the parameter |
def setGlobalParameterName | ( | self, | |
args | |||
) |
setGlobalParameterName(CustomNonbondedForce self, int index, std::string const & name)
Set the name of a global parameter.
index | the index of the parameter for which to set the name |
name | the name of the parameter |
def setNonbondedMethod | ( | self, | |
args | |||
) |
setNonbondedMethod(CustomNonbondedForce self, OpenMM::CustomNonbondedForce::NonbondedMethod method)
Set the method used for handling long range nonbonded interactions.
def setParticleParameters | ( | self, | |
args | |||
) |
setParticleParameters(CustomNonbondedForce self, int index, vectord parameters)
Set the nonbonded force parameters for a particle.
index | the index of the particle for which to set parameters |
parameters | the list of parameters for the specified particle |
def setPerParticleParameterName | ( | self, | |
args | |||
) |
setPerParticleParameterName(CustomNonbondedForce self, int index, std::string const & name)
Set the name of a per-particle parameter.
index | the index of the parameter for which to set the name |
name | the name of the parameter |
def updateParametersInContext | ( | self, | |
args | |||
) |
updateParametersInContext(CustomNonbondedForce self, Context context)
Update the per-particle 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() to modify this object's parameters, then call updateParametersInState() to copy them over to the Context.
This method has several limitations. The only information it updates is the values of per-particle parameters. All other aspects of the Force (the energy function, nonbonded method, cutoff distance, etc.) are unaffected and can only be changed by reinitializing the Context. Also, this method cannot be used to add new particles, only to change the parameters of existing ones.
|
static |
|
static |
|
static |
this |