Git Product home page Git Product logo

Comments (3)

jeremyagray avatar jeremyagray commented on August 11, 2024

from chempy.

jeremyagray avatar jeremyagray commented on August 11, 2024

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 sympy.primefactors() and division to get the coefficients instead of counting the factors from sympy.factorint(). The old code worked for non-repeating, relatively prime factors but was failing on others and the only test was on the former. I've managed to patch that and rework the elimination tests and add your examples. I've pushed the changes here. If you can test it, let me know how it works.

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.

from chempy.

jeremyagray avatar jeremyagray commented on August 11, 2024

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.

from chempy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.