-
Notifications
You must be signed in to change notification settings - Fork 25
ConstraintsCollection always added, even when empty #1432
Copy link
Copy link
Open
Description
Description
The creation pathway from SMIRNOFF sources results in a ConstraintsCollection always being added, even if there's no corresponding ConstraintHandler or possible way for constraints to be added later.
This is harmless, I think, but also an unexpected result. We could take care to remove it if empty, or simply not create it if no handler is present.
Reproduction
In [1]: from openff.toolkit import Molecule, ForceField
In [2]: sage = ForceField("openff-2.3.0.offxml")
In [3]: sage.deregister_parameter_handler("Bonds")
In [4]: sage.deregister_parameter_handler("Constraints")
In [5]: interchange = sage.create_interchange(Molecule.from_smiles("CCO").to_topology())
In [6]: interchange.collections
Out[6]:
{'Constraints': Handler 'Constraints' with expression '', 0 mapping keys, and 0 potentials,
'Angles': Handler 'Angles' with expression 'k/2*(theta-angle)**2', 13 mapping keys, and 3 potentials,
'ProperTorsions': Handler 'ProperTorsions' with expression 'k*(1+cos(periodicity*theta-phase))', 16 mapping keys, and 6 potentials,
'ImproperTorsions': Handler 'ImproperTorsions' with expression 'k*(1+cos(periodicity*theta-phase))', 0 mapping keys, and 0 potentials,
'vdW': Handler 'vdW' with expression '4*epsilon*((sigma/r)**12-(sigma/r)**6)', 9 mapping keys, and 5 potentials,
'Electrostatics': Handler 'Electrostatics' with expression 'coul', 9 mapping keys, and 9 potentials}A sillier example involves a force field with no handlers at all, which still results in an empty collection being present:
In [8]: [*ForceField().create_interchange(Molecule.from_smiles("CCO").to_topology()).collections.values()]
Out[8]: [Handler 'Constraints' with expression '', 0 mapping keys, and 0 potentials]Software versions
- Which operating system and version are you using?
- How did you install Interchange?
- What is the output of running
conda list?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels