An algorithm for solving chemical mechanisms using sparse matrices

Tagged as: neuroscience, biophysics, stoichiometric
written on 2013-04-26

Sparse Matrix Technique for solving chemical kinetic equations

The solution of any chemical reaction mechanism requires the use of the stoichiometric coefficients to calculate the right-hand sides of the kinetic equations. If the number of species participating in any chemical reaction is always much less than the total number of chemical species involved, then the matrices of stoichiometric coefficients will be sparse. A sparse matrix is one in which there are many more zero elements than nonzero ones. In such a case, one can exploit the prevalence of zero matrix elements with a sparse matrix technique in which only nonzero matrix elements are stored and processed.

This technique involves three one-dimensional arrays: two integer index arrays, IA, JA, and a real one, A. Nonzero elements of the original matrix M are stored row-by-row in A. To identify the nonzero elements in a row, we need to know the column of each entry. The array JA is used to store the column indices which correspond to the nonzero entries of M, i.e., if A(k)=M(i,j), then JA(k)=j.

We also need to know the number of nonzero elements in each row. The index positions in JA and A where each row of M begins are stored in the IA array. If M(i,j) is the leftmost entry of the i-th row and A(k)=M(i,j), then IA(k)=k. Moreover, IA(N+1) is defined as the index in JA and A of the first location following the last (N-th), element in the row. Thus, the number of entries in the i-th row is given by the difference IA(i+1)-IA(i), and the nonzero elements of the i-th row are stored in a sequence

A(IA(i)), A(IA(i)+1), \ldots, A(IA(i+1)-1)
while the corresponding column indices are stored in
JA(IA(i)), JA(IA(i)+1), \ldots, JA(IA(i+1)-1)