Repository navigation
fix: keep Pourbaix entries whose composition equals comp_dict - #4714
raashish1601 wants to merge 2 commits into
Conversation
process_multientry read the product coefficient with rxn.get_coeff(prod_comp). When an entry has the same composition as the product, get_coeff finds the reactant first and returns -1, so the entry was never turned into a MultiEntry and could not be a stable domain of its own diagram. Take the product coefficient from the last position instead. Fixes materialsproject#4709
|
Automated PR review generated by Claude (posted via @shyuep's account); sanity-check before acting. Good: The root cause is identified correctly. Substantive:
|
|
Checked the With a second entry next to the matching one, that entry gets a coefficient of 0, so |
|
Automated PR review generated by Claude (posted from @shyuep's account). Based on code and CI status only, nothing was run. Please sanity-check before acting. Good: Correct, minimal fix for #4709. CI: no status checks have run on this PR (zero checks reported), so there is no automated signal here. Worth triggering the workflow (or approving the fork run) before merge. Substantive: none. The one assumption to confirm is that Nit: the two-entry assertions ( |
|
The comment above that line already says the product is the last composition. |
Fixes #4709
PourbaixDiagram.process_multientrybuildsReaction(entry_comps + [H, O], [prod_comp])and read the product coefficient withrxn.get_coeff(prod_comp).get_coefflooks the composition up inall_compand returns the first match, so when an entry has the same composition as the product (e.g. Cu3P withcomp_dict={"Cu": 3, "P": 1}) it returns the reactant coefficient (-1). The positive-coefficient check then fails and the entry is never turned into aMultiEntry, so the compound can't be a stable domain of its own diagram and its decomposition energy comes out negative.The product is always the last composition in the reaction, so this takes
rxn.coeffs[-1]instead.With the reproducer from the issue, Cu3P(s) is now a stable domain and its decomposition energy at pH 7, -1 V is 0 (was -0.25 eV/atom). Added
test_entry_with_comp_dict_composition, which fails on master and passes with the change.tests/analysis/test_pourbaix_diagram.pypasses locally (22 passed), ruff and ruff format are clean, and mypy reports the same pre-existing errors as master for this file.