question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can not make openmm system with no `Nonbonded` force

See original GitHub issue

Describe the bug Trying to create an openmm system with no nonbonded force results in an error due to the post-processing done here. In my case the nonbonded force is replaced by a custom nonbonded force implemented via smirnoff-plugins which creates the exclusions here before the toolkit so missing this step should be fine.

To Reproduce This is not quite the same as I have not added the custom force but the result is the same

from openff.toolkit.typing.engines.smirnoff import ForceField
from openff.toolkit.topology import Molecule

ff = ForceField("openff_unconstrained-1.3.0.offxml")
# remove all nonbonded handlers 
del ff._parameter_handlers["ToolkitAM1BCC"]
del ff._parameter_handlers["LibraryCharges"]
del ff._parameter_handlers["Electrostatics"]
del ff._parameter_handlers["vdW"]

water = Molecule.from_smiles("O")
system = ff.create_openmm_system(water.to_topology())

Output

IndexError Traceback (most recent call last) /var/folders/9q/nm__l0v13fggc72v94p0hybw0000gq/T/ipykernel_68062/4179821129.py in <module> ----> 1 system = ff.create_openmm_system(water.to_topology())

~/miniconda3/envs/openff-plugins/lib/python3.8/site-packages/openff/toolkit/typing/engines/smirnoff/forcefield.py in create_openmm_system(self, topology, **kwargs) 1376 # TODO: Can we generalize this to allow for CustomNonbondedForce implementations too? 1377 forces = [system.getForce(i) for i in range(system.getNumForces())] -> 1378 nonbonded_force = [f for f in forces if type(f) == openmm.NonbondedForce][0] 1379 1380 nonbonded_force.createExceptionsFromBonds(

IndexError: list index out of range

Computing environment (please complete the following information):

  • Operating system osx
  • Output of running conda list
  • openff-toolkit 0.10.0+32.gc316bfe0.dirty
  • openff-toolkit-base 0.10.0
  • smirnoff_plugins 0.0.1+4.g6118a88.dirty

Additional context

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
mattwthompsoncommented, Oct 4, 2021

The TODO two lines above seems quite relevant as a bit of debt 😅 .

Relates somewhat to discussions around revamping the SMIRNOFF spec, particularly https://github.com/openforcefield/standards/issues/2#issuecomment-930133340. Requiring at least one of NonbondedForce or CustomNonbondedForce seems to fit every use case I can think of. Any obvious pitfalls?

1reaction
SimonBoothroydcommented, Oct 5, 2021

I agree that, though peculiar, force fields with no non-bonded interactions should be permissible.

When computing gradients by finite difference I usually create a subset of a force field that only contains the relevant handler type. So if I was computing dU / d bond length then I would create a system from a force field only containing the BondHandler. Kind of a weird use case but definitely useful to be able to do.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to reproduce standard nonbonded force as a custom ...
I'd like to make a CustomNonbondedForce which exactly reproduces the standard NonbondedForce. Here's my attempt so far: import openmm as mm ...
Read more >
NonbondedForce — OpenMM 7.0.0.dev-f2e879e documentation
To use this class, create a NonbondedForce object, then call addParticle() once for each particle in the System to define its parameters.
Read more >
NonbondedForce - OpenMM Documentation
Returns whether or not this force makes use of periodic boundary conditions. Enum: NonbondedMethod. NoCutoff, No cutoff is applied to nonbonded interactions.
Read more >
NonbondedForce — OpenMM 7.4.0.dev-0a21497 ...
To use this class, create a NonbondedForce object, then call addParticle() once for each particle in the System to define its parameters.
Read more >
CustomNonbondedForce — OpenMM 7.1.0.dev-9567ddb ...
The values of per-particle parameters are specified as part of the system definition ... If you do not add any interaction groups to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found