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

Bug in pymatgen.analysis.reaction_calculator.ComputedReaction #3983

Open
1azyking opened this issue Aug 9, 2024 · 0 comments
Open

Bug in pymatgen.analysis.reaction_calculator.ComputedReaction #3983

1azyking opened this issue Aug 9, 2024 · 0 comments
Labels

Comments

@1azyking
Copy link

1azyking commented Aug 9, 2024

Python version

Python 3.10.6

Pymatgen version

2024.8.8

Operating system version

Windows

Current behavior

rxn: 12 LiCuS -> Cu + Cu7S4 + 4 Li3CuS2
rxn_e: 0.003
reactants: ['H2O', 'LiCuS']
products: ['H2S', 'Cu', 'Cu7S4', 'Li3CuS2']
--------------after normalization to H2O---------------
rxn: 6e+15 LiCuS + 1.489 H2S -> H2O + 5e+14 Cu + 5e+14 Cu7S4 + 2e+15 Li3CuS2
rxn_e: 1499976386498.000
reactants: ['H2O', 'LiCuS']
products: ['H2S', 'Cu', 'Cu7S4', 'Li3CuS2']

version of pymatgen: 2024.8.8

When I take Cu, Cu7S4, and Li3CuS2 as the products of the hydrolysis reaction of LiCuS, it reports a decomposition from LiCuS to Cu, Cu7S4, and Li3CuS2. However, the H2O and H2S are also listed in reactant and product entries, respectively. Moreover, when I normalize the decomposition to H2O or H2S, it reports a wrong hydrolysis reaction with strange stoichiometric numbers.

Expected Behavior

The reaction with imbalanced reactant and product entries is expected to be reported as None. And I wonder why the error normalization occured.

Minimal example

from pymatgen.analysis.reaction_calculator import ComputedReaction
from pymatgen.entries.computed_entries import ComputedEntry
from pymatgen.core import Composition
from pymatgen import core

entry_h2o = ComputedEntry(Composition("H2O"), -3.440)
entry_h2s = ComputedEntry(Composition("H2S"), -1.049)
entry_licus = ComputedEntry(Composition("LiCuS"), -2.592)
entry_cu = ComputedEntry(Composition("Cu"), 0.0)
entry_cu7s4 = ComputedEntry(Composition("Cu7S4"), -2.541)
entry_li3cus2 = ComputedEntry(Composition("Li3CuS2"), -7.14)

reactants = [entry_h2o, entry_licus]
products = [entry_h2s, entry_cu, entry_cu7s4, entry_li3cus2]

rxn = ComputedReaction(reactants, products)
print(f"rxn: {rxn}")
print(f"rxn_e: {rxn.calculated_reaction_energy:.3f}")
print(f"reactants: {[e.name for e in rxn._reactant_entries]}")
print(f"products: {[e.name for e in rxn._product_entries]}")
print("--------------after normalization to H2O---------------")
rxn.normalize_to(entry_h2o.composition, 1.0)
print(f"rxn: {rxn}")
print(f"rxn_e: {rxn.calculated_reaction_energy:.3f}")
print(f"reactants: {[e.name for e in rxn._reactant_entries]}")
print(f"products: {[e.name for e in rxn._product_entries]}")
print()
print(f"version of pymatgen: {core.__version__}")

Relevant files to reproduce this bug

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant