Skip to content

SMIRNOFF energy test failing #330

@mattwthompson

Description

@mattwthompson

While working on something else, haven't looked any deeper

___________________________________ TestSMIRNOFFTemplateGenerator.test_energies ___________________________________

self = <openmmforcefields.tests.test_template_generators.TestSMIRNOFFTemplateGenerator testMethod=test_energies>

    def test_energies(self):
        """Test potential energies match between openff-toolkit and OpenMM ForceField"""

        # Test all supported SMIRNOFF force fields
        for small_molecule_forcefield in SMIRNOFFTemplateGenerator.INSTALLED_FORCEFIELDS:
            if "ff14sb" in small_molecule_forcefield:
                continue
            if "tip" in small_molecule_forcefield:
                continue
            if "opc" in small_molecule_forcefield:
                continue

            # We cannot test openff-2.0.0-rc.1 because it triggers an openmm.OpenMMException due to an equilibrium angle > \pi
            # See https://github.com/openmm/openmm/issues/3185
            if "openff-2.0.0-rc.1" not in small_molecule_forcefield:
                continue

            print(f'Testing energies for {small_molecule_forcefield}...')
            # Create a generator that knows about a few molecules
            # TODO: Should the generator also load the appropriate force field files into the ForceField object?
            generator = SMIRNOFFTemplateGenerator(molecules=self.molecules, forcefield=small_molecule_forcefield)
            # Create a ForceField
            openmm_forcefield = openmm.app.ForceField()
            # Register the template generator
            openmm_forcefield.registerTemplateGenerator(generator.generator)
            # Parameterize some molecules
            for molecule in self.molecules:
                # Create OpenMM System using OpenMM app
                openmm_system = openmm_forcefield.createSystem(molecule.to_topology().to_openmm(), removeCMMotion=False, nonbondedMethod=NoCutoff)

                # Retrieve System generated by the SMIRNOFF typing engine
                smirnoff_system = generator.get_openmm_system(molecule)

                # Compare energies and forces
>               self.compare_energies(molecule, openmm_system, smirnoff_system)

openmmforcefields/tests/test_template_generators.py:819:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
openmmforcefields/tests/test_template_generators.py:647: in compare_energies
    reference_energy, reference_forces = cls.compute_energy(
openmmforcefields/tests/test_template_generators.py:612: in compute_energy
    context = openmm.Context(system, integrator, platform)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <openmm.openmm.Context;  >
args = (<openmm.openmm.System; proxy of <Swig Object of type 'OpenMM::System *' at 0x170762b50> >, <openmm.openmm.VerletInteg...or *' at 0x170761560> >, <openmm.openmm.Platform; proxy of <Swig Object of type 'OpenMM::Platform *' at 0x170762d00> >)

    def __init__(self, *args):
        r"""
        __init__(self, system, integrator) -> Context
        __init__(self, system, integrator, platform) -> Context
        __init__(self, system, integrator, platform, properties) -> Context
        __init__(self, other) -> Context
        Construct a new Context in which to run a simulation, explicitly specifying what Platform should be used to perform calculations and the values of platform-specific properties.

        Parameters
        ----------
        system : System
            the System which will be simulated
        integrator : Integrator
            the Integrator which will be used to simulate the System
        platform : Platform
            the Platform to use for calculations
        properties : map< std::string, std::string >
            a set of values for platform-specific properties. Keys are the property names.
        """
>       _openmm.Context_swiginit(self, _openmm.new_Context(*args))
E       openmm.OpenMMException: HarmonicAngleForce: angle must be between 0 and pi

../../micromamba/envs/interchange-examples-env/lib/python3.11/site-packages/openmm/openmm.py:2471: OpenMMException
---------------------------------------------- Captured stdout call -----------------------------------------------
Testing energies for openff-2.0.0-rc.1...
================================================ warnings summary =================================================
openmmforcefields/tests/test_template_generators.py::TestGAFFTemplateGenerator::test_add_molecules
  /Users/mattthompson/software/openmmforcefields/openmmforcefields/utils.py:36: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    from pkg_resources import resource_filename

openmmforcefields/tests/test_template_generators.py::TestGAFFTemplateGenerator::test_add_molecules
  /Users/mattthompson/micromamba/envs/interchange-examples-env/lib/python3.11/site-packages/pkg_resources/__init__.py:2832: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(pkg)

openmmforcefields/tests/test_template_generators.py::TestSMIRNOFFTemplateGenerator::test_14_scaling_from_offxml
  /Users/mattthompson/micromamba/envs/interchange-examples-env/lib/python3.11/site-packages/lark/utils.py:163: DeprecationWarning: module 'sre_parse' is deprecated
    import sre_parse

openmmforcefields/tests/test_template_generators.py::TestSMIRNOFFTemplateGenerator::test_14_scaling_from_offxml
  /Users/mattthompson/micromamba/envs/interchange-examples-env/lib/python3.11/site-packages/lark/utils.py:164: DeprecationWarning: module 'sre_constants' is deprecated
    import sre_constants

openmmforcefields/tests/test_template_generators.py::TestSMIRNOFFTemplateGenerator::test_14_scaling_from_offxml
  /Users/mattthompson/micromamba/envs/interchange-examples-env/lib/python3.11/site-packages/mdtraj/formats/__init__.py:6: DeprecationWarning: 'xdrlib' is deprecated and slated for removal in Python 3.13
    from .xtc import XTCTrajectoryFile

openmmforcefields/tests/test_template_generators.py::TestSMIRNOFFTemplateGenerator::test_14_scaling_from_offxml
  /Users/mattthompson/micromamba/envs/interchange-examples-env/lib/python3.11/site-packages/mbuild/recipes/__init__.py:13: DeprecationWarning: SelectableGroups dict interface is deprecated. Use select.
    entry_points = metadata.entry_points()["mbuild.plugins"]

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================================= short test summary info =============================================
FAILED openmmforcefields/tests/test_template_generators.py::TestSMIRNOFFTemplateGenerator::test_energies - openmm.OpenMMException: HarmonicAngleForce: angle must be between 0 and pi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions