massaction
A python package for the numerical solution of mass-action laws with constraints for the description of chemical reactions.
Installation
The easiest way to install massaction is from PyPi using pip.
pip install massaction
Usage
The major perk of massaction is the simple syntax in which one can set up the description of a chemical equilibrium. For instance, the mass-action law for the oxyhydrogen reaction may be set up in just a few lines of Python code:
from massaction.model import ChemModel
mymodel = ChemModel(3) # set up a model with 3 chemical species
h2o, h2, o2 = mymodel.get_all_species() # give names to the species objects
# first set up the reaction equation, then define constraints to ensure atom balance
reaction = h2 + o2 >> 2*h2o
ln_equilibrium_constant = 20. # arbitrary units
constraint_hydrogen = 2*h2 + 2*h2o == 1.0 # arbitrary units
constraint_oxygen = h2o + 2*o2 == 10.0 # arbitrary units
# now solve the system of equations to obtain an array with the natural logarithm of the concentrations
ln_concentrations = mymodel.solve( [reaction], [ln_equilibrium_constant], [constraint_hydrogen, constraint_oxygen] )
The resulting array ln_concentrations is array([ -0.69314718, -22.94443898, 1.55814462]), which contains the entries $\ln\left(c(\mathrm{H_2O})\right)$, $\ln\left(c(\mathrm{H_2})\right)$, and $\ln\left(c(\mathrm{O_2})\right)$, respectively.
Release files for massaction 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| massaction-0.2.1.tar.gz | 11.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| massaction-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.8 kB
Release files / massaction-0.2.1.tar.gz
| Download URL | massaction-0.2.1.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e24b7ef5f1e0b59be34e53080f9547db03779856b969673f83b6d711f4897c1d
|
|
BLAKE2b-256 checksum How to use checksums |
2df73a7eda2643e8974fd4195ab05157b9384928470786bb41fc5f863a3466ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / massaction-0.2.1-py3-none-any.whl
| Download URL | massaction-0.2.1-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b137ee4ad778e2886f19cabb906ebea758fe1c273e8ae343f66a2581ab90aa58
|
|
BLAKE2b-256 checksum How to use checksums |
25a95caf557ca43f85440504d692e70a10a71fd3b1458f7f0d161d140f4905fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|