-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Virtual site parameters can clash if looked up using only SMIRKS #940
Comments
Okay, so you have an ammonia and you're trying to apply two different virtual sites using In [89]: [key.name for key in ic["VirtualSites"].key_map]
Out[89]: ['EP1', 'EP2']
In [90]: [pot.parameters["distance"] for pot in ic["VirtualSites"].potentials.values()]
Out[90]: [<Quantity(0.5, 'angstrom')>, <Quantity(0.5, 'angstrom')>]
In [91]: pprint([*ic["Electrostatics"].potentials.values()])
[Potential(parameters={'charge': <Quantity(-1.01270999, 'elementary_charge')>}, map_key=None),
Potential(parameters={'charge': <Quantity(0.337569997, 'elementary_charge')>}, map_key=None),
Potential(parameters={'charge': <Quantity(0.337569997, 'elementary_charge')>}, map_key=None),
Potential(parameters={'charge': <Quantity(0.337569997, 'elementary_charge')>}, map_key=None),
Potential(parameters={'charge_increments': <Quantity([1 0 0 0], 'elementary_charge')>}, map_key=None),
Potential(parameters={'charge_increments': <Quantity([1 0 0 0], 'elementary_charge')>}, map_key=None)]
In [92]: [charge.m for charge in ic["Electrostatics"].charges.values()]
Out[92]: [0.9872900098562241, 0.337569996714592, 0.337569996714592, 0.337569996714592, -1.0, -1.0] This is definitely wrong. That the keys aren't wrong implies to me it's something going wrong in the logic that decides if there should be a new parameter or not, which shouldn't happen since it gets both results from SMARTS-matching. Incidentally, I found that the position of each is getting assigned incorrectly. OpenMM should be smart enough to fix this if the parameters are correct, so I can often wave my hands and claim it's just a visualization quirk. But in this case the parameters themselves appear to also get the value of EP1:
Might be related, might not. With any luck, the charge and distance parameters are mis-assigned from only the virtual site code and the actual logic of getting charges and positions are not incorrect. |
This is probably where things are getting funky: This has caused me several headaches in the past and I've advocated for it to be changed (openforcefield/openff-toolkit#1363) but I think with virtual sites it's valid for two fundamentally different parameters to have the same SMIRKS patterns. The lookup magic is poorly-suited for this case, so I think I'll have to temporarily carry along the entire |
Oh also @lilyminium I'm curious if this test cases was really a MWE or something closer to scientific interest. Covering this with a unit test(s) should fix the bug, but working it into an example increases the likelihood it really works (i.e. can run a few timesteps in addition to having the appearance of being parameterized correctly). In other words, is there a practical use case of these sorts of virtual sites, being two particles at difference distances and/or charges on the same orientation atom(s)? |
This particular MWE wasn't of scientific interest, but I think I would have liked this behaviour for easier multi-vsites on the C-Br bond (which I currently implemented using both C and Br as parent atoms, but it would be easier to use Br as the parent for both) -- I was testing things out in relation to openforcefield/standards#64 |
Description
I was testing out some
match="once"
combinations with TrivalentLonePair and ran into an unexpected key/potential mapping in Interchange.Reproduction
Please include a minimally reproducing example of this bug.
Output
Despite Interchange picking up both EP1 and EP2, EP2 appears to get assigned the same parameters as EP1. If I reverse the order of EP2 and EP1 in defining the force field, the reverse happens -- EP1 gets assigned the same parameters as EP2.
Software versions
main
pip install -e .
conda list
?The text was updated successfully, but these errors were encountered: