I'm looking for a package that is compatible with Python 3 and can actually do work with reactions along with, for instance, referencing values. Ideally, it should also not be a package that will take 20 days to learn how to access one value.

More specifically: there should be a way to figure out all possible reactions a certain state could lead to, a way to manipulate lists of possible reactions and applicable reactions in certain states, and to apply reactions to states to get a resulting new state (this, of course, may require some coding on my part, but just an idea of what it should lead too - the more the package can do the better).

Thanks; I'd be glad to provide any clarification in the comments.

  • 2
    $\begingroup$ Maybe you want to clarify this question. What does "work with reactions" mean? $\endgroup$
    – Greg
    May 19, 2017 at 1:49
  • $\begingroup$ @Greg see the second paragraph...I think I gave decent examples there, or are those unclear? $\endgroup$
    – auden
    May 19, 2017 at 1:51
  • 2
    $\begingroup$ Well maybe it is unclear therefore I am asking to help you formulate better question. What state? What kind of chemistry? You mean fully automated and figures out all chemistry for you? Of course for free, in Python, preferably open source and runs on a laptop, right? $\endgroup$
    – Greg
    May 19, 2017 at 1:54
  • $\begingroup$ @Greg no need to be sarcastic. I never said "fully automated and figures out all chemistry for [me]" - I said "this of course may require some coding on my part, but [...] the more the package can do the better". Most of the chemistry packages for python I've seen have an emphasis on having values stored for access. I didn't know if there was one that found the result of a reaction or some such problem. "State" means some general state that I input. $\endgroup$
    – auden
    May 19, 2017 at 2:08
  • 5
    $\begingroup$ I am not sarcastic. I am pointing out that your question makes not much sense so far in this shape and form. What do you mean by a state? What properties/quantities do you want to calculate (if you want to calculate anything) and what info do you already have? Do you want to calculate kinetical equations? Do you want to figure out the equations themselves? " python I've seen have an emphasis on having values stored for access" What packages? What values? To solve what problems? Do you mean kinetical calculations done using pre-determined rate constants for the elemental reactions? $\endgroup$
    – Greg
    May 19, 2017 at 5:06

1 Answer 1


This is not really my area of expertise, but a quick search for "python chemical reactions" revealed three hits I've never seen before that may be of interest, the first one being closest to what you want.


from chempy import ReactionSystem  # The rate constants below are arbitrary
rsys = ReactionSystem.from_string("""2 Fe+2 + H2O2 -> 2 Fe+3 + 2 OH-; 42
    2 Fe+3 + H2O2 -> 2 Fe+2 + O2 + 2 H+; 17
    H+ + OH- -> H2O; 1e10
    H2O -> H+ + OH-; 1e-4
    Fe+3 + 2 H2O -> FeOOH(s) + 3 H+; 1
    FeOOH(s) + 3 H+ -> Fe+3 + 2 H2O; 2.5""")  # "[H2O]" = 1.0 (actually 55.4 at RT)
from chempy.kinetics.ode import get_odesys
odesys, extra = get_odesys(rsys)
from collections import defaultdict
import numpy as np
tout = sorted(np.concatenate((np.linspace(0, 23), np.logspace(-8, 1))))
c0 = defaultdict(float, {'Fe+2': 0.05, 'H2O2': 0.1, 'H2O': 1.0, 'H+': 1e-7, 'OH-': 1e-7})
result = odesys.integrate(tout, c0, atol=1e-12, rtol=1e-14)
import matplotlib.pyplot as plt
_ = plt.subplot(1, 2, 1)
_ = result.plot(names=[k for k in rsys.substances if k != 'H2O'])
_ = plt.legend(loc='best', prop={'size': 9}); _ = plt.xlabel('Time'); _ = plt.ylabel('Concentration')
_ = plt.subplot(1, 2, 2)
_ = result.plot(names=[k for k in rsys.substances if k != 'H2O'], xscale='log', yscale='log')
_ = plt.legend(loc='best', prop={'size': 9}); _ = plt.xlabel('Time'); _ = plt.ylabel('Concentration')
_ = plt.tight_layout()
plt.show()  # doctest: +SKIP



There is RDKit and Pybel as well, but those are more traditional cheminformatics tools.

  • $\begingroup$ Chempy seems like it'll work very well - thanks! $\endgroup$
    – auden
    May 19, 2017 at 11:27
  • 6
    $\begingroup$ One suggestion that's missing is Bill Green's group RMG (Reaction Mechanism Generator) software: rmg.mit.edu It certainly isn't simple to use, but I'm told it's extremely powerful. One can construct reaction mechanisms using pre-defined rules (class based methods), I believe it supports combinatorial and heuristic pathway network generation, and it has very useful support libraries that can calculate transport and thermochemical properties of reasonable first-guess accuracy. $\endgroup$ May 20, 2017 at 13:17
  • 1
    $\begingroup$ RMG is a great tool for constructing reaction mechanism if that's up anyone's alley. The documentation is fairly good and should be enough to get you up and running. For solving systems of rate equations, I strongly suggest the use of Cantera. It's very robust and essentially a free alternative to the popular (and costly) Chemkin software program. If the original poster is basically just looking for a simple code that can balance equations and act as basically a glorified ODE solver though, chempy seems suitable. For those interested in surface reactions, CatMAP is a good option too. $\endgroup$
    – Argon
    Jul 27, 2017 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.