Balance chemical equations & calculates molecular weights plus periodic table of elements
Project description
Package capable of balance chemical equations and contains the most used portion of the periodic table of elements.
The package has two objects: chemeq and periodic_table.
1. chemeq
CLASS, Receives a string representing a chemical equation as input.
In the shape: "reactant_1 + ... + reactant_n = product_1 + ... + product_n".
The chemeq CLASS has three properties and one method.
is_balanced : Property. Boolean (True or False)
reactants : Property. pandas.DtataFrame where each row represents one of the reactants (left side)
compounds, molecular weights and elements.
products : Property. pandas.DtataFrame where each row represents one of the product (right side)
compounds, molecular weights and elements.
balance() : Method. Balances the equation if it is unbalanced.
2. periodic_table
pandas.DataFrame containing a portion of the periodic table of elements contains: Z, name, symbol, atomic mass,
atomic mass error, period, group & state.
Source for the periodic table of elements:
IUPAC - International Union of Pure and Applied Chemistry
https://iupac.org/what-we-do/periodic-table-of-elements/
LIMITATIONS
- Does not include Rare earths, synthetic elements, Radon, Francium & Radium.
- Intermediate prefixes like those from hydrates such as Cu(SO4)•5H2O
must be represented with subindexes like Cu(SO4)(H2O)5.
EXAMPLES
>>> from chemeq import chemeq
>>> eq = chemeq("C2H5(OH) + O2 = CO2 + H2O")
>>> eq.is_balanced
False
The balance status of the equation is also visible in the equation object itself.
>>> eq
<Unbalanced equation: "C2H5(OH) + O2 = CO2 + H2O">
To balance the equation invoke the balance() method
>>> eq.balance()
>>> eq.is_balanced
True
>>> eq
<Balanced equation: "C2H5(OH) + 3O2 = 2CO2 + 3H2O">
Example of its properties
>>> str(eq)
"C2H5(OH) + 3O2 = 2CO2 + 3H2O"
>>> eq.reactants
coefficient formula C H O Mass(g/mol)
0 1 C2H5(OH) 2 6 1 46.069
1 3 O2 0 0 2 31.998
>>> eq.products
coefficient formula C H O Mass(g/mol)
0 2 CO2 1 0 2 44.009
1 3 H2O 0 2 1 18.015</pre>
An equation can be created with their indexes to test if it is balanced. If it is not it can be balanced later.
>>> eq = chemeq("CuS + 8HNO3 = CuSO4 + 8NO2 + 4H2O")
>>> eq.is_balanced
True
>>> eq = chemeq("73CuS + 73HNO3 = 11CuSO4 + 11NO2 + 11H2O")
>>> eq.is_balanced
False
>>> eq.balance()
>>> eq
<Balanced equation: "CuS + 8HNO3 = CuSO4 + 8NO2 + 4H2O">
>>> from chemeq import periodic_table
>>> periodic_table
name symbol atomic_weight error group period state
atomic_number
1 Hydrogen H 1.0080 0.0002 1 1 g
2 Helium He 4.0026 0.0001 18 1 g
3 Lithium Li 6.9400 0.0600 1 2 s
4 Beryllium Be 9.0122 0.0001 2 2 s
5 Boron B 10.8100 0.0200 13 2 s
... ... ... ... ... ... ... ...
79 Gold Au 196.9700 0.0100 11 6 s
80 Mercury Hg 200.5900 0.0100 12 6 l
81 Thallium Tl 204.3800 0.0100 13 6 s
82 Lead Pb 207.2000 1.1000 14 6 s
83 Bismuth Bi 208.9800 0.0100 15 6 s
[67 rows x 7 columns]
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
Built Distribution
File details
Details for the file chemeq-0.1.7.tar.gz
.
File metadata
- Download URL: chemeq-0.1.7.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f26ddd238e90094d1c9279bdb920199c7e573cc19a4fa2414734459720dd5943 |
|
MD5 | bc432f4fe1680e9ef1697c692a6929e1 |
|
BLAKE2b-256 | e0aa60b514f8c6051bf41afb0640f3abd155f4e4facd40624104872295e1327b |
File details
Details for the file chemeq-0.1.7-py3-none-any.whl
.
File metadata
- Download URL: chemeq-0.1.7-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82de1938d358bd5f27742425ab16154834236bff6488ae5dee091e8fde631550 |
|
MD5 | a03a0ba8afb673afcc09fabb3b316c33 |
|
BLAKE2b-256 | ead89b74c29a3a5774ae4b58e82d8d1a787a129d10c632b1349eb3da277e919d |