Ion bugfixes and enhancements#2287
Merged
mkhorton merged 9 commits intomaterialsproject:masterfrom Nov 9, 2021
Merged
Conversation
- place sign before magnitude in reduced_formula - always append (aq) to uncharged Ion - consolidate charge string formatting into new util method
Member
|
Thanks for this PR @rkingsbury ! looks great. One concern is the proliferation of special cases for organics, I wonder if there's a better long-term solution to this that's more general/transferrable. |
rkingsbury
added a commit
to rkingsbury/mdgo
that referenced
this pull request
Nov 23, 2021
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]`
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR contains some miscellaneous bugfixes and enhancements for the
Ionclass.formulaandreduced_formulafor diatomic molecules and Ions #2204 by overloadingget_reduced_formula_and_factorto provide special formula handling for ions. Thereduced_formulafor hydroxide, hydrogen peroxide, acetate, acetic acid, and small alcohols are now more consistent with the way these species are usually written.utils.string.charge_stringmethod to make the representation of ion charges more consistent acrossformula,reduced_formula, etc.Ionformulae more consistent. By default, charges are now always appended in brackets, with the sign preceding the magnitude, e.g.Na[+1]orSO4[-2]. This provides unambiguous differentiation between stoichiometric coefficients and charges, and will facilitate usingIon.reduced_formulaas database keys in, e.g., the Pourbaix ion data. For unchargedIon, the formula is always followed by(aq).Zr(OH)4(aq)becomesZrO2.2H2O(aq)to_latex_stringandIon.from_formulaAdditional dependencies introduced (if any)
None
Checklist
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.
Run pydocstyle on your code.