Defining chemical systems#

Written by Allan Leal (ETH Zurich) on Jan 4th, 2022

Attention

Always make sure you are using the latest version of Reaktoro. Otherwise, some new features documented on this website will not work on your machine and you may receive unintuitive errors. Follow these update instructions to get the latest version of Reaktoro!

Before performing chemical reaction calculations, such as chemical equilibrium and kinetics, we need to determine the phases that must be considered in the calculation and the chemical species that constitute these phases.

For example, to calculate the solubility of a mineral in water, two phases must be considered:

  • an aqueous phase representing water and dissolved species; and

  • a solid phase representing the mineral we want to dissolve in the aqueous solution.

Another example is the combustion of a solid substance. We must define a chemical system composed of:

  • a gaseous phase containing most of the gases relevant to the process; and

  • one or more solid/liquid substances (condensed phases) that may appear during the combustion process.

The concept of a chemical system is represented in Reaktoro using the ChemicalSystem class. You should expect to construct one object of this class for almost every chemical process you want to model.

In a ChemicalSystem object, you can find a list of Phase objects representing the phases. The Phase class is also an essential component of Reaktoro. It contains the list of chemical species composing the phase, as a list of Species objects. Additionally, each Phase object includes its activity model to account for its non-ideal thermodynamic behavior.

Note

We’ll learn more about activity models in a subsequent section and how to specify them for our phases.

Next, we will present how to construct a chemical system in Reaktoro for different applications.

Chemical system definition for a mineral solubility problem#

Let’s consider the chemical equilibrium problem associated with calculating the solubility of halite (NaCl) in water. The code block below demonstrates how a ChemicalSystem object is created with an aqueous and mineral phase.

from reaktoro import *

# Let's use one of PHREEQC's database
db = PhreeqcDatabase("phreeqc.dat")

# Define an aqueous solution with species that are pertinent to the problem
solution = AqueousPhase("H2O H+ OH- Na+ Cl-")

# Because we want to compute the solubility of halite, a mineral phase is needed
halite = MineralPhase("Halite")

# We can now create our ChemicalSystem object with the above phase specifications
system = ChemicalSystem(db, solution, halite)

That’s it! With the ChemicalSystem object created above, we can do some exciting things. For example, we can inspect the phases in the system and their composing chemical species:

for phase in system.phases():
    print(phase.name())
    for species in phase.species():
        print(":: " + species.name())
AqueousPhase
:: H2O
:: H+
:: OH-
:: Na+
:: Cl-
Halite
:: Halite

Note

Reaktoro has default names for phases, such as AqueousPhase and GaseousPhase for aqueous and gaseous phases. For pure mineral phases, the phase name is the same as the name of the mineral species composing it. That’s is why the mineral phase above is named Halite, whose only composing species is called Halite. Note also that Reaktoro supports as many phases as you wish, each phase containing any number of species. We will demonstrate this in subsequent tutorials.

We can also inspect how the chemical species are ordered in the system:

for species in system.species():
    print(species.name())
H2O
H+
OH-
Na+
Cl-
Halite

And inspect the chemical elements in the system:

for element in system.elements():
    print(element.symbol())
H
O
Na
Cl

The ChemicalSystem class also contains the formula matrix \(A\) of the system, which is a matrix whose entry \(A_{j,i}\) contains the number of atoms of element with index \(j\) in species with index \(i\):

print(system.formulaMatrix())
[[ 2.  1.  1.  0.  0.  0.]
 [ 1.  0.  1.  0.  0.  0.]
 [ 0.  0.  0.  1.  0.  1.]
 [ 0.  0.  0.  0.  1.  1.]
 [ 0.  1. -1.  1. -1.  0.]]

The last row in the formula matrix contains the electric charge of each species.

Tip

Access the link ChemicalSystem to find out all methods available in class ChemicalSystem!

Chemical system definition for a gas solubility problem#

We now consider a chemical system of interest for the computation of CO2 solubility in saline solutions. For this case, we will need an aqueous and gaseous phase:

from reaktoro import *

# Let's use the SUPCRTBL database this time (its complete version that includes organic species)
db = SupcrtDatabase("supcrtbl-organics")

# Define an aqueous solution with automatic species collection for given selected elements
solution = AqueousPhase(speciate("H O Na Cl Ca C"))

# Let Reaktoro automatically identify the gases by specifying an empty list of species below
gas = GaseousPhase()

# We can now create our ChemicalSystem object with the above phase specifications
system = ChemicalSystem(db, solution, gas)

Let’s print the species in the system, their names, formula, and molar mass:

print("{:<25}{:<25}{:<20}".format("Name", "Formula", "Molar Mass (kg/mol)"))
for species in system.species():
    print("{:<25}{:<25}{:<20.6f}".format(species.name(), species.formula().str(), species.molarMass()))
Name                     Formula                  Molar Mass (kg/mol) 
1-Butanol(aq)            C4H9OH                   0.074123            
1-Butene(aq)             C4H8                     0.056108            
1-Butyne(aq)             C4H6                     0.054092            
1-Heptanol(aq)           C7H15OH                  0.116203            
1-Heptene(aq)            C7H14                    0.098188            
1-Heptyne(aq)            C7H12                    0.096172            
1-Hexanol(aq)            C6H13OH                  0.102177            
1-Hexene(aq)             C6H12                    0.084161            
1-Hexyne(aq)             C6H10                    0.082145            
1-Octanol(aq)            C8H17OH                  0.130230            
1-Octene(aq)             C8H16                    0.112215            
1-Octyne(aq)             C8H14                    0.110199            
1-Pentanol(aq)           C5H11OH                  0.088150            
1-Pentene(aq)            C5H10                    0.070134            
1-Pentyne(aq)            C5H8                     0.068119            
1-Propanol(aq)           C3H7OH                   0.060096            
1-Propene(aq)            C3H6                     0.042081            
1-Propyne(aq)            C3H4                     0.040065            
2,3-DMP(aq)              C6H3OHCH3CH3             0.122167            
2,4-DMP(aq)              C6H3OHCH3CH3             0.122167            
2,5-DMP(aq)              C6H3OHCH3CH3             0.122167            
2,6-DMP(aq)              C6H3OHCH3CH3             0.122167            
2-Butanone(aq)           C4H8O                    0.072107            
2-Heptanone(aq)          C7H14O                   0.114188            
2-Hexanone(aq)           C6H12O                   0.100161            
2-Hydroxybutanoate       C4H7O3-                  0.103098            
2-Hydroxybutanoic(aq)    C4H8O3                   0.104106            
2-Hydroxydecanoate       C10H19O3-                0.187260            
2-Hydroxydecanoic(aq)    C10H20O3                 0.188267            
2-Hydroxyheptanoic       C7H14O3                  0.146186            
2-Hydroxyhexanoate       C6H11O3-                 0.131152            
2-Hydroxyhexanoic(aq)    C6H12O3                  0.132159            
2-Hydroxynonanoate       C9H17O3-                 0.173233            
2-Hydroxynonanoic(aq)    C9H18O3                  0.174240            
2-Hydroxyoctanoate       C8H15O3-                 0.159206            
2-Hydroxyoctanoic(aq)    C8H16O3                  0.160213            
2-Hydroxypentanoic       C5H10O3                  0.118133            
2-Octanone(aq)           C8H16O                   0.128214            
2-Pentanone(aq)          C5H10O                   0.086134            
3,4-DMP(aq)              C6H3OHCH3CH3             0.122167            
3,5-DMP(aq)              C6H3OHCH3CH3             0.122167            
Acetaldehyde(aq)         CH3CHO                   0.044053            
Acetate-                 C2H3O2-                  0.059045            
Acetone(aq)              C3H6O                    0.058080            
Adipate                  C6H8O4-2                 0.144128            
Adipic-Acid(aq)          C6H10O4                  0.146143            
Azelaic-Acid(aq)         C9H16O4                  0.188224            
Azelate                  C9H14O4-2                0.186209            
Benzene(aq)              C6H6                     0.078114            
Benzoate                 C7H5O2-                  0.121116            
Benzoic-Acid(aq)         C7H6O2                   0.122123            
Butanal(aq)              CH3(CH2)2CHO             0.072107            
Butanoate                C4H7O2-                  0.087099            
Butanoic-Acid(aq)        C4H8O2                   0.088106            
CH4(aq)                  CH4                      0.016043            
CO(aq)                   CO                       0.028010            
CO2(aq)                  CO2                      0.044010            
CO3-2                    CO3-2                    0.060010            
Ca(Ac)+                  CaCH3COO+                0.099122            
Ca(Ac)2(aq)              Ca(CH3COO)2              0.158167            
Ca(But)+                 CaCH3(CH2)2CO2+          0.127176            
Ca(But)2(aq)             Ca(CH3CH2CH2CO2)2        0.214275            
Ca(For)+                 CaCHO2+                  0.085095            
Ca(For)2(aq)             Ca(CHO2)2                0.130113            
Ca(Glyc)+                CaCH3OCO2+               0.115121            
Ca(Glyc)2(aq)            Ca(CH3OCO2)2             0.190166            
Ca(HCO3)+                Ca(HCO3)+                0.101095            
Ca(Lac)+                 CaCH3CH2OCO2+            0.129148            
Ca(Lac)2(aq)             Ca(CH3CH2OCO2)2          0.218220            
Ca(Pent)+                CaCH3(CH2)3CO2+          0.141203            
Ca(Pent)2(aq)            Ca(CH3CH2CH2CH2CO2)2     0.242329            
Ca(Prop)+                CaCH3CH2CO2+             0.113149            
Ca(Prop)2(aq)            Ca(CH3CH2CO2)2           0.186221            
Ca+2                     Ca+2                     0.040077            
CaCO3(aq)                CaCO3                    0.100087            
CaCl+                    CaCl+                    0.075530            
CaCl2(aq)                CaCl2                    0.110983            
CaOH+                    CaOH+                    0.057085            
Cl-                      Cl-                      0.035453            
ClO-                     ClO-                     0.051453            
ClO2-                    ClO2-                    0.067452            
ClO3-                    ClO3-                    0.083451            
ClO4-                    ClO4-                    0.099451            
Decanal(aq)              CH3(CH2)8CHO             0.156268            
Decanoate                C10H19O2-                0.171260            
Decanoic-Acid(aq)        C10H20O2                 0.172268            
Dodecanoate              C12H23O2-                0.199314            
Dodecanoic-Acid(aq)      C12H24O2                 0.200321            
Ethane(aq)               C2H6                     0.030070            
Ethanol(aq)              C2H5OH                   0.046069            
Ethylacetate(aq)         CH3COOCH2CH3             0.088106            
Ethylbenzene(aq)         C6H5C2H5                 0.106167            
Ethylene(aq)             C2H4                     0.028054            
Ethyne(aq)               C2H2                     0.026038            
Formaldehyde(aq)         HCHO                     0.030026            
Formate                  HCO2-                    0.045018            
Formic-Acid(aq)          H2CO2                    0.046026            
Glutarate                C5H6O4-2                 0.130101            
Glutaric-Acid(aq)        C5H8O4                   0.132116            
Glycolate                C2H3O3-                  0.075045            
Glycolic-Acid(aq)        C2H4O3                   0.076052            
H+                       H+                       0.001007            
H-Acetate(aq)            C2H4O2                   0.060053            
H-Adipate                C6H9O4-                  0.145136            
H-Azelate                C9H15O4-                 0.187216            
H-Glutarate              C5H7O4-                  0.131109            
H-Malonate               C3H3O4-                  0.103055            
H-Oxalate                C2HO4-                   0.089028            
H-Pimelate               C7H11O4-                 0.159162            
H-Sebacate               C10H17O4-                0.201243            
H-Suberate               C8H13O4-                 0.173189            
H-Succinate              C4H5O4-                  0.117082            
H2(aq)                   H2                       0.002016            
H2O(aq)                  H2O                      0.018015            
H2O2(aq)                 H2O2                     0.034015            
HCO3-                    HCO3-                    0.061018            
HCl(aq)                  HCl                      0.036461            
HClO(aq)                 HClO                     0.052460            
HClO2(aq)                HClO2                    0.068459            
HO2-                     HO2-                     0.033007            
Heptanal(aq)             CH3(CH2)5CHO             0.114188            
Heptanoate               C7H13O2-                 0.129180            
Heptanoic-Acid(aq)       C7H14O2                  0.130187            
Hexanal(aq)              CH3(CH2)4CHO             0.100161            
Hexanoate                C6H11O2-                 0.115153            
Hexanoic-Acid(aq)        C6H12O2                  0.116160            
Lactate                  C3H5O3-                  0.089071            
Lactic-Acid(aq)          C3H6O3                   0.090079            
Malonate                 C3H2O4-2                 0.102048            
Malonic-Acid(aq)         C3H4O4                   0.104062            
Methanol(aq)             CH3OH                    0.032042            
Na(Ac)(aq)               NaCH3COO                 0.082034            
Na(Ac)2-                 Na(CH3COO)2-             0.141080            
Na(But)(aq)              NaCH3(CH2)2CO2           0.110088            
Na(But)2-                Na(CH3CH2CH2CO2)2-       0.197187            
Na(For)(aq)              NaCHO2                   0.068008            
Na(For)2-                Na(CHO2)2-               0.113026            
Na(Glyc)(aq)             Na(CH3OCO2)              0.098034            
Na(Glyc)2-               Na(CH3OCO2)2-            0.173078            
Na(Lac)(aq)              NaCH3CH2OCO2             0.112061            
Na(Lac)2-                Na(CH3CH2OCO2)2-         0.201132            
Na(Pent)(aq)             NaCH3(CH2)3CO2           0.124115            
Na(Pent)2-               Na(CH3CH2CH2CH2CO2)2-    0.225241            
Na(Prop)(aq)             NaCH3CH2CO2              0.096061            
Na(Prop)2-               Na(CH3CH2CO2)2-          0.169133            
Na+                      Na+                      0.022989            
NaCl(aq)                 NaCl                     0.058442            
NaOH(aq)                 NaOH                     0.039997            
Nonanal(aq)              CH3(CH2)7CHO             0.142241            
Nonanoate                C9H17O2-                 0.157233            
Nonanoic-Acid(aq)        C9H18O2                  0.158241            
O2(aq)                   O2                       0.031999            
OH-                      OH-                      0.017008            
Octanal(aq)              CH3(CH2)6CHO             0.128214            
Octanoate                C8H15O2-                 0.143206            
Octanoic-Acid(aq)        C8H16O2                  0.144214            
Oxalate                  C2O4-2                   0.088021            
Oxalic-Acid(aq)          C2H2O4                   0.090035            
Pentanal(aq)             CH3(CH2)3CHO             0.086134            
Pentanoate               C5H9O2-                  0.101126            
Pentanoic-Acid(aq)       C5H10O2                  0.102133            
Phenol(aq)               C6H5OH                   0.094113            
Pimelate                 C7H10O4-2                0.158155            
Pimelic-Acid(aq)         C7H12O4                  0.160170            
Propanal(aq)             CH3CH2CHO                0.058080            
Propane(aq)              C3H8                     0.044097            
Propanoate               C3H5O2-                  0.073072            
Propanoic-Acid(aq)       C3H6O2                   0.074079            
Sebacate                 C10H16O4-2               0.200236            
Sebacic-Acid(aq)         C10H18O4                 0.202251            
Suberate                 C8H12O4-2                0.172182            
Suberic-Acid(aq)         C8H14O4                  0.174197            
Succinate                C4H4O4-2                 0.116074            
Succinic-Acid(aq)        C4H6O4                   0.118089            
Toluene(aq)              C6H5CH3                  0.092141            
Undecanoate              C11H21O2-                0.185287            
Undecanoic-Acid(aq)      C11H22O2                 0.186294            
m-Cresol(aq)             C6H4OHCH3                0.108140            
m-Toluate                C8H7O2-                  0.135143            
m-Toluic-Acid(aq)        C8H8O2                   0.136150            
n-Butane(aq)             C4H10                    0.058123            
n-Butylbenzene(aq)       C6H5C4H9                 0.134221            
n-Heptane(aq)            C7H16                    0.100204            
n-Heptylbenzene(aq)      C6H5C7H15                0.176302            
n-Hexane(aq)             C6H14                    0.086177            
n-Hexylbenzene(aq)       C6H5C6H13                0.162275            
n-Octane(aq)             C8H18                    0.114231            
n-Octylbenzene(aq)       C6H5C8H17                0.190329            
n-Pentane(aq)            C5H12                    0.072150            
n-Pentylbenzene(aq)      C6H5C5H1                 0.148248            
n-Propylbenzene(aq)      C6H5C3H7                 0.120194            
o-Cresol(aq)             C6H4OHCH3                0.108140            
o-Toluate                C8H7O2-                  0.135143            
o-Toluic-Acid(aq)        C8H8O2                   0.136150            
p-Cresol(aq)             C6H4OHCH3                0.108140            
p-Toluate                C8H7O2-                  0.135143            
p-Toluic-Acid(aq)        C8H8O2                   0.136150            
CH4(g)                   CH4                      0.016043            
CO(g)                    CO                       0.028010            
CO2(g)                   CO2                      0.044010            
Ethylene(g)              C2H4                     0.028054            
H2(g)                    H2                       0.002016            
H2O(g)                   H2O                      0.018015            
O2(g)                    O2                       0.031999            
Phenol(g)                C6H5OH                   0.094113            
m-Cresol(g)              CH3C6H4(OH)              0.108140            
o-Cresol(g)              CH3C6H4(OH)              0.108140            
p-Cresol(g)              CH3C6H4(OH)              0.108140            

This chemical system contains many species. The SUPCRTBL database contains many organic species that should play an insignificant role in accurately computing CO2 solubility. All organic species in SUPCRT and SUPCRTBL databases in Reaktoro’s YAML format have an organic tag which we can use to filter out them.

Let’s then redefine our ChemicalSystem object system by excluding those organic aqueous species and specifying exactly the gases we want:

solution = AqueousPhase(speciate("H O Na Cl Ca C"), exclude("organic"))

gas = GaseousPhase("CO2(g)")

system = ChemicalSystem(db, solution, gas)

Warning

Make sure you specify species names exactly how they exist in the Database object you have created, such as in GaseousPhase("CO2(g)") above. Otherwise you will get a runtime exception!

Note

You can use SupcrtDatabase("supcrtbl") if you want the SUPCRTBL database version without organic species. In this case, the exclude("organic") filter is not needed and has no effect.

And here is the updated list of species (only their names this time):

for species in system.species():
    print(species.name())
CO(aq)
CO2(aq)
CO3-2
Ca(HCO3)+
Ca+2
CaCO3(aq)
CaCl+
CaCl2(aq)
CaOH+
Cl-
ClO-
ClO2-
ClO3-
ClO4-
H+
H2(aq)
H2O(aq)
H2O2(aq)
HCO3-
HCl(aq)
HClO(aq)
HClO2(aq)
HO2-
Na+
NaCl(aq)
NaOH(aq)
O2(aq)
OH-
CO2(g)

You may still be discontent with so many aqueous species for the sake of CO2 solubility calculation. We demonstrate with the code block below how to specify the exact aqueous species to be considered in the phase using a list of species names.

aqueous_species = [
    "H2O(aq)", 
    "CaOH+", 
    "CO2(aq)", 
    "CO3-2", 
    "Ca(HCO3)+", 
    "Ca+2", 
    "CaCl+", 
    "Cl-", 
    "H+", 
    "HCO3-", 
    "HO2-", 
    "Na+", 
    "OH-"
]

solution = AqueousPhase(aqueous_species)

system = ChemicalSystem(db, solution, gas)
for species in system.species():
    print(species.name())
H2O(aq)
CaOH+
CO2(aq)
CO3-2
Ca(HCO3)+
Ca+2
CaCl+
Cl-
H+
HCO3-
HO2-
Na+
OH-
CO2(g)

Chemical system definition with many phases#

Now, let’s overcomplicate and define a chemical system with many phases and species. We have an aqueous solution for which we know the chemical elements of interest. We want Reaktoro to automatically include in our chemical system all minerals that could potentially be important (e.g., minerals that could precipitate as the solution temperature is changed). These are minerals in the database whose constituting elements are found in the aqueous solution. We also want to show how a mineral phase can be defined as a solid solution (containing more than one mineral end-member).

We demonstrate the above requirements for creating a chemical system in the code block below. Note the use of the cemdata18 database provided by ThermoFun, which is suitable for modeling cement chemistry.

db = ThermoFunDatabase("cemdata18")

solution = AqueousPhase(speciate("H O Na Cl Ca Mg C Si Fe Al K S"))
gas = GaseousPhase()
pureminerals = MineralPhases()
solidsolution = MineralPhase("ettringite Fe-ettringite")

system = ChemicalSystem(db, solution, gas, pureminerals, solidsolution)

Let’s now print the phase names and their composing species:

for phase in system.phases():
    print(phase.name())
    for species in phase.species():
        print(":: " + species.name())
AqueousPhase
:: Al(SO4)+
:: Al(SO4)2-
:: Al+3
:: AlO+
:: AlO2-
:: AlO2H@
:: AlOH+2
:: AlSiO5-3
:: CH4@
:: CO2@
:: CO3-2
:: Ca(CO3)@
:: Ca(HCO3)+
:: Ca(HSiO3)+
:: Ca(SO4)@
:: Ca+2
:: CaOH+
:: CaSiO3@
:: Cl-
:: ClO4-
:: Fe(CO3)@
:: Fe(HCO3)+
:: Fe(HSO4)+
:: Fe(HSO4)+2
:: Fe(SO4)+
:: Fe(SO4)2-
:: Fe(SO4)@
:: Fe+2
:: Fe+3
:: FeCl+
:: FeCl+2
:: FeCl2+
:: FeCl3@
:: FeO+
:: FeO2-
:: FeO2H@
:: FeOH+
:: FeOH+2
:: H+
:: H2@
:: H2O@
:: H2S@
:: HCO3-
:: HS-
:: HSO3-
:: HSO4-
:: HSiO3-
:: K(SO4)-
:: K+
:: KOH@
:: Mg(CO3)@
:: Mg(HCO3)+
:: Mg(HSiO3)+
:: Mg+2
:: MgOH+
:: MgSO4@
:: Na(CO3)-
:: Na(HCO3)@
:: Na(SO4)-
:: Na+
:: NaOH@
:: O2@
:: OH-
:: S2O3-2
:: SO3-2
:: SO4-2
:: Si4O10-4
:: SiO2@
:: SiO3-2
GaseousPhase
:: CH4
:: CO2
:: H2
:: H2O
:: H2S
:: O2
ettringite
:: ettringite
:: Fe-ettringite
5CA
:: 5CA
5CNA
:: 5CNA
AlOHam
:: AlOHam
AlOHmic
:: AlOHmic
Amor-Sl
:: Amor-Sl
Anh
:: Anh
Arg
:: Arg
Brc
:: Brc
C12A7
:: C12A7
C2AClH5
:: C2AClH5
C2AH65
:: C2AH65
C2AH7.5
:: C2AH7.5
C2S
:: C2S
C3A
:: C3A
C3AFS0.84H4.32
:: C3AFS0.84H4.32
C3AH6
:: C3AH6
C3AS0.41H5.18
:: C3AS0.41H5.18
C3AS0.84H4.32
:: C3AS0.84H4.32
C3FH6
:: C3FH6
C3FS0.84H4.32
:: C3FS0.84H4.32
C3FS1.34H3.32
:: C3FS1.34H3.32
C3S
:: C3S
C4AClH10
:: C4AClH10
C4AF
:: C4AF
C4AH11
:: C4AH11
C4AH13
:: C4AH13
C4AH19
:: C4AH19
C4AsClH12
:: C4AsClH12
C4FH13
:: C4FH13
CA
:: CA
CA2
:: CA2
CAH10
:: CAH10
CSH3T-T2C
:: CSH3T-T2C
CSH3T-T5C
:: CSH3T-T5C
CSH3T-TobH
:: CSH3T-TobH
CSHQ-JenD
:: CSHQ-JenD
CSHQ-JenH
:: CSHQ-JenH
CSHQ-TobD
:: CSHQ-TobD
CSHQ-TobH
:: CSHQ-TobH
Cal
:: Cal
Dis-Dol
:: Dis-Dol
ECSH1-KSH
:: ECSH1-KSH
ECSH1-NaSH
:: ECSH1-NaSH
ECSH1-SH
:: ECSH1-SH
ECSH1-TobCa
:: ECSH1-TobCa
ECSH2-JenCa
:: ECSH2-JenCa
ECSH2-KSH
:: ECSH2-KSH
ECSH2-NaSH
:: ECSH2-NaSH
ECSH2-TobCa
:: ECSH2-TobCa
Ettringite13_des
:: Ettringite13_des
Ettringite9_des
:: Ettringite9_des
Fe
:: Fe
Fe-ettringite
:: Fe-ettringite
Fe-ettringite05
:: Fe-ettringite05
Fe-hemicarbonate
:: Fe-hemicarbonate
Fe-monosulph05
:: Fe-monosulph05
Fe-monosulphate
:: Fe-monosulphate
FeOOHmic
:: FeOOHmic
Femonocarbonate
:: Femonocarbonate
Gbs
:: Gbs
Gp
:: Gp
Gr
:: Gr
Gt
:: Gt
Hem
:: Hem
INFCA
:: INFCA
INFCN
:: INFCN
INFCNA
:: INFCNA
Jennite
:: Jennite
K2O
:: K2O
K2SO4
:: K2SO4
KSiOH
:: KSiOH
Kln
:: Kln
Lim
:: Lim
M075SH
:: M075SH
M15SH
:: M15SH
M4A-OH-LDH
:: M4A-OH-LDH
M6A-OH-LDH
:: M6A-OH-LDH
M8A-OH-LDH
:: M8A-OH-LDH
Mag
:: Mag
Melanterite
:: Melanterite
Mg2AlC0.5OH
:: Mg2AlC0.5OH
Mg2FeC0.5OH
:: Mg2FeC0.5OH
Mg3AlC0.5OH
:: Mg3AlC0.5OH
Mg3FeC0.5OH
:: Mg3FeC0.5OH
Mgs
:: Mgs
Na2O
:: Na2O
Na2SO4
:: Na2SO4
NaSiOH
:: NaSiOH
Ord-Dol
:: Ord-Dol
Portlandite
:: Portlandite
Py
:: Py
Qtz
:: Qtz
Sd
:: Sd
Sulfur
:: Sulfur
T2C-CNASHss
:: T2C-CNASHss
T5C-CNASHss
:: T5C-CNASHss
Tob-I
:: Tob-I
Tob-II
:: Tob-II
TobH-CNASHss
:: TobH-CNASHss
Tro
:: Tro
chabazite
:: chabazite
ettringite!
:: ettringite
ettringite03_ss
:: ettringite03_ss
ettringite05
:: ettringite05
ettringite13
:: ettringite13
ettringite30
:: ettringite30
ettringite9
:: ettringite9
ettringite_ss
:: ettringite_ss
hemicarbonat10.5
:: hemicarbonat10.5
hemicarbonate
:: hemicarbonate
hemicarbonate9
:: hemicarbonate9
hemihydrate
:: hemihydrate
hydrotalcite
:: hydrotalcite
monocarbonate
:: monocarbonate
monocarbonate05
:: monocarbonate05
monocarbonate9
:: monocarbonate9
monosulphate10.5
:: monosulphate10.5
monosulphate12
:: monosulphate12
monosulphate1205
:: monosulphate1205
monosulphate14
:: monosulphate14
monosulphate16
:: monosulphate16
monosulphate9
:: monosulphate9
natrolite
:: natrolite
straetlingite
:: straetlingite
straetlingite5.5
:: straetlingite5.5
straetlingite7
:: straetlingite7
syngenite
:: syngenite
thaumasite
:: thaumasite
tricarboalu
:: tricarboalu
tricarboalu03
:: tricarboalu03
zeoliteP_Ca
:: zeoliteP_Ca
zeoliteX
:: zeoliteX
zeoliteY
:: zeoliteY

Tip

If efficient calculations are required in your application, you may want to be more selective in the phases and species that populate your chemical system! Unfortunately, it is not always possible to know in advance the species that do not make sense for our model. So do it carefully. Ensure that for all thermodynamic/chemical conditions of interest (e.g. for temperature, pressure ranges of interest) the species you want to exclude from the system are negligible (i.e. exist with numerically zero or tiny amounts).

Imagine, however, you are dealing with two minerals and water and you don’t want to specify the chemical elements in the definition of the aqueous phase. This is what you can do:

db = PhreeqcDatabase("phreeqc.dat")

solution = AqueousPhase()
albite = MineralPhase("Albite")
kaolinite = MineralPhase("Kaolinite")

system = ChemicalSystem(db, albite, kaolinite, solution)

Let’s now find out which aqueous species were selected automatically for our aqueous phase:

aqueousphase = system.phases().get("AqueousPhase")
for species in aqueousphase.species():
    print(species.name())
H+
H2O
Al+3
Al(OH)2+
Al(OH)3
Al(OH)4-
AlOH+2
H2
H4SiO4
H2SiO4-2
H3SiO4-
Na+
OH-
NaOH
O2

Chemical system definition for a combustion problem#

Forget about water now and let’s construct a chemical system suitable for modeling the combustion of black powder. Black powder is composed of potassium nitrate (KNO3), charcoal (C10Ca0.026H4.774N0.039O1.234), and sulfur (S8).

In the code block below we construct a chemical system using the chemical elements above.

# Let's use the NASA-CEA database for this example
db = NasaDatabase("nasa-cea")

# Consider all possible condensed phases (solid or liquid substances) with given elements
condensed = CondensedPhases(speciate("K N O C Ca H S"))

# Automatically select the gases based on the elements above
gases = GaseousPhase()  

# Create a chemical system suitable for modeling combustion of black powder!
system = ChemicalSystem(db, gases, condensed)

We print below the gases and condensed phases constituting our chemical system:

print("Gases")
for species in system.species():
    if species.aggregateState() == AggregateState.Gas:
        print(":: " + species.name())
print("Condensed Phases")
for species in system.species():
    if species.aggregateState() == AggregateState.CondensedPhase:
        print(":: " + species.name())
Gases
:: e-
:: C
:: C+
:: C-
:: CH
:: CH+
:: CH2
:: CH3
:: CH2OH
:: CH2OH+
:: CH3O
:: CH4
:: CH3OH
:: CH3OOH
:: CN
:: CN+
:: CN-
:: CNN
:: CO
:: CO+
:: COS
:: CO2
:: CO2+
:: COOH
:: CS
:: CS2
:: C2
:: C2+
:: C2-
:: C2H
:: C2H2,acetylene
:: C2H2,vinylidene
:: CH2CO,ketene
:: O(CH)2O
:: HO(CO)2OH
:: C2H3,vinyl
:: CH3CN
:: CH3CO,acetyl
:: C2H4
:: C2H4O,ethylen-o
:: CH3CHO,ethanal
:: CH3COOH
:: OHCH2COOH
:: C2H5
:: C2H6
:: CH3N2CH3
:: C2H5OH
:: CH3OCH3
:: CH3O2CH3
:: CCN
:: CNC
:: OCCN
:: C2N2
:: C2O
:: C2S2
:: C3
:: C3H3,1-propynl
:: C3H3,2-propynl
:: C3H4,allene
:: C3H4,propyne
:: C3H4,cyclo-
:: C3H5,allyl
:: C3H6,propylene
:: C3H6,cyclo-
:: C3H6O,propylox
:: C3H6O,acetone
:: C3H6O,propanal
:: C3H7,n-propyl
:: C3H7,i-propyl
:: C3H8
:: C3H8O,1propanol
:: C3H8O,2propanol
:: CNCOCN
:: C3OS
:: C3O2
:: C3S2
:: C4
:: C4H2,butadiyne
:: C4H4,1,3-cyclo-
:: C4H6,butadiene
:: C4H6,1butyne
:: C4H6,2butyne
:: C4H6,cyclo-
:: C4H8,1-butene
:: C4H8,cis2-buten
:: C4H8,tr2-butene
:: C4H8,isobutene
:: C4H8,cyclo-
:: (CH3COOH)2
:: C4H9,n-butyl
:: C4H9,i-butyl
:: C4H9,s-butyl
:: C4H9,t-butyl
:: C4H10,n-butane
:: C4H10,isobutane
:: C4N2
:: C5
:: C5H6,1,3cyclo-
:: C5H8,cyclo-
:: C5H10,1-pentene
:: C5H10,cyclo-
:: C5H11,pentyl
:: C5H11,t-pentyl
:: C5H12,n-pentane
:: C5H12,i-pentane
:: CH3C(CH3)2CH3
:: C6H2
:: C6H5,phenyl
:: C6H5O,phenoxy
:: C6H6
:: C6H5OH,phenol
:: C6H10,cyclo-
:: C6H12,1-hexene
:: C6H12,cyclo-
:: C6H13,n-hexyl
:: C6H14,n-hexane
:: C7H7,benzyl
:: C7H8
:: C7H8O,cresol-mx
:: C7H14,1-heptene
:: C7H15,n-heptyl
:: C7H16,n-heptane
:: C7H16,2-methylh
:: C8H8,styrene
:: C8H10,ethylbenz
:: C8H16,1-octene
:: C8H17,n-octyl
:: C8H18,n-octane
:: C8H18,isooctane
:: C9H19,n-nonyl
:: C10H8,naphthale
:: C10H21,n-decyl
:: C12H9,o-bipheny
:: C12H10,biphenyl
:: Ca
:: Ca+
:: CaH
:: CaO
:: CaO+
:: CaOH
:: CaOH+
:: Ca(OH)2
:: CaS
:: Ca2
:: H
:: H+
:: H-
:: HCN
:: HCO
:: HCO+
:: HCCN
:: HCCO
:: HNC
:: HNCO
:: HNO
:: HNO2
:: HNO3
:: HO2
:: HO2-
:: H2
:: H2+
:: H2-
:: HCHO,formaldehy
:: HCOOH
:: H2O
:: H2O+
:: H2O2
:: H2S
:: H2SO4
:: H3O+
:: (HCOOH)2
:: K
:: K+
:: K-
:: KCN
:: KH
:: KNO2
:: KNO3
:: KO
:: KOH
:: K2
:: K2+
:: K2CO3
:: K2C2N2
:: K2O
:: K2O+
:: K2O2
:: K2O2H2
:: K2SO4
:: N
:: N+
:: N-
:: NCO
:: NH
:: NH+
:: NH2
:: NH3
:: NH2OH
:: NH4+
:: NO
:: NO+
:: NO2
:: NO2-
:: NO3
:: NO3-
:: N2
:: N2+
:: N2-
:: NCN
:: N2H2
:: NH2NO2
:: N2H4
:: N2O
:: N2O+
:: N2O3
:: N2O4
:: N2O5
:: N3
:: N3H
:: O
:: O+
:: O-
:: OH
:: OH+
:: OH-
:: O2
:: O2+
:: O2-
:: O3
:: S
:: S+
:: S-
:: SH
:: SH-
:: SN
:: SO
:: SO-
:: SO2
:: SO2-
:: SO3
:: S2
:: S2-
:: S2O
:: S3
:: S4
:: S5
:: S6
:: S7
:: S8
:: JP-10(g)
:: Jet-A(g)
Condensed Phases
:: Ca(cd)
:: CaCO3(cd)
:: CaH2(cd)
:: CaO(cd)
:: Ca(OH)2(cd)
:: CaS(cd)
:: CaSO4(cd)
:: K(cd)
:: KCN(cd)
:: KH(cd)
:: KNO2(cd)
:: KNO3(cd)
:: KOH(cd)
:: KO2(cd)
:: K2CO3(cd)
:: K2O(cd)
:: K2O2(cd)
:: K2S(cd)
:: K2SO4(cd)
:: S(cd)
:: NH4NO3(cd)

Let’s check how many phases and species were collected in our system:

print("Number of species in the system:", system.species().size())
print("Number of phases in the system:", system.phases().size())
Number of species in the system: 317
Number of phases in the system: 67

This is an impressive number of species and phases to be able to model the combustion of black powder!

Note

By including as many gases and condensed phases as possible, Reaktoro will be able to determine those that may appear after burning black powder. For example, K2S(cd), K2SO4(cd) and CaS(cd) are typically formed in the combustion process. By including them in the definition of the chemical system, the chemical equilibrium solver will be able to find positive amounts for them (i.e., the solver will identify these condensed phases as stable in equilibrium).

Keep reading to learn more about how the ChemicalSystem class plays an important role in Reaktoro!