Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

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


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}

as you see, the atomic numbers (and 0 for charge) is used as keys and the count of each kind became respective value.

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.


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.

Filename, size & hash SHA256 hash help File type Python version Upload date
chempy-0.3.4.tar.gz (57.5 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page