openmmtools.forces.FlatBottomRestraintBondForce¶
-
class
openmmtools.forces.FlatBottomRestraintBondForce(spring_constant, well_radius, *args, **kwargs)[source]¶ A restraint between two atoms using a flat potential well with harmonic walls.
This is a version of
FlatBottomRestraintForcethat can be used with OpenCL 32-bit platforms. It supports atom groups with only a single atom.Parameters: - spring_constant : simtk.unit.Quantity
The spring constant K (see energy expression above) in units compatible with joule/nanometer**2/mole.
- well_radius : simtk.unit.Quantity
The distance r0 (see energy expression above) at which the harmonic restraint is imposed in units of distance.
- restrained_atom_index1 : int
The index of the first group of atoms to restrain.
- restrained_atom_index2 : int
The index of the second group of atoms to restrain.
- controlling_parameter_name : str, optional
The name of the global parameter controlling the energy function. The default value is ‘lambda_restraints’.
Attributes: spring_constantunit.simtk.Quantity: The spring constant K (units of energy/mole/length^2).
well_radiusunit.simtk.Quantity: The distance at which the harmonic restraint is imposed (units of length).
restrained_atom_indices1The indices of the first group of restrained atoms.
restrained_atom_indices2The indices of the first group of restrained atoms.
restraint_parametersOrderedDict: The restraint parameters in dictionary form.
controlling_parameter_namestr: The name of the global parameter controlling the energy function (read-only).
Methods
addBond(self, particle1, particle2, parameters)addBond(self, particle1, particle2) -> int addEnergyParameterDerivative(self, name)Request that this Force compute the derivative of its energy with respect to a global parameter. addGlobalParameter(self, name, defaultValue)Add a new global parameter that the interaction may depend on. addPerBondParameter(self, name)Add a new per-bond parameter that the interaction may depend on. compute_standard_state_correction(…[, …])Return the standard state correction of the restraint. deserialize_xml(xml_serialization)Shortcut to deserialize the XML representation and the restore interface. distance_at_energy(potential_energy)Compute the distance at which the potential energy is potential_energy.getBondParameters(self, index)Get the force field parameters for a bond term. getEnergyFunction(self)Get the algebraic expression that gives the interaction energy for each bond getEnergyParameterDerivativeName(self, index)Get the name of a global parameter with respect to which this Force should compute the derivative of 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. getNumBonds(self)Get the number of bonds for which force field parameters have been defined. getNumEnergyParameterDerivatives(self)Get the number of global parameters with respect to which the derivative of the energy should be computed. getNumGlobalParameters(self)Get the number of global parameters that the interaction depends on. getNumPerBondParameters(self)Get the number of per-bond parameters that the interaction depends on. getPerBondParameterName(self, index)Get the name of a per-bond parameter. is_restorable(openmm_object)Check if the custom integrator or force has a restorable interface. restore_interface(openmm_object)Restore the original interface of an OpenMM custom force or integrator. setBondParameters(self, index, particle1, …)Set the force field parameters for a bond term. setEnergyFunction(self, energy)Set the algebraic expression that gives the interaction energy for each bond 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. setPerBondParameterName(self, index, name)Set the name of a per-bond parameter. setUsesPeriodicBoundaryConditions(self, periodic)Set whether this force should apply periodic boundary conditions when calculating displacements. updateParametersInContext(self, context)Update the per-bond 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) → CustomBondForce¶ __init__(self, other) -> CustomBondForce
Create a CustomBondForce.
Parameters: - energy : string
an algebraic expression giving the interaction energy between two bonded particles as a function of r, the distance between them
Methods
__init__(self, energy)__init__(self, other) -> CustomBondForce addBond(self, particle1, particle2, parameters)addBond(self, particle1, particle2) -> int addEnergyParameterDerivative(self, name)Request that this Force compute the derivative of its energy with respect to a global parameter. addGlobalParameter(self, name, defaultValue)Add a new global parameter that the interaction may depend on. addPerBondParameter(self, name)Add a new per-bond parameter that the interaction may depend on. compute_standard_state_correction(…[, …])Return the standard state correction of the restraint. deserialize_xml(xml_serialization)Shortcut to deserialize the XML representation and the restore interface. distance_at_energy(potential_energy)Compute the distance at which the potential energy is potential_energy.getBondParameters(self, index)Get the force field parameters for a bond term. getEnergyFunction(self)Get the algebraic expression that gives the interaction energy for each bond getEnergyParameterDerivativeName(self, index)Get the name of a global parameter with respect to which this Force should compute the derivative of 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. getNumBonds(self)Get the number of bonds for which force field parameters have been defined. getNumEnergyParameterDerivatives(self)Get the number of global parameters with respect to which the derivative of the energy should be computed. getNumGlobalParameters(self)Get the number of global parameters that the interaction depends on. getNumPerBondParameters(self)Get the number of per-bond parameters that the interaction depends on. getPerBondParameterName(self, index)Get the name of a per-bond parameter. is_restorable(openmm_object)Check if the custom integrator or force has a restorable interface. restore_interface(openmm_object)Restore the original interface of an OpenMM custom force or integrator. setBondParameters(self, index, particle1, …)Set the force field parameters for a bond term. setEnergyFunction(self, energy)Set the algebraic expression that gives the interaction energy for each bond 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. setPerBondParameterName(self, index, name)Set the name of a per-bond parameter. setUsesPeriodicBoundaryConditions(self, periodic)Set whether this force should apply periodic boundary conditions when calculating displacements. updateParametersInContext(self, context)Update the per-bond 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
controlling_parameter_namestr: The name of the global parameter controlling the energy function (read-only). restrained_atom_indices1The indices of the first group of restrained atoms. restrained_atom_indices2The indices of the first group of restrained atoms. restraint_parametersOrderedDict: The restraint parameters in dictionary form. spring_constantunit.simtk.Quantity: The spring constant K (units of energy/mole/length^2). well_radiusunit.simtk.Quantity: The distance at which the harmonic restraint is imposed (units of length). -
addBond(self, particle1, particle2, parameters) → int¶ addBond(self, particle1, particle2) -> int
Add a bond term to the force field.
Parameters: - particle1 : int
the index of the first particle connected by the bond
- particle2 : int
the index of the second particle connected by the bond
- parameters : vector< double >
the list of parameters for the new bond
Returns: - int
the index of the bond that was added
-
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
-
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
-
addPerBondParameter(self, name) → int¶ Add a new per-bond 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
-
compute_standard_state_correction(thermodynamic_state, square_well=False, radius_cutoff=None, energy_cutoff=None, max_volume=None)¶ Return the standard state correction of the restraint.
The standard state correction is computed as
- log(V_standard / V_restraint)
where V_standard is the volume at standard state concentration and V_restraint is the restraint volume. V_restraint is bounded by the volume of the periodic box.
The
square_wellparameter, can be used to re-compute the standard state correction when removing the bias introduced by the restraint.Parameters: - thermodynamic_state : states.ThermodynamicState
The thermodynamic state at which to compute the standard state correction.
- square_well : bool, optional
If True, this computes the standard state correction assuming the restraint to obey a square well potential. The energy cutoff is still applied to the original energy potential.
- radius_cutoff : simtk.unit.Quantity, optional
The maximum distance achievable by the restraint (units compatible with nanometers). This is equivalent to placing a hard wall potential at this distance.
- energy_cutoff : float, optional
The maximum potential energy achievable by the restraint in kT. This is equivalent to placing a hard wall potential at a distance such that
potential_energy(distance) == energy_cutoff.- max_volume : simtk.unit.Quantity or ‘system’, optional
The volume of the periodic box (units compatible with nanometer**3). This must be provided the thermodynamic state is in NPT. If the string ‘system’ is passed, the maximum volume is computed from the system box vectors (this has no effect if the system is not periodic).
Returns: - correction : float
The unit-less standard state correction in kT at the given thermodynamic state.
Raises: - TypeError
If the thermodynamic state is in the NPT ensemble, and
max_volumeis not provided, or if the system is non-periodic and no cutoff is given.
-
controlling_parameter_name¶ str: The name of the global parameter controlling the energy function (read-only).
-
classmethod
deserialize_xml(xml_serialization)¶ Shortcut to deserialize the XML representation and the restore interface.
Parameters: - xml_serialization : str
The XML representation of the OpenMM custom force/integrator.
Returns: - openmm_object
The deserialized OpenMM force/integrator with the original interface restored (if restorable).
-
distance_at_energy(potential_energy)¶ Compute the distance at which the potential energy is
potential_energy.Parameters: - potential_energy : simtk.unit.Quantity
The potential energy of the restraint (units of energy/mole).
Returns: - distance : simtk.unit.Quantity
The distance at which the potential energy is
potential_energy(units of length).
-
getBondParameters(self, index)¶ Get the force field parameters for a bond term.
Parameters: - index : int
the index of the bond for which to get parameters
Returns: - particle1 : int
the index of the first particle connected by the bond
- particle2 : int
the index of the second particle connected by the bond
- parameters : vector< double >
the list of parameters for the bond
-
getEnergyFunction(self) → std::string const &¶ Get the algebraic expression that gives the interaction energy for each bond
-
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
-
getForceGroup(self) → int¶ Get the force group this Force belongs to.
-
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
-
getNumBonds(self) → int¶ Get the number of bonds for which force field parameters have been defined.
-
getNumEnergyParameterDerivatives(self) → int¶ Get the number of global parameters with respect to which the derivative of the energy should be computed.
-
getNumGlobalParameters(self) → int¶ Get the number of global parameters that the interaction depends on.
-
getNumPerBondParameters(self) → int¶ Get the number of per-bond parameters that the interaction depends on.
-
getPerBondParameterName(self, index) → std::string const &¶ Get the name of a per-bond parameter.
Parameters: - index : int
the index of the parameter for which to get the name
Returns: - string
the parameter name
-
classmethod
is_restorable(openmm_object)¶ Check if the custom integrator or force has a restorable interface.
Parameters: - openmm_object : object
The custom integrator or force to check.
Returns: - True if the object has a restorable interface, False otherwise.
-
classmethod
restore_interface(openmm_object)¶ Restore the original interface of an OpenMM custom force or integrator.
The function restore the methods of the original class that inherited from
RestorableOpenMMObject. Return False if the interface could not be restored.Parameters: - openmm_object : object
The object to restore.
Returns: - True if the original class interface could be restored, False otherwise.
-
restrained_atom_indices1¶ The indices of the first group of restrained atoms.
-
restrained_atom_indices2¶ The indices of the first group of restrained atoms.
-
restraint_parameters¶ OrderedDict: The restraint parameters in dictionary form.
-
setBondParameters(self, index, particle1, particle2, parameters) setBondParameters(self, index, particle1, particle2)¶ Set the force field parameters for a bond term.
Parameters: - index : int
the index of the bond for which to set parameters
- particle1 : int
the index of the first particle connected by the bond
- particle2 : int
the index of the second particle connected by the bond
- parameters : vector< double >
the list of parameters for the bond
-
setEnergyFunction(self, energy)¶ Set the algebraic expression that gives the interaction energy for each bond
-
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).
-
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
-
setPerBondParameterName(self, index, name)¶ Set the name of a per-bond parameter.
Parameters: - index : int
the index of the parameter for which to set the name
- name : string
the name of the parameter
-
setUsesPeriodicBoundaryConditions(self, periodic)¶ Set whether this force should apply periodic boundary conditions when calculating displacements. Usually this is not appropriate for bonded forces, but there are situations when it can be useful.
-
spring_constant¶ unit.simtk.Quantity: The spring constant K (units of energy/mole/length^2).
-
updateParametersInContext(self, context)¶ Update the per-bond 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 setBondParameters() 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-bond parameters. All other aspects of the Force (such as the energy function) are unaffected and can only be changed by reinitializing the Context. The set of particles involved in a bond cannot be changed, nor can new bonds be added.
-
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
-
well_radius¶ unit.simtk.Quantity: The distance at which the harmonic restraint is imposed (units of length).