functionreadSpecies

Return the symbols and coefficients of the elements in a chemical formula

Extends from Modelica.Icons.Function (Icon for functions).

Information

This function reads a chemical formula (formula) and returns the symbols (symbols) and coefficients (coeffs). Each element is interpreted according to the rules in the readElement function. Currently, formula may not contain parentheses or brackets.

The symbols correspond to chemical/physical elements or electrons ("e-"). Electrons are listed if the charge is nonzero.

Example:
(symbols, coeffs) = readSpecies("C19HF37O5S-") returns symbols={"C", "H", "F", "O", "S", "e-"} and coeffs={19, 1, 37, 5, 1, 1}.

Inputs

TypeNameDefaultDescription
StringformulaChemical formula

Outputs

TypeNameDefaultDescription
String[countElements(formula)]symbolsSymbols of the elements
Integer[countElements(formula)]coeffsCoefficients of the elements