nanover.openmm.potentials module
Helpers around useful potentials that can be applied to OpenMM systems.
- nanover.openmm.potentials.restrain_particles(positions: Quantity, particle_indices: Iterable[int], force_constant: Quantity = Quantity(value=100, unit=kilojoule / nanometer**2 * mole))
Generate an OpenMM force that restrains the position of the selected particles.
Apply a harmonic potential to restrain the position of the selected particles. The particles are restrained to their positions in the given position array (usually the initial positions).
See
restraint_force()
for the details of the potential.- Parameters:
positions – The positions of all the particles in the system.
particle_indices – The indices in the system of the particles to restrain.
force_constant – The force constant for the harmonic potential.
- Returns:
The populated OpenMM force to add to the OpenMM system.
- nanover.openmm.potentials.restraint_force(force_constant: Quantity = Quantity(value=100, unit=kilojoule / nanometer**2 * mole))
Generate an OpenMM force for position restraints.
The position of the selected atoms is restrained with a harmonic potential the form of which is \(k * distance(r, r0)^2\); where \(k\) is the force constant in kJ/(mol * nm^2), \(r\) is the position of the atom, and \(r0\) is the equilibrium position of that atom.
>>> from openmm.unit import kilojoule_per_mole, nanometer >>> # Create the force >>> force_constant = 225 * kilojoule_per_mole / nanometer ** 2 >>> force = restraint_force(force_constant) >>> # Add particles to the force >>> force.addParticle(0, [10 * nanometer, 8 * nanometer, 2.3 * nanometer]) >>> force.addParticle(2, [12 * nanometer, 8.4 * nanometer, 0.8 * nanometer]) >>> # Add the force to the system >>> my_system.addForce(force)
Note
Like any force in OpenMM, the position restraints need to be added to the system before a context is created from the molecular system.
- Parameters:
force_constant – The force constant, \(k\). The value is expected to be a
Quantity
, it will be converted to kJ/(mol * nm^2).- Returns:
An OpenMM force to add to the system.