HarmonicBondForce giving energy of zero
See original GitHub issueHi OpenFF - question, not necessarily a bug.
I was re-writing the force groups (in OpenMM) as Custom*Forces and noticed the HarmonicBondForce from an OpenFF-parameterized ligand has zero bond energies. Can that be correct? Perhaps the bonds were all at their minima - but even after a few simulation steps the energy is still zero. Below is a smallish example using Nemonapride. Thanks for your time!
from simtk.openmm.app import *
from simtk.openmm import *
from simtk import *
from rdkit import Chem
from rdkit.Chem import AllChem
from openff.toolkit.topology import Molecule
from openmmforcefields.generators import SMIRNOFFTemplateGenerator
#get a ligand (AQD - nemonapride):
smi = 'C[C@@H]1[C@@H](CCN1Cc2ccccc2)NC(=O)c3cc(c(cc3OC)NC)Cl'
aqd_mol = Chem.MolFromSmiles(smi)
aqd_molH = Chem.AddHs(aqd_mol)
AllChem.EmbedMolecule(aqd_molH)
Chem.MolToPDBFile(aqd_molH, 'AQD_ligand.pdb')
# Create an OpenFF Molecule object
molecule = Molecule.from_rdkit(aqd_molH)
molecule.assign_partial_charges('gasteiger')
gen = SMIRNOFFTemplateGenerator(molecules=molecule)
## Create an OpenMM ForceField object
forcefield = app.ForceField('amber/protein.ff14SB.xml')
# Register the template generator
forcefield.registerTemplateGenerator(gen.generator)
# load PDB file
pdb = PDBFile('AQD_ligand.pdb')
system = forcefield.createSystem(pdb.topology, nonbondedMethod=app.CutoffNonPeriodic,
nonbondedCutoff=0.9*unit.nanometer,constraints=None)
for c, f in enumerate(system.getForces()):
f.setForceGroup(c)
# make a simulation and print energies:
integrator = openmm.LangevinIntegrator(50*unit.kelvin, 1/unit.picosecond, 1*unit.femtosecond)
platform = openmm.Platform.getPlatformByName('CPU')
simulation = app.Simulation(pdb.topology, system, integrator, platform)
simulation.context.setPositions(pdb.positions)
forces = system.getForces()
for c, f in enumerate(forces):
original_energy = simulation.context.getState(getEnergy=True,groups=c).getPotentialEnergy()
print(original_energy, f)
output:
0.0 kJ/mol <simtk.openmm.openmm.HarmonicBondForce; proxy of <Swig Object of type 'OpenMM::HarmonicBondForce *' at 0x1611c3390> >
51.81715162906145 kJ/mol <simtk.openmm.openmm.HarmonicAngleForce; proxy of <Swig Object of type 'OpenMM::HarmonicAngleForce *' at 0x1611c3300> >
340.93114607291744 kJ/mol <simtk.openmm.openmm.PeriodicTorsionForce; proxy of <Swig Object of type 'OpenMM::PeriodicTorsionForce *' at 0x1611c3270> >
392.7482977019789 kJ/mol <simtk.openmm.openmm.NonbondedForce; proxy of <Swig Object of type 'OpenMM::NonbondedForce *' at 0x1611c3090> >
38.06694470156162 kJ/mol <simtk.openmm.openmm.CMMotionRemover; proxy of <Swig Object of type 'OpenMM::CMMotionRemover *' at 0x1611c30f0> >
run some steps and print energies again:
simulation.step(50)
for c, f in enumerate(forces):
original_energy = simulation.context.getState(getEnergy=True,groups=c).getPotentialEnergy()
print(original_energy, f)
output:
0.0 kJ/mol <simtk.openmm.openmm.HarmonicBondForce; proxy of <Swig Object of type 'OpenMM::HarmonicBondForce *' at 0x1611c3390> >
26.704057535960047 kJ/mol <simtk.openmm.openmm.HarmonicAngleForce; proxy of <Swig Object of type 'OpenMM::HarmonicAngleForce *' at 0x1611c3300> >
363.67554671367213 kJ/mol <simtk.openmm.openmm.PeriodicTorsionForce; proxy of <Swig Object of type 'OpenMM::PeriodicTorsionForce *' at 0x1611c3270> >
390.37960424963217 kJ/mol <simtk.openmm.openmm.NonbondedForce; proxy of <Swig Object of type 'OpenMM::NonbondedForce *' at 0x1611c3090> >
45.48346996107692 kJ/mol <simtk.openmm.openmm.CMMotionRemover; proxy of <Swig Object of type 'OpenMM::CMMotionRemover *' at 0x1611c30f0> >
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
18. Standard Forces — OpenMM User Guide 7.6 documentation
If the NonbondedMethod in use is anything other than NoCutoff and r is greater than the cutoff distance, the energy and force are...
Read more >Energy Component Analysis in OpenMM · Issue #1463 - GitHub
I have been trying to compare energies between AMBER and OpenMM outputs for prmtop and ... HarmonicBondForce; proxy of <Swig Object of type ......
Read more >OpenMM: CustomBondForce Class Reference - SimTK
energy, an algebraic expression giving the interaction energy between two bonded particles as a function of r, the distance between them ...
Read more >Introduction – Molecular Mechanics Tools - MolSSI Education
This force field describes the energy associated with molecular movements such as bond stretching, angle bending, or dihedral angle rotation. If you are...
Read more >FFXML format - Structural Bioinformatics Library: User Manual
The potential energy decomposes as a sum of contributions, which themselves decomposes into terms. The functors give access to contributions and terms.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ah yes, that solves it thanks! Appreciate you taking a look. Closing
The bitmask behavior on
groups
is exactly what is happening. If you are ever going to be getting a single force group or set of force groups from thegetState
function, you should always cast yourint
/ints
into an iterable object, unless you work in bitmask math.If the Center of Mass is in the center of the box at step 0, its energy will be 0, but afterwords it can move a bit. The
CMMotionRemover
only applies a force to keep the Center of Mass in the Center of Volume loosely. Its a uniform force acting on every particle. See here for the actual operation.