openmmtools.forces.UnshiftedReactionFieldForce¶
-
class
openmmtools.forces.UnshiftedReactionFieldForce(cutoff_distance=Quantity(value=15, unit=angstrom), switch_width=Quantity(value=1.0, unit=angstrom), reaction_field_dielectric=78.3)[source]¶ A force modelling switched reaction-field electrostatics.
Contrarily to a normal NonbondedForce with CutoffPeriodic nonbonded method, this force sets the c_rf to 0.0 and uses a switching function to avoid forces discontinuities at the cutoff distance.
Parameters: - cutoff_distance : simtk.unit.Quantity, default 15*angstroms
The cutoff distance (units of distance).
- switch_width : simtk.unit.Quantity, default 1.0*angstrom
Switch width for electrostatics (units of distance).
- reaction_field_dielectric : float
The dielectric constant used for the solvent.
Methods
addEnergyParameterDerivative(self, name)Request that this Force compute the derivative of its energy with respect to a global parameter. addExclusion(self, particle1, particle2)Add a particle pair to the list of interactions that should be excluded. addFunction(self, name, values, min, max)Add a tabulated function that may appear in the energy expression. addGlobalParameter(self, name, defaultValue)Add a new global parameter that the interaction may depend on. addInteractionGroup(self, set1, set2)Add an interaction group. addParticle(self, parameters)addParticle(self) -> int addPerParticleParameter(self, name)Add a new per-particle parameter that the interaction may depend on. addTabulatedFunction(self, name, function)Add a tabulated function that may appear in the energy expression. createExclusionsFromBonds(self, bonds, …)Identify exclusions based on the molecular topology. from_nonbonded_force(nonbonded_force[, …])Copy constructor from an OpenMM NonbondedForce. from_system(system[, switch_width, unit])Copy constructor from the first OpenMM NonbondedForce in system. getCutoffDistance(self)Get the cutoff distance (in nm) being used for nonbonded interactions. getEnergyFunction(self)Get the algebraic expression that gives the interaction energy between two particles getEnergyParameterDerivativeName(self, index)Get the name of a global parameter with respect to which this Force should compute the derivative of the energy. getExclusionParticles(self, index)Get the particles in a pair whose interaction should be excluded. getForceGroup(self)Get the force group this Force belongs to. getFunctionParameters(self, index)Get the parameters for a tabulated function that may appear in the energy expression. getGlobalParameterDefaultValue(self, index)Get the default value of a global parameter. getGlobalParameterName(self, index)Get the name of a global parameter. getInteractionGroupParameters(self, index)Get the parameters for an interaction group. getNonbondedMethod(self)Get the method used for handling long range nonbonded interactions. getNumEnergyParameterDerivatives(self)Get the number of global parameters with respect to which the derivative of the energy should be computed. getNumExclusions(self)Get the number of particle pairs whose interactions should be excluded. getNumFunctions(self)Get the number of tabulated functions that have been defined. getNumGlobalParameters(self)Get the number of global parameters that the interaction depends on. getNumInteractionGroups(self)Get the number of interaction groups that have been defined. getNumParticles(self)Get the number of particles for which force field parameters have been defined. getNumPerParticleParameters(self)Get the number of per-particle parameters that the interaction depends on. getNumTabulatedFunctions(self)Get the number of tabulated functions that have been defined. getParticleParameters(self, index)Get the nonbonded force parameters for a particle. getPerParticleParameterName(self, index)Get the name of a per-particle parameter. getSwitchingDistance(self)Get the distance at which the switching function begins to reduce the interaction. getTabulatedFunction(self, index)getTabulatedFunction(self, index) -> TabulatedFunction getTabulatedFunctionName(self, index)Get the name of a tabulated function that may appear in the energy expression. getUseLongRangeCorrection(self)Get whether to add a correction to the energy to compensate for the cutoff and switching function. getUseSwitchingFunction(self)Get whether a switching function is applied to the interaction. setCutoffDistance(self, distance)Set the cutoff distance (in nm) being used for nonbonded interactions. setEnergyFunction(self, energy)Set the algebraic expression that gives the interaction energy between two particles setExclusionParticles(self, index, …)Set the particles in a pair whose interaction should be excluded. setForceGroup(self, group)Set the force group this Force belongs to. setFunctionParameters(self, index, name, …)Set the parameters for a tabulated function that may appear in the energy expression. setGlobalParameterDefaultValue(self, index, …)Set the default value of a global parameter. setGlobalParameterName(self, index, name)Set the name of a global parameter. setInteractionGroupParameters(self, index, …)Set the parameters for an interaction group. setNonbondedMethod(self, method)Set the method used for handling long range nonbonded interactions. setParticleParameters(self, index, parameters)Set the nonbonded force parameters for a particle. setPerParticleParameterName(self, index, name)Set the name of a per-particle parameter. setSwitchingDistance(self, distance)Set the distance at which the switching function begins to reduce the interaction. setUseLongRangeCorrection(self, use)Set whether to add a correction to the energy to compensate for the cutoff and switching function. setUseSwitchingFunction(self, use)Set whether a switching function is applied to the interaction. updateParametersInContext(self, context)Update the per-particle 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. -
__init__(self, energy) → CustomNonbondedForce[source]¶ __init__(self, rhs) -> CustomNonbondedForce
Create a CustomNonbondedForce.
Parameters: - energy : string
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
Methods
__init__(self, energy)__init__(self, rhs) -> CustomNonbondedForce addEnergyParameterDerivative(self, name)Request that this Force compute the derivative of its energy with respect to a global parameter. addExclusion(self, particle1, particle2)Add a particle pair to the list of interactions that should be excluded. addFunction(self, name, values, min, max)Add a tabulated function that may appear in the energy expression. addGlobalParameter(self, name, defaultValue)Add a new global parameter that the interaction may depend on. addInteractionGroup(self, set1, set2)Add an interaction group. addParticle(self, parameters)addParticle(self) -> int addPerParticleParameter(self, name)Add a new per-particle parameter that the interaction may depend on. addTabulatedFunction(self, name, function)Add a tabulated function that may appear in the energy expression. createExclusionsFromBonds(self, bonds, …)Identify exclusions based on the molecular topology. from_nonbonded_force(nonbonded_force[, …])Copy constructor from an OpenMM NonbondedForce. from_system(system[, switch_width, unit])Copy constructor from the first OpenMM NonbondedForce in system. getCutoffDistance(self)Get the cutoff distance (in nm) being used for nonbonded interactions. getEnergyFunction(self)Get the algebraic expression that gives the interaction energy between two particles getEnergyParameterDerivativeName(self, index)Get the name of a global parameter with respect to which this Force should compute the derivative of the energy. getExclusionParticles(self, index)Get the particles in a pair whose interaction should be excluded. getForceGroup(self)Get the force group this Force belongs to. getFunctionParameters(self, index)Get the parameters for a tabulated function that may appear in the energy expression. getGlobalParameterDefaultValue(self, index)Get the default value of a global parameter. getGlobalParameterName(self, index)Get the name of a global parameter. getInteractionGroupParameters(self, index)Get the parameters for an interaction group. getNonbondedMethod(self)Get the method used for handling long range nonbonded interactions. getNumEnergyParameterDerivatives(self)Get the number of global parameters with respect to which the derivative of the energy should be computed. getNumExclusions(self)Get the number of particle pairs whose interactions should be excluded. getNumFunctions(self)Get the number of tabulated functions that have been defined. getNumGlobalParameters(self)Get the number of global parameters that the interaction depends on. getNumInteractionGroups(self)Get the number of interaction groups that have been defined. getNumParticles(self)Get the number of particles for which force field parameters have been defined. getNumPerParticleParameters(self)Get the number of per-particle parameters that the interaction depends on. getNumTabulatedFunctions(self)Get the number of tabulated functions that have been defined. getParticleParameters(self, index)Get the nonbonded force parameters for a particle. getPerParticleParameterName(self, index)Get the name of a per-particle parameter. getSwitchingDistance(self)Get the distance at which the switching function begins to reduce the interaction. getTabulatedFunction(self, index)getTabulatedFunction(self, index) -> TabulatedFunction getTabulatedFunctionName(self, index)Get the name of a tabulated function that may appear in the energy expression. getUseLongRangeCorrection(self)Get whether to add a correction to the energy to compensate for the cutoff and switching function. getUseSwitchingFunction(self)Get whether a switching function is applied to the interaction. setCutoffDistance(self, distance)Set the cutoff distance (in nm) being used for nonbonded interactions. setEnergyFunction(self, energy)Set the algebraic expression that gives the interaction energy between two particles setExclusionParticles(self, index, …)Set the particles in a pair whose interaction should be excluded. setForceGroup(self, group)Set the force group this Force belongs to. setFunctionParameters(self, index, name, …)Set the parameters for a tabulated function that may appear in the energy expression. setGlobalParameterDefaultValue(self, index, …)Set the default value of a global parameter. setGlobalParameterName(self, index, name)Set the name of a global parameter. setInteractionGroupParameters(self, index, …)Set the parameters for an interaction group. setNonbondedMethod(self, method)Set the method used for handling long range nonbonded interactions. setParticleParameters(self, index, parameters)Set the nonbonded force parameters for a particle. setPerParticleParameterName(self, index, name)Set the name of a per-particle parameter. setSwitchingDistance(self, distance)Set the distance at which the switching function begins to reduce the interaction. setUseLongRangeCorrection(self, use)Set whether to add a correction to the energy to compensate for the cutoff and switching function. setUseSwitchingFunction(self, use)Set whether a switching function is applied to the interaction. updateParametersInContext(self, context)Update the per-particle 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
CutoffNonPeriodicCutoffPeriodicNoCutoff-
addEnergyParameterDerivative(self, name)¶ Request that this Force compute the derivative of its energy with respect to a global parameter. The parameter must have already been added with addGlobalParameter().
Parameters: - name : string
the name of the parameter
-
addExclusion(self, particle1, particle2) → int¶ Add a particle pair to the list of interactions that should be excluded.
In many cases, you can use createExclusionsFromBonds() rather than adding each exclusion explicitly.
Parameters: - particle1 : int
the index of the first particle in the pair
- particle2 : int
the index of the second particle in the pair
Returns: - int
the index of the exclusion that was added
-
addFunction(self, name, values, min, max) → int¶ Add a tabulated function that may appear in the energy expression.
@deprecated This method exists only for backward compatibility. Use addTabulatedFunction() instead.
-
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 : string
the name of the parameter
- defaultValue : double
the default value of the parameter
Returns: - int
the index of the parameter that was added
-
addInteractionGroup(self, set1, set2) → int¶ Add an interaction group. An interaction will be computed between every particle in set1 and every particle in set2.
Parameters: - set1 : set< int >
the first set of particles forming the interaction group
- set2 : set< int >
the second set of particles forming the interaction group
Returns: - int
the index of the interaction group that was added
-
addParticle(self, parameters) → int¶ addParticle(self) -> 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: - parameters : vector< double >
the list of parameters for the new particle
Returns: - int
the index of the particle that was added
-
addPerParticleParameter(self, name) → int¶ Add a new per-particle parameter that the interaction may depend on.
Parameters: - name : string
the name of the parameter
Returns: - int
the index of the parameter that was added
-
addTabulatedFunction(self, name, function) → int¶ Add a tabulated function that may appear in the energy expression.
Parameters: - name : string
the name of the function as it appears in expressions
- function : TabulatedFunction *
a TabulatedFunction object defining the function. The TabulatedFunction should have been created on the heap with the “new” operator. The Force takes over ownership of it, and deletes it when the Force itself is deleted.
Returns: - int
the index of the function that was added
-
createExclusionsFromBonds(self, bonds, bondCutoff)¶ Identify exclusions based on the molecular topology. Particles which are separated by up to a specified number of bonds are added as exclusions.
Parameters: - bonds : vector< std::pair< int, int > >
the set of bonds based on which to construct exclusions. Each element specifies the indices of two particles that are bonded to each other.
- bondCutoff : int
pairs of particles that are separated by this many bonds or fewer are added to the list of exclusions
-
classmethod
from_nonbonded_force(nonbonded_force, switch_width=Quantity(value=1.0, unit=angstrom))[source]¶ Copy constructor from an OpenMM NonbondedForce.
The returned force has same cutoff distance and dielectric, and its particles have the same charges. Exclusions corresponding to nonbonded_force exceptions are also added.
Parameters: - nonbonded_force : simtk.openmm.NonbondedForce
The nonbonded force to copy.
- switch_width : simtk.unit.Quantity
Switch width for electrostatics (units of distance).
Returns: - reaction_field_force : UnshiftedReactionFieldForce
The reaction field force with copied particles.
-
classmethod
from_system(system, switch_width=Quantity(value=1.0, unit=angstrom))[source]¶ Copy constructor from the first OpenMM NonbondedForce in system.
If multiple `NonbondedForce`s are found, an exception is raised.
Parameters: - system : simtk.openmm.System
The system containing the nonbonded force to copy.
- switch_width : simtk.unit.Quantity
Switch width for electrostatics (units of distance).
Returns: - reaction_field_force : UnshiftedReactionFieldForce
The reaction field force.
See also
UnshiftedReactionField.from_nonbonded_force
-
getCutoffDistance(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.
Returns: - double
the cutoff distance, measured in nm
-
getEnergyFunction(self) → std::string const &¶ Get the algebraic expression that gives the interaction energy between two particles
-
getEnergyParameterDerivativeName(self, index) → std::string const &¶ Get the name of a global parameter with respect to which this Force should compute the derivative of the energy.
Parameters: - index : int
the index of the parameter derivative, between 0 and getNumEnergyParameterDerivatives()
Returns: - string
the parameter name
-
getExclusionParticles(self, index)¶ Get the particles in a pair whose interaction should be excluded.
Parameters: - index : int
the index of the exclusion for which to get particle indices
Returns: - particle1 : int
the index of the first particle in the pair
- particle2 : int
the index of the second particle in the pair
-
getForceGroup(self) → int¶ Get the force group this Force belongs to.
-
getFunctionParameters(self, index)¶ Get the parameters for a tabulated function that may appear in the energy expression.
@deprecated This method exists only for backward compatibility. Use getTabulatedFunctionParameters() instead. If the specified function is not a Continuous1DFunction, this throws an exception.
-
getGlobalParameterDefaultValue(self, index) → double¶ Get the default value of a global parameter.
Parameters: - index : int
the index of the parameter for which to get the default value
Returns: - double
the parameter default value
-
getGlobalParameterName(self, index) → std::string const &¶ Get the name of a global parameter.
Parameters: - index : int
the index of the parameter for which to get the name
Returns: - string
the parameter name
-
getInteractionGroupParameters(self, index)¶ Get the parameters for an interaction group.
Parameters: - index : int
the index of the interaction group for which to get parameters
Returns: - set1 : set< int >
the first set of particles forming the interaction group
- set2 : set< int >
the second set of particles forming the interaction group
-
getNonbondedMethod(self) → OpenMM::CustomNonbondedForce::NonbondedMethod¶ Get the method used for handling long range nonbonded interactions.
-
getNumEnergyParameterDerivatives(self) → int¶ Get the number of global parameters with respect to which the derivative of the energy should be computed.
-
getNumExclusions(self) → int¶ Get the number of particle pairs whose interactions should be excluded.
-
getNumFunctions(self) → int¶ Get the number of tabulated functions that have been defined.
@deprecated This method exists only for backward compatibility. Use getNumTabulatedFunctions() instead.
-
getNumGlobalParameters(self) → int¶ Get the number of global parameters that the interaction depends on.
-
getNumInteractionGroups(self) → int¶ Get the number of interaction groups that have been defined.
-
getNumParticles(self) → int¶ Get the number of particles for which force field parameters have been defined.
-
getNumPerParticleParameters(self) → int¶ Get the number of per-particle parameters that the interaction depends on.
-
getNumTabulatedFunctions(self) → int¶ Get the number of tabulated functions that have been defined.
-
getParticleParameters(self, index)¶ Get the nonbonded force parameters for a particle.
Parameters: - index : int
the index of the particle for which to get parameters
Returns: - parameters : vector< double >
the list of parameters for the specified particle
-
getPerParticleParameterName(self, index) → std::string const &¶ Get the name of a per-particle parameter.
Parameters: - index : int
the index of the parameter for which to get the name
Returns: - string
the parameter name
-
getSwitchingDistance(self) → double¶ Get the distance at which the switching function begins to reduce the interaction. This must be less than the cutoff distance.
-
getTabulatedFunction(self, index) → TabulatedFunction¶ getTabulatedFunction(self, index) -> TabulatedFunction
Get a reference to a tabulated function that may appear in the energy expression.
Parameters: - index : int
the index of the function to get
Returns: - TabulatedFunction
the TabulatedFunction object defining the function
-
getTabulatedFunctionName(self, index) → std::string const &¶ Get the name of a tabulated function that may appear in the energy expression.
Parameters: - index : int
the index of the function to get
Returns: - string
the name of the function as it appears in expressions
-
getUseLongRangeCorrection(self) → bool¶ Get whether to add a correction to the energy to compensate for the cutoff and switching function. This has no effect if periodic boundary conditions are not used.
-
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.
-
setCutoffDistance(self, 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.
Parameters: - distance : double
the cutoff distance, measured in nm
-
setEnergyFunction(self, energy)¶ Set the algebraic expression that gives the interaction energy between two particles
-
setExclusionParticles(self, index, particle1, particle2)¶ Set the particles in a pair whose interaction should be excluded.
Parameters: - index : int
the index of the exclusion for which to set particle indices
- particle1 : int
the index of the first particle in the pair
- particle2 : int
the index of the second particle in the pair
-
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).
-
setFunctionParameters(self, index, name, values, min, max)¶ Set the parameters for a tabulated function that may appear in the energy expression.
@deprecated This method exists only for backward compatibility. Use setTabulatedFunctionParameters() instead. If the specified function is not a Continuous1DFunction, this throws an exception.
-
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 : double
the default value of the parameter
-
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 : string
the name of the parameter
-
setInteractionGroupParameters(self, index, set1, set2)¶ Set the parameters for an interaction group.
Parameters: - index : int
the index of the interaction group for which to set parameters
- set1 : set< int >
the first set of particles forming the interaction group
- set2 : set< int >
the second set of particles forming the interaction group
-
setNonbondedMethod(self, method)¶ Set the method used for handling long range nonbonded interactions.
-
setParticleParameters(self, index, parameters)¶ Set the nonbonded force parameters for a particle.
Parameters: - index : int
the index of the particle for which to set parameters
- parameters : vector< double >
the list of parameters for the specified particle
-
setPerParticleParameterName(self, index, name)¶ Set the name of a per-particle parameter.
Parameters: - index : int
the index of the parameter for which to set the name
- name : string
the name of the parameter
-
setSwitchingDistance(self, distance)¶ Set the distance at which the switching function begins to reduce the interaction. This must be less than the cutoff distance.
-
setUseLongRangeCorrection(self, use)¶ Set whether to add a correction to the energy to compensate for the cutoff and switching function. This has no effect if periodic boundary conditions are not used.
-
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.
-
updateParametersInContext(self, 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 updateParametersInContext() 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.
-
usesPeriodicBoundaryConditions(self) → bool¶ Returns whether or not this force makes use of periodic boundary conditions.
Returns: - bool
true if force uses PBC and false otherwise