Skip to main content

ChemPy is a Python package which aims to be useful for chemists

Project description

Build status PyPI version Python version License airspeedvelocity coverage

ChemPy is a Python package useful for chemistry (mainly phyiscal/inorganic/analytical chemistry). Currently it includes:

  • Solver for equilibria (including multiphase systems)
  • Numerical integration routines for chemical kinetics (ODE solver frontend)
  • Integrated rate expressions (and convenience fitting routines)
  • Relations in Physical chemistry
    • Debye-Hückel expressions
    • Arrhenius equation
    • Einstein-Smoluchowski equation
  • Properties
    • water density as function of temperature
    • water permittivity as function of temperature and pressure
    • water diffusivity as function of temperature
    • sulfuric acid density as function of temperature & weight fraction H₂SO₄


Autogenerated API documentation for latest stable release is found here: (and development docs for the current master branch are found here:


Simplest way to install chempy is to use the Conda package manager:

$ conda install -c bjodah chempy pytest

alternatively you may also use pip:

$ python -m pip install --user chempy

(you can skip the --user flag if you have got root permissions), to run the tests you need pytest too:

$ python -m pip install --user --upgrade pytest
$ python -m pytest --pyargs chempy

note that there are some issues with using pytest --pyargs with conda at the moment.


See examples/, and rendered jupyter notebooks here: You may also browse the documentation for more examples. Here are a few code snippets:

Parsing formulae

>>> from chempy import Substance
>>> Substance.from_formula('Fe(CN)6/3-').composition == {0: -3, 26: 1, 6: 6, 7: 6}

we see that the atomic numbers (and 0 for charge) became keys and multiplicity of each element became respective value. Note the / separating the charge.

Chemical equilibria

>>> from chempy import Equilibrium
>>> from chempy.chemistry import Species
>>> water_autop = Equilibrium({'H2O': 1}, {'H+': 1, 'OH-': 1}, 10**-14)
>>> ammonia_prot = Equilibrium({'NH4+': 1}, {'NH3': 1, 'H+': 1}, 10**-9.24)
>>> from chempy.equilibria import EqSystem
>>> substances = map(Species.from_formula, 'H2O OH- H+ NH3 NH4+'.split())
>>> eqsys = EqSystem([water_autop, ammonia_prot], substances)
>>> print('\n'.join(map(str, eqsys.rxns)))
H2O = H+ + OH-; 1e-14
NH4+ = H+ + NH3; 5.75e-10
>>> from collections import defaultdict
>>> init_conc = defaultdict(float, {'H2O': 1, 'NH3': 0.1})
>>> x, sol, sane = eqsys.root(init_conc)
>>> assert sol['success'] and sane
>>> print(', '.join('%.2g' % v for v in x))
1, 0.0013, 7.6e-12, 0.099, 0.0013

Please note that the API of the chempy.equilibria module is not finalized at the moment.


Run py.test can be used to run the tests.``python -m pytest –pyargs chempy``


The source code is Open Source and is released under the very permissive “simplified (2-clause) BSD license”. See LICENSE for further details.

Contributors are welcome to suggest improvements at


Björn Dahlgren, contact:
  • gmail adress: bjodah
  • adress: bda

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for chempy, version 0.3.2
Filename, size File type Python version Upload date Hashes
Filename, size chempy-0.3.2.tar.gz (56.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page