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₄

Documentation

Autogenerated API documentation for latest stable release is found here: https://pythonhosted.org/chempy (and development docs for the current master branch are found here: http://hera.physchem.kth.se/~chempy/branches/master/html).

Installation

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

Examples

See examples/, and rendered jupyter notebooks here: http://hera.physchem.kth.se/~chempy/branches/master/examples. 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}
True

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.

License

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 https://github.com/bjodah/chempy

Author

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

  • kth.se 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.

Source Distribution

chempy-0.3.5.tar.gz (57.5 kB view details)

Uploaded Source

File details

Details for the file chempy-0.3.5.tar.gz.

File metadata

  • Download URL: chempy-0.3.5.tar.gz
  • Upload date:
  • Size: 57.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for chempy-0.3.5.tar.gz
Algorithm Hash digest
SHA256 2882b5cf8dac8dd15800b923e6c677ceb30d49c7d0e7f220c9176d78cf3c7b5b
MD5 a6d697fae7cd370a917c10ede42d8c62
BLAKE2b-256 209b528636756859e8d26b777701fe51ae420099648fa739eae8499ce89ac686

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page