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

Support for multiple forcefields #2

Merged
merged 9 commits into from
Apr 12, 2022

Conversation

arepstein
Copy link

@arepstein arepstein commented Jan 28, 2022

Improvements on forcefield specification for mixed systems and specific water models

Summary

Include a summary of major changes in bullet points:

  • Added capability to use base names of forcefields, e.g. "gaff" or "spce"
  • Added partial charges to multiple forcefield system setup
  • Converted all system and forcefield creation to OpenMM rather than OpenFF
  • Added test for system with spce water and charges specified

TODO (if any)

  • Unsure of how units should be handled in specifying box size

Checklist

Work-in-progress pull requests are encouraged, but please put [WIP]
in the pull request title.

Improvements on forcefield specification for mixed systems and specific water models
Implemented changes in comments, ran pre-commit
pymatgen/io/openmm/utils.py Show resolved Hide resolved
pymatgen/io/openmm/utils.py Outdated Show resolved Hide resolved
pymatgen/io/openmm/utils.py Outdated Show resolved Hide resolved
pymatgen/io/openmm/utils.py Outdated Show resolved Hide resolved
pymatgen/io/openmm/utils.py Outdated Show resolved Hide resolved
pymatgen/io/openmm/utils.py Outdated Show resolved Hide resolved
pymatgen/io/openmm/utils.py Outdated Show resolved Hide resolved
Did my best to address all comments
pymatgen/io/openmm/utils.py Outdated Show resolved Hide resolved
pymatgen/io/openmm/utils.py Outdated Show resolved Hide resolved
pymatgen/io/openmm/utils.py Outdated Show resolved Hide resolved
pymatgen/io/openmm/utils.py Outdated Show resolved Hide resolved
pymatgen/io/openmm/utils.py Show resolved Hide resolved
Comment on lines +76 to +77

def test_get_input_set_w_charges_and_forcefields(self):
Copy link
Owner

@orionarcher orionarcher Feb 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add a more diverse set of tests and test more of the possible forcefields. This would be a great case for pytest parameterize, which would let you test a long list of forcefield inputs with almost complete code re-use.

I also think we should make sure that this is actually doing what we expect. Currently, we are just testing to make sure that it doesn't fail, but there is no confirmation that the Systems are actually parameterized differently.

We could test parameterization by instantiating a system using input_set['system.xml'].get_system() and then using the System.getForces() iterator to loop through the forces.

Even just looping through all the forces and confirming that they are different for different force fields is enough. I'd recommend testing this with just a lone water molecule and with a lone ethanol (or any organic). That'll keep the resulting Forces arrays small. Just generating the Forces and then using those values as a test would be sufficient, no need to look up in the Sage or GAFF docs what the values are supposed to be.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds great, this will take me a bit longer to get to but at the very least will have it done by next week

@orionarcher
Copy link
Owner

The changes look great. Thanks for implementing. I have a few more requests in the same vein and some suggestions for other tests to add.

Alex Epstein added 2 commits February 2, 2022 11:47
Added function to assign_biopolymer_and_water_ff
Comment on lines +495 to +500
charged_mols = assign_charges_to_mols(
smile_strings=smile_strings,
partial_charges=partial_charges,
partial_charge_method=partial_charge_method,
partial_charge_scaling=partial_charge_scaling,
)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we pull this out front and call it once for small molecules and biopolymer_or_water?

@@ -0,0 +1 @@
repo_token: KpgnfDK8BDSSTSS4lSrCvHwHnchLgIQ0D
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this link up with a GitHub Hook? I don't quite understand how to get coveralls working, definitely a good idea though.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an attempt to get it working. Still fairly confused but will try and get it to work. It's an action on materialsproject/pymatgen, and I don't understand why that isn't run here

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, that would have to be set up on my repo. That's my responsibility so for now I'd just remove this.

Later on, (read: post-qual) we'll break out all this code into a separate repo. At that point, we'll set up CI + coveralls.

Alex Epstein added 4 commits February 2, 2022 15:40
Adding unit tests for:
1. smiles with formal charge
2. Ensuring different water models assign different parameters
3. Testing mixing of small molecule ff with water ff

Also removed tip4p support because it requires the addition of an extra particle. Need to figure that out
Fixed smiles string in test_formal_charge
Be careful about smiles!!
ran black
@orionarcher orionarcher merged commit 01efafd into orionarcher:htmd_openmm Apr 12, 2022
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.

2 participants