-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Description
I discovered chempy this morning and was working through some of the examples so I apologize if this is something I've done wrong and isn't really an issue.
I tried to use the example code from Balancing Reactions to balance a couple of redox reactions from the end-of-chapter problems in the textbook we use. The example code worked flawlessly but when I built the reactions from the textbook I got odd coefficients: [-12, -12] in one instance and [24, 12] in the other. These should have been [-1, -1] or [1, 1] for the first and [2, 1] for the second.
Here is my code for each instance:
# balance the reaction Cr2O7-2 + I- --> Cr+3 + IO3- in acidic solution
# the answer should be Cr2O7-2 + 8 H+ + I- --> 2 Cr+3 + 4 H2O + IO3-
import chempy as chem
ox_r, ox_p = chem.balance_stoichiometry({'I-', 'H2O'}, {'IO3-', 'H+', 'e-'})
red_r, red_p = chem.balance_stoichiometry({'Cr2O7-2', 'H+', 'e-'}, {'Cr+3', 'H2O'})
print(ox_r, ox_p)
print(red_r, red_p)
ox = chem.Equilibrium(ox_r, ox_p, K1)
red = chem.Equilibrium(red_r, red_p, K2)
coeff = chem.Equilibrium.eliminate([ox, red], 'e-')
print(f'coeff: {coeff}')
redox = ox*coeff[o] + red*coeff[1]
print(redox)
# balance the reaction MnO4- + br- --> MnO2 + BrO3-
# the answer should be 2 MnO4- + Br- + 2 H+ --> 2 MnO2 + BrO3- + H2O
import chempy as chem
ox_r, ox_p = chem.balance_stoichiometry({'MnO4-', 'H+', 'e-'}, {'MnO2', 'H2O'})
red_r, red_p = chem.balance_stoichiometry({'Br-', 'H2O'}, {'BrO3-', 'H+', 'e-'})
print(ox_r, ox_p)
print(red_r, red_p)
ox = chem.Equilibrium(ox_r, ox_p, K1)
red = chem.Equilibrium(red_r, red_p, K2)
coeff = chem.Equilibrium.eliminate([ox, red], 'e-')
print(f'coeff: {coeff}')
redox = ox*coeff[0] + red*coeff[1]
print(redox)
Metadata
Metadata
Assignees
Labels
No labels