Migrate Pourbaix workflow to pyEQL v1.6.1 - #369
Conversation
|
Hi @rkingsbury , I noticed the Should I target this PR against the |
pyEQL v1.5.0pyEQL v1.5.0
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## pourbaix #369 +/- ##
=============================================
+ Coverage 71.75% 87.17% +15.42%
=============================================
Files 13 17 +4
Lines 2687 3112 +425
Branches 481 549 +68
=============================================
+ Hits 1928 2713 +785
+ Misses 676 290 -386
- Partials 83 109 +26 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Hi @SuixiongTay , sorry I somehow missed your comment from 4/1. I've rebased your changes in the |
pyEQL v1.5.0pyEQL v1.5.0
cbb679d to
b5c65a1
Compare
pyEQL v1.5.0pyEQL v1.5.0
|
Hi @rkingsbury, quick question: Regarding rebasing onto |
|
Good question - for this PR, please compare against |
|
Thanks @rkingsbury! I dont seem to have the option to edit the target branch. Would you mind helping me change it? |
pyEQL v1.5.0pyEQL v1.6.1
pyEQL v1.6.1pyEQL v1.6.1
Done. You'll need to reconcile some merge conflicts it looks like. Lmk if you get stuck! |
pyEQL v1.6.1pyEQL v1.6.1
|
Hi @rkingsbury , this PR is ready for your review. I have also included two examples: |
rkingsbury
left a comment
There was a problem hiding this comment.
Thanks for this @SuixiongTay ! This really helps me understand your methods and changes. Overall looks good. I've made a series of small comments, including some opportunities for refactoring / streamlining that we can tackle separately or at another time.
The biggest / most important things to address before merging this are:
- I don't think it's necessary (or advisable) for us to carry any of the solid compatibility classes in
pyEQL. All we need to care about is theAqueousCompatibility. We can import all the**Compatibilityclasses (MP, MP2020, MIT) and associated.yamlfiles frompymatgenif we need them. Making this change will simplify this PR quite a bit by eliminating some extra files. - Make sure you have added or updated docstrings and references whereever appropriate to be consistent with your changes. (See specific comments). It's easy to copy/paste stuff, forget to update the docstring or reference, and then have a hard time figuring out where a number came from later on.
- Clarification: (why) do we need a separate method
modified_get_ion_entries_in_chemsys? I understand it might have made sense to develop it side-by-side initially, but is there any reason not to just merge the changes into the regularget_ion_entries_in_chemsys?
There was a problem hiding this comment.
Please delete the checkpoint file (and/or edit .gitignore to correctly ignore them - this is actually a problem right now.
(btw, the checkpoint file exposed your MP API Key, so you might want to re-generate it)
There was a problem hiding this comment.
Both notebooks look good! In this one, please add a short explanatory comment near the examples to explain why, in Example 1, you set comp_dict and conc_dict equal to one another, but in Examples 2 and 3, you set comp_dict to correspond to the target phase of interest.
| self.cpd_entropies = { | ||
| # exp anion entropy | ||
| "O2": 0.316731, | ||
| "N2": 0.295729, | ||
| "F2": 0.313025, | ||
| "Cl2": 0.344373, | ||
| "Br": 0.235039, | ||
| "Hg": 0.234421, | ||
| "H2O": 0.071963, # 0.215891 eV/H2O | ||
| # exp cation entropy | ||
| "C": 0.017737, | ||
| "S": 0.098265, | ||
| "Na": 0.158245, | ||
| "K": 0.181694, | ||
| "Ca": 0.127993, | ||
| "Mg": 0.100985, | ||
| "Li": 0.089984, | ||
| "P": 0.126972, | ||
| "Al": 0.087543, | ||
| # exp solid entropy | ||
| # oxides | ||
| "Na2O": 0.0773147, | ||
| "MgO": 0.04312, # microcrystal #0.0416239 (macrocrystal) | ||
| "CaO": 0.0614161, | ||
| "KO2": 0.1202056, | ||
| "K2O2": 0.0788753, | ||
| "Na2O2": 0.0733903, | ||
| "Li2O": 0.038699, | ||
| "Fe3O4": 0.06463, | ||
| "Fe2O3": 0.05402, | ||
| "Ca2Fe2O5": 0.06482, | ||
| "Mg(FeO2)2": 0.05465, | ||
| "Al2O3": 0.031470, | ||
| "CaAl2O4": 0.050422, | ||
| "CaAl4O7": 0.0457904, | ||
| "LiAlO2": 0.041211, | ||
| "LiAl5O8": 0.033062, | ||
| "SiO2": 0.043097, | ||
| "Al2FeO4": 0.04693, | ||
| "MgFe2O4": 0.05465, | ||
| # chlorides | ||
| "NaCl": 0.111445, | ||
| "KCl": 0.127606, | ||
| "H4NCl": 0.048721, | ||
| "MgCl2": 0.092312, | ||
| "CaCl2": 0.107742, | ||
| "LiCl": 0.0916683, | ||
| "FeCl2": 0.0789525, | ||
| "FeCl3": 0.074665, | ||
| "MgH2Cl2O": 0.0706607, # hydrate | ||
| "MgH4(ClO)2": 0.061768, # hydrate | ||
| "MgH8(ClO2)2": 0.0543861, # hydrate | ||
| "MgH12(ClO3)2": 0.0538711, # hydrate | ||
| "LiAl2H6ClO6": 0.039220162, # hydrate, #0.071213, #quacc 406.14803248222813 J/mol.K | ||
| # carbonates | ||
| "Li2CO3": 0.046542, | ||
| "NaHCO3": 0.052377, | ||
| "Na2CO3": 0.069517, | ||
| "K2CO3": 0.080096, | ||
| "CaCO3": 0.057414, | ||
| "MgCO3": 0.040604, | ||
| "CaMg(CO3)2": 0.047952, | ||
| "KHCO3": 0.059485, | ||
| "FeCO3": 0.057414, | ||
| "Na3H5(CO4)2": 0.051708, | ||
| "Na2H20CO13": 0.0483, | ||
| "Na2H2CO4": 0.05772, | ||
| "Na2H10SO5": 0.04944, | ||
| # sulfides | ||
| "MgS": 0.0777628, | ||
| "CaS": 0.087296, | ||
| "Na2S": 0.086214, | ||
| "K2S": 0.108154, | ||
| "FeS2": 0.0545, | ||
| "FeS": 0.09315, | ||
| "Na2S2O7": 0.056774, # hydrate | ||
| "K2S2O7": 0.071691, # hydrate | ||
| # "Na2S5": None, | ||
| # sulfates | ||
| "CaSO4": 0.054953, | ||
| "MgSO4": 0.047176, | ||
| "K2SO4": 0.077500, | ||
| "Na2SO4": 0.06603, | ||
| "KHSO4": 0.060964, | ||
| "NaHSO4": 0.049883, | ||
| "Li2SO4": 0.0508103, | ||
| "FeSO4": 0.05536, | ||
| "Al2(SO4)3": 0.043498, | ||
| "CaH4SO6": 0.049983, # hydrate | ||
| "Ca2H2S2O9": 0.053768, # hydrate | ||
| "MgH12SO10": 0.0448196, # hydrate | ||
| "MgH12SO9": 0.04328852, # hydrate | ||
| "MgH14SO11": 0.042575, # hydrate | ||
| "MgH2SO5": 0.0433990, # hydrate | ||
| "FeH14SO11": 0.0468325, # hydrate | ||
| # nitrates | ||
| "Ca(NO3)2": 0.066369, | ||
| "NaNO3": 0.072012, | ||
| "NaNO2": 0.080189, | ||
| "Mg(NO3)2": 0.056309, | ||
| "KNO3": 0.082228, | ||
| "KNO2": 0.117494, | ||
| "MgPH16NO10": 0.03462, # hydrate #0.04192 #struvite | ||
| "MgH12(NO6)2": 0.0517309, # hydrate | ||
| # phosphates | ||
| "P2O5": 0.050515, | ||
| "FePH2O5": 0.044098, # hydrate | ||
| "Ca2P2O7": 0.05316, | ||
| "FeP(H2O3)2": 0.044098, # hydrate | ||
| "Mg2P2O7": 0.04351, | ||
| "Mg3(PO4)2": 0.044973, | ||
| "Ca3(PO4)2": 0.056098, | ||
| "CaPHO4": 0.0491682, | ||
| "CaPH5O6": 0.0450325, # hydrate | ||
| "CaP2(H2O3)3": 0.044601, # hydrate | ||
| "Ca5P3HO13": 0.0574393, # hydrate | ||
| # nitrogen compounds | ||
| "NaN3": 0.074827, | ||
| # carbon compounds | ||
| "CaC2": 0.072062, | ||
| "Fe3C": 0.07177, | ||
| # hydroxides | ||
| "KHO": 0.081270, | ||
| "NaHO": 0.066391, | ||
| "Ca(HO)2": 0.051537, | ||
| "Mg(HO)2": 0.039047, | ||
| "LiHO": 0.044086, | ||
| "Li2O2": 0.037785, | ||
| "FeHO2": 0.04664, | ||
| "LiH3O2": 0.0366745, # hydrate | ||
| "Al(HO)3": 0.0302169, | ||
| "AlHO2": 0.0374136, # 0.0272973 polymorph | ||
| # hydrides | ||
| "NaH": 0.0618271, | ||
| "NaH2N": 0.0594075, | ||
| "LiH": 0.0309135, | ||
| "CaH2": 0.043262, | ||
| "LiAlH4": 0.0405526, | ||
| "Li3AlH6": 0.0317015, | ||
| # cyanates | ||
| "NaCNO": 0.0747035, | ||
| "KCSN": 0.0959945, | ||
| # others | ||
| "CaMg2": 0.1074022, | ||
| "H4CN2O": 0.0461752, | ||
| # silicate | ||
| "Mg3Si2H4O9": 0.038, | ||
| "MgSiO3": 0.041865, | ||
| "CaMg(SiO3)2": 0.044167, | ||
| "Ca2Mg5Si8(HO12)2": 0.04137, | ||
| "Mg3Si4(HO6)2": 0.038362, | ||
| "NaAlSi3O8": 0.0493, | ||
| # "CaAl2(SiO4)2", | ||
| # "NaAlSi2H2O7", | ||
| # "KAl3Si3(HO6)2", | ||
| # "Al2Si2H4O9", |
There was a problem hiding this comment.
This is just a note for the future given the volume of expanded data here it makes most sense to store all the entropies separately in a .json or .yaml file and read it in here.
Can you add a TODO comment in the code about this? (or just do it now, if you prefer)
| # Standard state entropy of molecular-like compounds at 298K (-T delta S) | ||
| # from Kubaschewski Tables (eV/atom) |
There was a problem hiding this comment.
Update this comment
molecular-like compounds->pure elements, molecular gases, and reference solids- Add or update the reference - I think most of your entropies come from NIST rather than Kumaschewski, right?
| universal_solid_shift_eV_per_atom: float = 0.0, | ||
| apply_universal_shift_to: str = "compounds", |
There was a problem hiding this comment.
Add descriptions for these new kwargs to the docstring (Args: section). Remember to include units!
|
|
||
|
|
||
| def test_get_pourbaix_entries(monkeypatch): | ||
| from pymatgen.analysis.compatibility import MaterialsProjectAqueousCompatibility # noqa: PLC0415 |
There was a problem hiding this comment.
This should import from pyEQL's version
| from pymatgen.analysis.pourbaix_diagram import PourbaixDiagram, PourbaixEntry | ||
| from pymatgen.core.composition import Composition | ||
| from pymatgen.core.ion import Ion | ||
| from pymatgen.entries.compatibility import MaterialsProjectAqueousCompatibility |
There was a problem hiding this comment.
Should import the pyEQL version
| from mp_api.client import MPRester | ||
| from pymatgen.analysis.phase_diagram import PhaseDiagram | ||
| from pymatgen.analysis.pourbaix_diagram import IonEntry, PourbaixDiagram, PourbaixEntry | ||
| from pymatgen.analysis.pourbaix_diagram import PourbaixDiagram, PourbaixEntry |
There was a problem hiding this comment.
should import the pyEQL version
There was a problem hiding this comment.
Please revert this change to whatever the upstream branch has, unless this bump is required to make your changes work (this requirement will be updated separately elsewhere)
There was a problem hiding this comment.
Pare this file down to ONLY test MPAqueousCompatibility - in keeping with my bigger comment to remove all the **Compatibility classes except the aqueous one from pyEQL.
Description
This PR migrates the previous
pourbaixtopourbaix_pyEQL_v1.5branch.Content
pourbaix_api.pypourbaix_diagram.pycompatibility.pyMP2020Compatibility.yamlMITCompatibility.yamlmpr_reference_ion_database.jsonpourbaix_test_data.jsonpymatgentest_pourbaix_api.pytest_pourbaix_diagram.pytest_compatibility.pypyeql_tutorial_pourbaix_Ca-Mg-C.ipynbpyeql_tutorial_pourbaix_Na-K-Mg-Cl.ipynbNote
emmet-coreusestyping.NotRequiredwhich was introduced in python3.11.pytest.importskipis used to skip through python3.10to avoid the error.Addressing #368