User:Viorel Minda

User: Viorel Minda

A STOICHIOMETRY CALCULATOR

Here are some ideas that might interest someone who wants to "build' a calculator which performs the tasks involved in computing the stoichiometry of a chemical reaction. The calculator needs to do what it's done by hand in such a calculation: (1) Find the coefficients of the balanced chemical equation, corresponding to the chemical reaction, (2) Calculate the formula mass of each substance involved in the reaction, and, (3) Multiply each formula mass by the coefficient corresponding to the respective substance. These tasks are the same to those performed when computation is done by hand. A device needs to do some other things besides these, such as provide for input and output and handle all kinds of possible errors.

The "Jeremias Benjamin Richter" calculator discussed here, JBR for short, is implemented in Excel VBA. It outputs on an Excel worksheet The output can be further processed using the Excel functionality, or some other Microsoft Office App.

EXAMPLE

The following example has not been chosen for its chemical veracity, but is appropriate for showing the algorithm used to obtain the stoichiometric coefficients (task #1).

INPUT:

FeCl3 + H2S --> Fe2S3 + HCl

OUTPUT:

a) The balanced chemical equation:

2.FeCl3 + 3.H2S = 1.Fe2S3 + 6.HCl

b) The stoichiometric quantities:

(1) THE COEFFICIENTS OF THE BALANCD CHEMICAL EQUATION

The Reaction Matrix

JBR looks at the INPUT as if it is an equation with four unknowns:

x1.FeCl3 + x2.H2S - x3.Fe2S3 - x4.HCl = 0

This leads to a system of four linear and homogeneous equation, one for each kind of atom:

(Fe)     1.x1 + 0.x2 - 2.x3 - 0.x4 = 0

(Cl)      3.x1 + 0.x2 - 0.x3 - 1.x4 = 0             (System 1)

(H)       0.x1 + 2.x2 - 0.x3 - 1.x4 = 0

(S)       0.x1 + 1.x2 - 3.x3 - 0.x4 = 0

(system 1) has an infinite number of sets (x1 x2 x3 x4) which are its "solutions",i.2., for which the left side becomes equal to the right side (0 = 0). There is always the "trivial" set (0 0 0 0). Chemists, by custom, look for the set with the smallest integers other than zeros, which "balance the chemical equation", and call this set "the coefficients of the chemical equation corresponding to the chemical reaction". There are several ways to find the "solution" of such a system.

Most ready made software used for solving linear equations implement in code the Gauss-Jordan Elimination Method. This method processes an "augmented matrix" using row operations

The row operations are:

Ri <--> Rj: Interchange row i and j.  cRi: Replace row i with c times row i, where c is a constant multiple. Ri + cRj: Replace row i with the sum of row i and c times row j.

Why not use the software which comes with Microsoft Excel? There are a couple of reasons for that: First, there are cases for which the matrix generated from a set of chemical reactants and products is not an "augmented matrix". The example taken here is such a case. Second, the solution set usually is made up of non-integers which need more processing in order to change them into the smallest integer set. Finally, for some people, writing code is fun.

The system is summarized in the following Table:

The numbers in the Table above make up the Reaction Matrix, RxMx:

This matrix is not a proper augmented matrix. It must have a "square matrix" on the left and another matrix to the right of this. We apply the row operations to it hoping it will transform into an equivalent augmented matrix.

This is a 3x4 augmented matrix; a 3x3 square matrix on the left and a 3x1 to its right. One row has been eliminated (all elements are zero) because it was Redundant, i.e., it did not contained any info not already in some other row. It was not linearly independent from other row.

This gets further processed, to the Reduced Row Echelon Form:

(2) FORMULA MASS

(3) THE STOICHIOMETRY