Skip to content
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

Expanded search for improper_types #665

Merged

Conversation

umesh-timalsina
Copy link
Member

For an improper, if we are to consider atom1 as the central atom, then the order of atom2/atom3/atom3 really doesn't matter when it comes to finding a matching type from the forcefield. In #644, when testing on a system with impropers, I found that we were only trying to find a potential match using two possibilities, while there should have been 6. This PR is an attempt to fix that.

Previously, the following code would error out:

>>> ff_with_impropers = ForceField()
>>> ff_with_impropers.name = "imp_ff"
>>> ff_with_impropers.improper_types = {
    "CT~CT~HC~HC": ImproperType(name="imp1"),
    "CT~HC~HC~HC": ImproperType(name="imp2"),
 }
>>> ff_with_impropers.get_potential("improper_type", ["CT", "HC", "HC", "CT"])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/umesh/krow/mosdef/gmso/gmso/core/forcefield.py", line 270, in get_potential
    return potential_extractors[group](key, warn=warn)
  File "/home/umesh/krow/mosdef/gmso/gmso/core/forcefield.py", line 455, in _get_improper_type
    raise MissingPotentialError(msg)

With this branch, we are able to find the correct parameters for improper based on the central atom regardless of how the rest of the atoms are ordered.

@codecov
Copy link

codecov bot commented Jun 9, 2022

Codecov Report

Merging #665 (ae5b1de) into develop (02bdcd3) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##           develop     #665      +/-   ##
===========================================
+ Coverage    91.08%   91.10%   +0.02%     
===========================================
  Files           57       57              
  Lines         4756     4758       +2     
===========================================
+ Hits          4332     4335       +3     
+ Misses         424      423       -1     
Impacted Files Coverage Δ
gmso/core/forcefield.py 93.47% <100.00%> (+0.41%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 02bdcd3...ae5b1de. Read the comment docs.

@umesh-timalsina umesh-timalsina merged commit 4436e35 into mosdef-hub:develop Jun 9, 2022
@umesh-timalsina umesh-timalsina deleted the detailed-improper-search branch June 9, 2022 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant