Stoichiometric Matrix

From the definition of species, it is possible to construct a stoichiometric matrix that establishes the relationship between species and chemical elements for species or oxides for cement species. This is called canonical decomposition.

Stochiometric matrix for species

Any species can be described as a linear combination of chemical elements. A species vector can be expressed as a function of the chemical elements on which they depend. This dependence leads to the creation of a stochiometric matrix.

fH2O = 2 * :H + :O
H2O = Species(fH2O)
HSO4 = Species("HSO₄⁻")
CO2 = Species(Dict(:C => 1, :O => 2); symbol="CO₂")
species = [H2O, HSO4, CO2]
canonical_stoich_matrix(species) ;
┌────┬─────┬───────┬─────┐
     H2O  HSO₄⁻  CO₂ 
├────┼─────┼───────┼─────┤
  C    0      0    1 
  H    2      1    0 
  S    0      1    0 
  O    1      4    2 
 Zz    0     -1    0 
└────┴─────┴───────┴─────┘

Stochiometric matrix for cement species

A cement species vector can also be expressed in terms of other species on which they depend. Here, the cement species are expressed in terms of the oxides from which they are composed.

C3S = CemSpecies("C3S")
C2S = CemSpecies("C2S")
C3A = CemSpecies("C3A")
C4AF = CemSpecies(Dict(:C=>4, :A=>1, :F=>1); name="C4AF")
cemspecies = [C3S, C2S, C3A, C4AF]
A, indep_comp = canonical_stoich_matrix(cemspecies)
┌───┬─────┬─────┬─────┬──────┐
    C3S  C2S  C3A  C4AF 
├───┼─────┼─────┼─────┼──────┤
 C    3    2    3     4 
 S    1    1    0     0 
 A    0    0    1     1 
 F    0    0    0     1 
└───┴─────┴─────┴─────┴──────┘

Stochiometric matrix for species and primary species

The decomposition of a set of species can also be done according to a base of primary species.

fH2O = 2 * :H + :O
H2O = Species(fH2O)
HSO4 = Species("HSO₄⁻")
CO2 = Species(Dict(:C => 1, :O => 2); symbol="CO₂")
species = [H2O, HSO4, CO2]
H⁺ = Species("H⁺")
SO₄²⁻ = Species("SO₄²⁻")
CO₃²⁻ = Species("CO₃²⁻")
primary_species = [H⁺, SO₄²⁻, CO₃²⁻, H2O]
A, indep_comp, dep_comp = stoich_matrix(species, primary_species)
┌───────┬─────┬───────┬─────┐
        H2O  HSO₄⁻  CO₂ 
├───────┼─────┼───────┼─────┤
   H2O    1      0   -1 
    H⁺    0      1    2 
 SO₄²⁻    0      1    0 
 CO₃²⁻    0      0    1 
└───────┴─────┴───────┴─────┘
Display of the stoichiometric matrix

The stochiometric matrix can be displayed with different column and row labels. Simply add the keyword 'label', which can take the following values: :name, :symbol, :formula

A, indep_comp, dep_comp = stoich_matrix(species, label=:name)

Finally, primary species candidates can be found in a database. Those from Cemdata18 can be listed with the following command:

using ChemistryLab #hide
df_elements, df_substances, df_reactions = read_thermofun("../../../data/cemdata18-merged.json") #hide
df_primaries = extract_primary_species("../../../data/CEMDATA18-31-03-2022-phaseVol.dat")
candidate_primaries = [Species(f; symbol=phreeqc_to_unicode(n)) for (f,n) in zip(df_primaries.formula, df_primaries.symbol)]

See ChemistryLab.read_thermofun and ChemistryLab.extract_primary_species

Stoichiometric matrix can then be obtained based on an set of independent primary species.

A, indep_comp, dep_comp = stoich_matrix(species, candidate_primaries)
┌───────┬─────┬───────┬─────┐
        H2O  HSO₄⁻  CO₂ 
├───────┼─────┼───────┼─────┤
   H2O    1      0   -1 
 CO₃²⁻    0      0    1 
    H⁺    0      1    2 
 SO₄²⁻    0      1    0 
└───────┴─────┴───────┴─────┘