balance-rxns
A Python package for balancing chemical equations and finding possible reactions.
Installation
pip install balance-rxns
Features
- Automatically balance chemical equations
- Find all possible reactions from given reactants and products
- Support for complex chemical formulas
- Accurate calculations based on sympy and pymatgen
Usage
Basic Usage
from balance_rxns import balance_rxns
# Define reactants and products
reactants = ("Fe", "O2")
products = ("FeO", "Fe2O3", "Fe3O4")
# Find all possible balanced equations
results = balance_rxns(reactants, products)
# Print results
for equation, reactant_coeffs, product_coeffs in results:
print(equation)
Output:
2Fe + O2 -> 2FeO
4Fe + 3O2 -> 2Fe2O3
3Fe + 2O2 -> Fe3O4
Advanced Options
# Limit the number of products
results = balance_rxns(
reactants=["Cu", "Al2O3"],
products=["CuAlO2"],
max_products_in_equation=2, # Maximum 2 products per equation
require_all_reactants_used=True # Require all reactants to be used
)
for equation, r_map, p_map in results:
print(f"Equation: {equation}")
print(f"Reactant coefficients: {r_map}")
print(f"Product coefficients: {p_map}")
print()
Parameters
reactants: List or tuple of reactant chemical formulasproducts: List or tuple of product chemical formulasmax_products_in_equation: Maximum number of products in each equation (default: all)require_all_reactants_used: Whether all reactants must be used (default: True)
Return Value
Returns a list where each element contains:
- String representation of the balanced equation
- Dictionary of reactants with their coefficients
- Dictionary of products with their coefficients
Dependencies
- pymatgen >= 2024.1.0
- sympy >= 1.12.0
License
MIT License
Contributing
Issues and Pull Requests are welcome!
Changelog
0.1.0 (2026-01-30)
- Initial release
- Support for chemical equation balancing
Metadata
Release files for balance-rxns 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| balance_rxns-0.2.0.tar.gz | 53.7 kB | Without provenance | Details for balance_rxns-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| balance_rxns-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for balance_rxns-0.2.0-py3-none-any.whl |
Total release size: 59.5 kB
Release files / balance_rxns-0.2.0.tar.gz
| Download URL | balance_rxns-0.2.0.tar.gz |
|---|---|
| Size | 53.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a9743aeac6c656c798e62bc24d5543a5d3687af8d35b5f84786892a6723897b2
|
|
BLAKE2b-256 checksum How to use checksums |
2dd274197b05684c797a368b0e519085a0ab01cbc2c7bf69db001e844cbe611b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.4
|
Release files / balance_rxns-0.2.0-py3-none-any.whl
| Download URL | balance_rxns-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3b06031c3c594dfed3763ec6d252a964fd717f8bb9197c43e757bc28e28feb0c
|
|
BLAKE2b-256 checksum How to use checksums |
28db1f6d282fbbd0d6f532d87b58afe3111ef544d6a63db52ec09f45c0a73dc9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.4
|
Security for balance-rxns 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.