This function returns a vector of stoichiometric coefficients
(n) that balance a chemical reaction among the species given
by a vector of chemical formulas (formulas). If the
reaction is ill-posed or non-unique, then the function will fail
with a message. Each formula is interpreted according to the rules
in the readElement
function.
Example:
stoich({"e-","H+","O2","H2O"}) returns
{-4,-4,-1,2}, which indicates the reaction
4e- + 4H+ + O2 ⇌
2H2O.
function stoich
import Modelica.Math.Matrices.singularValues;
extends Modelica.Icons.Function;
input String formulas[:] "Chemical formulas of the species";
output Integer n[size(formulas, 1)] "Stoichiometric coefficients" annotation(
Dialog(__Dymola_label = "<html><i>n</i></html>"));
end stoich;