Skip to main content

a package to balance simple chemical equations

Project description

Chemical Equation Balancer

Introduction

The Chemical Equation Balancer is a Python package designed to balance chemical equations and perform matrix operations related to them. This package simplifies the process of balancing complex chemical equations and provides functionality to work with matrices involved in the process.

Installation

You can install the Chemical Equation Balancer via pip:

pip install chemical_eq_balancer

Usage

Balancing Chemical Equations

To balance a chemical equation, initialize the balancer with the list of elements and the equation. Then, call print_answer() to get the balanced equation.

from chem_balancer import ChemicalEquationBalancer

elements = ['H', 'O']
equation = 'H2 + O2 -> H2O'

balancer = ChemicalEquationBalancer(elements, equation)
balancer.print_answer()

Accessing Matrix and Equation Information

Accessing Original Matrix

You can access the original matrix used for balancing with balancer.original_matrix.

original_matrix = balancer.original_matrix

Accessing Reduced Echelon Matrix

You can access the reduced echelon matrix obtained during balancing with balancer.matrix.

reduced_echelon_matrix = balancer.matrix

Accessing Formula and Elements

You can access the formula and elements used in the equation with balancer.formula and balancer.elements respectively.

formula = balancer.formula
elements = balancer.elements

Matrix Operations

Creating an Echelon Matrix

To create an echelon matrix, use echelon_maker(matrix) which give you power to make a matrix in echelon form.
You can also create reduce echelon matrix, use reduce_echelon_maker(matrix).

import numpy as np
from chem_balancer import ChemicalEquationBalancer

matrix = np.array([
    [1.0, 2.0, 3.0],
    [4.0, 5.0, 6.0],
    [7.0, 8.0, 9.0]
])

ce = ChemicalEquationBalancer()
ce.echelon_maker(matrix)
ce.reduce_echelon_maker(matrix)
ce.print_matrix(matrix)

Printing Matrix

You can also print a matrix in a formatted way using print_matrix(matrix).

import numpy as np
from chem_balancer import ChemicalEquationBalancer

matrix = np.array([
    [1.0, 2.0, 3.0],
    [4.0, 5.0, 6.0],
    [7.0, 8.0, 9.0]
])

ChemicalEquationBalancer.print_matrix(matrix)

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvement, please feel free to open an issue or submit a pull request on the GitHub repository.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

chemical_eq_balancer-0.4.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

chemical_eq_balancer-0.4-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file chemical_eq_balancer-0.4.tar.gz.

File metadata

  • Download URL: chemical_eq_balancer-0.4.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for chemical_eq_balancer-0.4.tar.gz
Algorithm Hash digest
SHA256 abeccc71c836570306ecce7a5ed09d54a5808cd111d27f0317099c3e601a864c
MD5 998837d7e6ac9d9732bb30b8599bb8ef
BLAKE2b-256 f9e6f34c884d91bdc6f92243bd16febdc1d6c3c6220822b6dd4fa5b040c9f298

See more details on using hashes here.

File details

Details for the file chemical_eq_balancer-0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for chemical_eq_balancer-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4b44e5b5d94ae29c14dea59bc14164a080e80ea6bc2894dab062b3eaaebe0392
MD5 67313ac4e2dc108f0f806da394017d50
BLAKE2b-256 ecbc7adcf183319c640c937cfe2e1d8ee30a9bd2e3a1476823b3ced8ec6820dc

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