-
Notifications
You must be signed in to change notification settings - Fork 80
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
Issue with Balancing Reactions (from examples) #209
Comments
It looks like this may be a bug in how eliminate is calculating its
elimination coefficients. Let me take a look later today.
I was able to replicate the behavior you are seeing and I was able to
generate the correct coefficients with a small fix, but I need to verify
with some more tests.
|
So it looks like this is a bug in how the coefficients by which the equations should be multiplied are calculated. The code was using the result of The sign of the coefficients still needs some work I believe. Everything works, signs included, except the manganese-bromate redox reaction. Right now the elimination coefficients are both negative and it seems like they should be positive but I need to chase more of the stoichiometry logic in other functions to be certain. I would also like to add some documentation on the signs of these coefficients (at least in the code; it may be elsewhere) and some more tests cases. |
Catch and fix the case of all negative elimination coefficients during elimination. Improve documentation and comments in the equilibrium eliminate method. Add, parametrize, and clarify tests for the equilibrium eliminate method. Github-closes: closes bjodah#209 Signed-off-by: Jeremy A Gray <[email protected]>
I've pushed the latest fixes to the above branch. The permanganate-bromate reaction elimination coefficients should both be positive but were both returning negative. The important thing was that both coefficients have the same sign; the negative would only reverse the reaction. This was happening arbitrarily based on whether the first reaction was eliminating a reactant and the second a product, or vice-versa. I've added a check for all negative coefficients, and that seems to solve all the current tests. At this point, we should probably add more tests to increase confidence in the solution and get some more eyes on the changes. Currently, the elimination method will only handle two reactions and not any number of reactions in general. So it works fine for redox half reactions but would need to be generalized further before using for something like elimination in a sequence of Hess's Law reaction steps. There's a commented example of a failing test that demonstrates the problem. |
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:
The text was updated successfully, but these errors were encountered: