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

Overhaul forcefield parameters for ions #15

Merged
merged 68 commits into from
Dec 14, 2021

Conversation

rkingsbury
Copy link
Collaborator

@rkingsbury rkingsbury commented Jul 22, 2021

Summary

Overhaul of the Lennard Jones parameters for ions. Comments / feedback welcome.

  • Went back to original papers to confirm units, combining rules, and water models used to fit each parameter set
  • Added TIP4P-FB, TIP3P-FB, OPC, and OPC3 water models
  • Pasted original parameters directly from .html tables in the original papers, then collected all parameters into a .xlsx file to reduce redundancy / potential for errors.
  • created a lightweight dataclass called IonLJParameters for storing the parameters in mdgo
  • Used the .xlsx to create a list of IonLJParameters and store in ions_lj_params.json
  • Changed call signature of get_ions so that the user specifies the ion first, followed by the water model, and then optionally the ion parameter set
  • Added detailed documentation
  • Change print statements to exception clauses for cases when code fails
  • Removed the Aqvist parameter set mainly because it is reported in a non standard way and I wasn't able to quickly figure out how to convert the parameters. It's also very old and only has a small number of ions, so I might advocate that we drop it.
  • Added unit tests
  • Removed individual .lmp data files now that ion parameters are stored in the .json file

Additional dependencies introduced (if any)

None

TODO (if any)

  • Make some changes to get_water for consistency with these changes
  • (optional) utilize the combining_rules attribute of IonLJData to enforce some kind of checking when mixing water and ion models
  • (optional) implement a dataclass similar to IonLJData for the water models

Checklist

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

Before a pull request can be merged, the following items must be checked:

  • [ x ] Code is in the standard Python style. The easiest way to handle this
    is to run the following in the correct sequence on your local machine. Start with running
    black on your new code. This will automatically reformat
    your code to PEP8 conventions and removes most issues. Then run
    pycodestyle, followed by
    flake8.
  • [ x ] Docstrings have been added in the Google docstring format.
    Run pydocstyle on your code.
  • [ x ] Type annotations are highly encouraged. Run mypy to type check your code.
  • [ x ] Tests have been added for any new functionality or bug fixes.
  • All linting and tests pass.

reported as kJ/mol; need to convert to kcal/mol
-Went back to original papers
-checked and converted all values
-cross-checked previous data entry
-moved ion parameters into an .xlsx file instead of text files
-reworked call signature of get_ion

In the future it would be preferable to store the ion data as a .json instead of .xlsx.
However pandas read_json does not support MultiIndex very well.
reported as kJ/mol; need to convert to kcal/mol
-Went back to original papers
-checked and converted all values
-cross-checked previous data entry
-moved ion parameters into an .xlsx file instead of text files
-reworked call signature of get_ion

In the future it would be preferable to store the ion data as a .json instead of .xlsx.
However pandas read_json does not support MultiIndex very well.
@htz1992213
Copy link
Collaborator

@rkingsbury Thank! I have resolved the version conflict by importing Literal from typing_extensions

Copy link
Collaborator

@htz1992213 htz1992213 left a comment

Choose a reason for hiding this comment

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

@rkingsbury I have also suggested code for specifying mixing rules. Could you please see if you are good with that? Thanks! Some more thought: will it work if we allow users to only specify parameter_set = "jj" without specifying water_model = "tip4p" in order to retrieve the "jj" parameters?

mdgo/forcefield.py Show resolved Hide resolved
mdgo/forcefield.py Outdated Show resolved Hide resolved
mdgo/forcefield.py Show resolved Hide resolved
rkingsbury and others added 10 commits November 15, 2021 19:00
Co-authored-by: Tingzheng Hou <thou@berkeley.edu>
Co-authored-by: Tingzheng Hou <thou@berkeley.edu>
Co-authored-by: Tingzheng Hou <thou@berkeley.edu>
Co-authored-by: Tingzheng Hou <thou@berkeley.edu>
Co-authored-by: Tingzheng Hou <thou@berkeley.edu>
Co-authored-by: Tingzheng Hou <thou@berkeley.edu>
Co-authored-by: Tingzheng Hou <thou@berkeley.edu>
@rkingsbury
Copy link
Collaborator Author

@rkingsbury I have also suggested code for specifying mixing rules. Could you please see if you are good with that? Thanks! Some more thought: will it work if we allow users to only specify parameter_set = "jj" without specifying water_model = "tip4p" in order to retrieve the "jj" parameters?

This is a good point @htz1992213 ; I hadn't though about the fact that one might want to use some of these ion parameters with solvents other than water. I think what I'll do is reverse the kwargs, so that parameter_set is required and water_model is optional. Some parameter sets like lm will need you to specify a water model because there are actually multiple sets of parameters, but others like jj will just return the ion parameters, since they don't depend on the water model

See pymatgen #2287
materialsproject/pymatgen#2287

The data file is now keyed by
Ion.reduced_formula, meaning all
ions have charges appended in
brackets, with explicit magnitudes
e.g. `Li[+1]`
@htz1992213
Copy link
Collaborator

@rkingsbury Sure, thanks! And I think the auto selection of recommended parameter_set of certain water_model could also be kept by feeding in some keywords like "auto".

@rkingsbury
Copy link
Collaborator Author

@rkingsbury Sure, thanks! And I think the auto selection of recommended parameter_set of certain water_model could also be kept by feeding in some keywords like "auto".

See my changes @htz1992213. Could you add a test of the mixing rule functionality?

@rkingsbury
Copy link
Collaborator Author

OK, there is a test failure which is due to a recent change in pymatgen. See materialsproject/pymatgen#2287. This has not been released yet so I'm not able to update the requirements.txt. The test passes locally for me though (with the latest pymatgen from GitHub)

Previously, the behavior of Ion.reduced_formula was somewhat inconsistent, so they did not make very good keys for a database or data file like we have here. I pushed some changes to pymatgen and updated the data file here to match, but the CI version of pymatgen hasn't picked up that change yet.

@htz1992213
Copy link
Collaborator

@rkingsbury Sure, thanks! And I think the auto selection of recommended parameter_set of certain water_model could also be kept by feeding in some keywords like "auto".

See my changes @htz1992213. Could you add a test of the mixing rule functionality?

Hi @rkingsbury, I have added tests. I also restored your previous auto-selection of parameter set from a given water model. I think that is a pretty cool feature. Could you please see if that looks good?

@rkingsbury
Copy link
Collaborator Author

@rkingsbury Sure, thanks! And I think the auto selection of recommended parameter_set of certain water_model could also be kept by feeding in some keywords like "auto".

See my changes @htz1992213. Could you add a test of the mixing rule functionality?

Hi @rkingsbury, I have added tests. I also restored your previous auto-selection of parameter set from a given water model. I think that is a pretty cool feature. Could you please see if that looks good?

Looks good to me, thanks @htz1992213 !

I guess we'll need to wait for the next pymatgen release in order to merge, since the ion data requires the changes to reduced_formula from materialsproject/pymatgen#2287

@htz1992213 htz1992213 merged commit a3ee43a into HouGroup:main Dec 14, 2021
@htz1992213
Copy link
Collaborator

@rkingsbury Merged! Thanks!

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.

None yet

2 participants