-
Notifications
You must be signed in to change notification settings - Fork 9
Use OOP forcefields #267
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
Use OOP forcefields #267
Conversation
@orbeckst here's the PR you asked me to ping you about! |
Codecov Report
@@ Coverage Diff @@
## develop #267 +/- ##
===========================================
+ Coverage 81.26% 81.68% +0.42%
===========================================
Files 15 15
Lines 1975 2026 +51
Branches 297 310 +13
===========================================
+ Hits 1605 1655 +50
+ Misses 278 276 -2
- Partials 92 95 +3
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR. In general I like your approach
- consolidate in
Forcefield
class - make the templates real templates
I have two initial requests:
-
The original intention with the templates was that they should in principle be legal input form GROMACS. However, I like explicit templating better (also, with 10+ experience since I wrote the original code...) so could you please rename the files from
*.top
to*.top.template
(or some other appropriate suffix...*.top.in
?) to make clear that these are now template files? -
You seem to be using an autoformatter which makes reading the diff difficult. Can you please either undo the formatting or submit a separate PR only with the formatting changes on the files that you touched. We can then merge that PR and then we can merge the main into this PR (or you can rebase) and we have a clean diff.
Done! I always forget to disable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update.
There are failing tests. Please make changes so that the tests pass again.
You can also run the tests locally (which is faster) if you have GROMACS installed (there are conda packages).
I've made a few important changes:
|
Regarding the error in the FEP tests, I'm unable to reproduce it on my machine and I think it's an issue with the MD workflow rather than any Python code that I've changed here. |
I've made those changes. The GitHub tests seem to be throwing some weird errors to do with cloning the repo. |
I restarted CI and all jobs are running. It was a temporary problem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all looking really good and I only have very few final requests:
-
I'd like to unify the API a bit by only using
forcefield
as a kwarg instead offf_class
andforcefield
(see comment). -
There are some other minor things in the comments.
-
Please update the docs at the top of
forcefields.py
where it saysIn the principle it is possible to switch to a different force field by supplying alternative template files.
The idea with this PR is that it now becomes easier to add custom force fields. Can you show an example? You could add a section "Adding your own forcefield". That would really help (1) for maintenance because it tells developers how it works and (2) for users so that we don't need to answer questions but can just point to docs.
Sorry it's taking a while. It's just that this is a sizable (and very good!!) change and I want to make sure that everything continues to work well together.
No problem! I'll work on those. I have actually been working on an example, it's in the |
awesome!
|
I've merged the example using Martini, you can find it in I also need to go back and clear some of the old, erroneous output from that notebook. The plots, for example, are completely wrong and don't reflect the latest results. |
Your MARTINI/MDPOW example notebook is fantastic! (I also noted that some of the GROMACS runs actually didn't run but just restarted from the last frame. However, it's nice to know that it's not an issue re-running the workflow as it won't destroy data.) For nan value in the Coulomb calculation I am not sure where it comes from. I assume that there is a valid Coulomb leg in the FEP calculation because MARTINI benzene has partial charges, doesn't it? One thing that's a bit odd is that alchemlyb and mdpow report different values for statistical inefficiency, for example alchemlyb states 15.84 and mdpow states 7.9840.
I think that's because we have to infer the actual value from what alchemlyb subsample in |
@orbeckst I've checked the code. The logger in the mdpow outputs the correlation time (g/2) but not the statistical inefficiency (g). And as the one calculated in mdpow is based on the length output of the subsampled dataframe, there is small difference between the mdpow one and alchemlyb one. As currently alchemlyb has a logger output for the SI, I think we can remove the mdpow logger information. |
Open an issue #275 |
Thank you! The Gromacs output is for a restart because it was the quickest way to re-generate most of the useful information after clearing the cell outputs. I'll work on those other points today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am very happy with your contribution. It's a really neat re-organization that's also backwards compatible.
Your example notebook is also really good. Nice work!!
@a-ws-m I let you look at my one comment about "sedstate" in the MDP file but if you tell me that this is what it ought to be, I'll squash-merge. (If you want rewrite the history on the PR into less than 5 commits then you're also welcome to do so, e.g. code changes+tests, example, but if not then that's fine too.) |
Thank you very much @a-ws-m , great contribution!! |
This implements several changes to make it easier for end-users to implement their own forcefields. Most of these changes revolve around the
Forcefield
class, which stores the path dictionaries that were previously separate entities. To use a non-default forcefield, make a newForcefield
instance and then pass it toSimulation
using theff_class
argument. This argument is optional; passing a string value forforcefield
will still work, it's simply converted behind the scenes. I also tidied up a few things, which may be worth discussing:system.top
andsystem_octwet.top
files have been changed to be compatible with Python's built-in Template functionality. This makes the code a bit easier to understand.watermodels.dat
file. As I understand it, GROMACS_WATER_MODELS is a master list of all water models, some of which are only available for OPLS-AA. If this is correct, it might be good to phase this out. I have changed the core functions that used this:get_solvent_model
andget_solvent_identifier
. The only other places in the code whereGROMACS_WATER_MODELS
is used is in the tests and inget_water_model
, a function which is also unused in the code base except in tests.is
->==
).I'll write some example code that demonstrates how to use a
Forcefield
next week. In the meantime, I'm sharing this PR so that the changes can be discussed.