Inspecting thermodynamic databases#

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!

This tutorial demonstrates how a thermodynamic database can be inspected programmatically using Reaktoro’s Python API. For this, we will consider the cemdata18 database supported in ThermoFun.

So, let’s get started by creating an object of class ThermoFunDatabase:

from reaktoro import *

db = ThermoFunDatabase("cemdata18")

We’ll use this db object throughout this tutorial to demonstrate all inspection capabilities available in class Database (yes, ThermoFunDatabase is a derived class from Database)!

Inspecting the species in the database#

Let’s loop through all species in this database object and print its name, chemical formula, and molar mass:

print(f"{'Species':<20}{'Formula':<60}{'Molar Mass (kg/mol)':<20}")
for species in db.species():
    print(f"{species.name():<20}{species.formula().str():<60}{species.molarMass():<20.6f}")
Species             Formula                                                     Molar Mass (kg/mol) 
5CA                 (CaO)1.25(SiO2)1(Al2O3)0.125(H2O)1.625                      0.172201            
5CNA                (CaO)1.25(SiO2)1(Al2O3)0.125(Na2O)0.25(H2O)1.375            0.183192            
Al(SO4)+            Al(SO4)+                                                    0.123046            
Al(SO4)2-           Al(SO4)2-                                                   0.219111            
Al+3                Al+3                                                        0.026980            
AlO+                AlO+                                                        0.042980            
AlO2-               AlO2-                                                       0.058981            
AlO2H@              AlO2H@                                                      0.059988            
AlOH+2              Al(OH)+2                                                    0.043988            
AlOHam              Al(OH)3                                                     0.078004            
AlOHmic             Al(OH)3                                                     0.078004            
AlSiO5-3            AlSiO5-3                                                    0.135066            
Amor-Sl             SiO2                                                        0.060084            
Anh                 CaSO4                                                       0.136143            
Arg                 CaCO3                                                       0.100087            
Brc                 Mg(OH)2                                                     0.058320            
C12A7               (CaO)12(Al2O3)7                                             1.386658            
C2AClH5             Ca2AlCl(OH)6(H2O)2                                          0.280665            
C2AH65              Ca2Al(OH)7(H2O)3                                            0.280235            
C2AH7.5             Ca2Al2(OH)10(H2O)2.5                                        0.349231            
C2S                 (CaO)2SiO2                                                  0.172239            
C3A                 (CaO)3Al2O3                                                 0.270193            
C3AFS0.84H4.32      (AlFe|3|O3)[Ca3O3(SiO2)0.84(H2O)4.32]                       0.427354            
C3AH6               Ca3Al2O6(H2O)6                                              0.378285            
C3AS0.41H5.18       Ca3Al2O6(SiO2)0.41(H2O)5.18                                 0.388147            
C3AS0.84H4.32       (AlAlO3)[Ca3O3(SiO2)0.84(H2O)4.32]                          0.398490            
C3FH6               Ca3Fe|3|2O6(H2O)6                                           0.436012            
C3FS0.84H4.32       (Fe|3|Fe|3|O3)[Ca3O3(SiO2)0.84(H2O)4.32]                    0.456217            
C3FS1.34H3.32       Ca3Fe|3|2O6(SiO2)1.34(H2O)3.32                              0.468244            
C3S                 (CaO)3SiO2                                                  0.228316            
C4AClH10            Ca4Al2Cl2(OH)12(H2O)4                                       0.561330            
C4AF                (CaO)4(Al2O3)(Fe|3|2O3)                                     0.485959            
C4AH11              Ca4Al2(OH)14(H2O)4                                          0.524439            
C4AH13              Ca4Al2(OH)14(H2O)6                                          0.560470            
C4AH19              Ca4Al2(OH)14(H2O)12                                         0.668562            
C4AsClH12           Ca4Al2Cl(SO4)0.5(OH)12(H2O)6                                0.609940            
C4FH13              Ca4Fe|3|2(OH)14(H2O)6                                       0.618197            
CA                  CaOAl2O3                                                    0.158039            
CA2                 CaO(Al2O3)2                                                 0.260000            
CAH10               CaOAl2O3(H2O)10                                             0.338192            
CH4                 C|-4|H4                                                     0.016043            
CH4@                C|-4|H4@                                                    0.016043            
CO2                 CO2                                                         0.044010            
CO2@                CO2@                                                        0.044010            
CO3-2               CO3-2                                                       0.060010            
CSH3T-T2C           ((CaO)0.75(SiO2)0.5(H2O)1.25)2                              0.189239            
CSH3T-T5C           ((CaO)1(SiO2)1(H2O)2)1.25                                   0.190240            
CSH3T-TobH          (CaO)1(SiO2)1.5(H2O)2.5                                     0.191242            
CSHQ-JenD           (CaO)1.5(SiO2)0.6667(H2O)2.5                                0.169213            
CSHQ-JenH           (CaO)1.3333(SiO2)1(H2O)2.1667                               0.173886            
CSHQ-TobD           ((CaO)1.25(SiO2)1(H2O)2.75)0.6667                           0.119821            
CSHQ-TobH           (CaO)0.6667(SiO2)1(H2O)1.5                                  0.124494            
Ca(CO3)@            CaCO3@                                                      0.100087            
Ca(HCO3)+           Ca(HCO3)+                                                   0.101094            
Ca(HSiO3)+          Ca(HSiO3)+                                                  0.117169            
Ca(SO4)@            CaSO4@                                                      0.136143            
Ca+2                Ca+2                                                        0.040077            
CaOH+               Ca(OH)+                                                     0.057085            
CaSiO3@             CaSiO3@                                                     0.116162            
Cal                 CaCO3                                                       0.100087            
Cl-                 Cl-                                                         0.035454            
ClO4-               Cl|7|O4-                                                    0.099451            
Cls                 SrSO4                                                       0.183685            
Dis-Dol             CaMg(CO3)2                                                  0.184401            
ECSH1-KSH           ((KOH)2.5SiO2H2O)0.2                                        0.043673            
ECSH1-NaSH          ((NaOH)2.5SiO2H2O)0.2                                       0.035618            
ECSH1-SH            (SiO2H2O)1                                                  0.078100            
ECSH1-SrSH          ((Sr(OH)2)1SiO2H2O)1                                        0.199734            
ECSH1-TobCa         ((Ca(OH)2)0.8333SiO2H2O)1                                   0.139841            
ECSH2-JenCa         ((Ca(OH)2)1.6667SiO2H2O)0.6                                 0.120954            
ECSH2-KSH           ((KOH)2.5SiO2H2O)0.2                                        0.043673            
ECSH2-NaSH          ((NaOH)2.5SiO2H2O)0.2                                       0.035618            
ECSH2-SrSH          ((Sr(OH)2)1SiO2H2O)1                                        0.199734            
ECSH2-SrSH(ACW)     ((Sr(OH)2)1SiO2H2O)1                                        0.199734            
ECSH2-TobCa         ((Ca(OH)2)0.8333SiO2H2O)1                                   0.139841            
Ettringite13_des    Ca6Al2(SO4)3(OH)12(H2O)7                                    0.912820            
Ettringite9_des     Ca6Al2(SO4)3(OH)12(H2O)3                                    0.840759            
Fe                  Fe|0|                                                       0.055845            
Fe(CO3)@            FeCO3@                                                      0.115854            
Fe(HCO3)+           FeHCO3+                                                     0.116861            
Fe(HSO4)+           FeHSO4+                                                     0.152917            
Fe(HSO4)+2          Fe|3|HSO4+2                                                 0.152916            
Fe(SO4)+            Fe|3|(SO4)+                                                 0.151909            
Fe(SO4)2-           Fe|3|(SO4)2-                                                0.247975            
Fe(SO4)@            Fe(SO4)@                                                    0.151910            
Fe+2                Fe+2                                                        0.055844            
Fe+3                Fe|3|+3                                                     0.055843            
Fe-ettringite       Ca6Fe|3|2(SO4)3(OH)12(H2O)26                                1.312838            
Fe-ettringite05     Ca3Fe|3|(SO4)1.5(OH)6(H2O)13                                0.656419            
Fe-hemicarbonate    Ca3O3Fe|3|2O3(CaCO3)0.5(CaO2H2)0.5(H2O)9.5                  0.586156            
Fe-monosulph05      Ca2Fe|3|S0.5O5(H2O)6                                        0.340123            
Fe-monosulphate     Ca4Fe|3|2SO10(H2O)12                                        0.680247            
FeCl+               FeCl+                                                       0.091297            
FeCl+2              Fe|3|Cl+2                                                   0.091297            
FeCl2+              Fe|3|Cl2+                                                   0.126750            
FeCl3@              Fe|3|Cl3@                                                   0.162204            
FeO+                Fe|3|O+                                                     0.071844            
FeO2-               Fe|3|O2-                                                    0.087844            
FeO2H@              Fe|3|O2H@                                                   0.088852            
FeOH+               FeOH+                                                       0.072852            
FeOH+2              Fe|3|(OH)+2                                                 0.072851            
FeOOHmic            Fe|3|OOH                                                    0.088852            
Femonocarbonate     Ca4O4Fe|3|2O3CO2(H2O)12                                     0.644191            
Gbs                 Al(OH)3                                                     0.078004            
Gp                  CaSO4(H2O)2                                                 0.172173            
Gr                  C|0|                                                        0.012011            
Gt                  Fe|3|O(OH)                                                  0.088852            
H+                  H+                                                          0.001007            
H2                  H|0|2                                                       0.002016            
H2@                 H|0|2@                                                      0.002016            
H2O                 H2O                                                         0.018015            
H2O@                H2O@                                                        0.018015            
H2S                 H2S|-2|                                                     0.034083            
H2S@                H2S|-2|@                                                    0.034083            
HCN@                HC|-1|N|0|@                                                 0.027025            
HCO3-               HCO3-                                                       0.061017            
HS-                 HS|-2|-                                                     0.033075            
HSO3-               HS|4|O3-                                                    0.081074            
HSO4-               HS|6|O4-                                                    0.097073            
HSiO3-              HSiO3-                                                      0.077092            
Hem                 Fe|3|2O3                                                    0.159688            
INFCA               (CaO)1(SiO2)1.1875(Al2O3)0.15625(H2O)1.65625                0.173197            
INFCN               (CaO)1(SiO2)1.5(Na2O)0.3125(H2O)1.1875                      0.186965            
INFCNA              (CaO)1(SiO2)1.1875(Al2O3)0.15625(Na2O)0.34375(H2O)1.3125    0.188309            
Jennite             (SiO2)1(CaO)1.666667(H2O)2.1                                0.191379            
K(SO4)-             KSO4-                                                       0.135163            
K+                  K+                                                          0.039098            
K2O                 K2O                                                         0.094196            
K2SO4               K2SO4                                                       0.174261            
KOH@                KOH@                                                        0.056106            
KSiOH               ((KOH)2.5SiO2H2O)0.2                                        0.043673            
Kln                 Al2Si2O5(OH)4                                               0.258160            
Lim                 CaO                                                         0.056077            
M075SH              Mg1.5Si2O5.5(H2O)2.5                                        0.225663            
M15SH               Mg1.5SiO3.5(H2O)2.5                                         0.165579            
M4A-OH-LDH          Mg4Al2(OH)14(H2O)3                                          0.443332            
M6A-OH-LDH          Mg6Al2(OH)18(H2O)3                                          0.559971            
M8A-OH-LDH          Mg8Al2(OH)22(H2O)3                                          0.676611            
Mag                 FeFe|3|2O4                                                  0.231533            
Melanterite         FeSO4(H2O)7                                                 0.278017            
Mg(CO3)@            Mg(CO3)@                                                    0.084314            
Mg(HCO3)+           Mg(HCO3)+                                                   0.085321            
Mg(HSiO3)+          Mg(HSiO3)+                                                  0.101396            
Mg+2                Mg+2                                                        0.024304            
Mg2AlC0.5OH         Mg2Al(OH)6(CO3)0.5(H2O)2                                    0.243671            
Mg2FeC0.5OH         Mg2Fe|3|(OH)6(CO3)0.5(H2O)2                                 0.272534            
Mg3AlC0.5OH         Mg3Al(OH)8(CO3)0.5(H2O)2.5                                  0.310998            
Mg3FeC0.5OH         Mg3Fe|3|(OH)8(CO3)0.5(H2O)2.5                               0.339862            
MgOH+               Mg(OH)+                                                     0.041312            
MgSO4@              Mg(SO4)@                                                    0.120370            
Mgs                 MgCO3                                                       0.084314            
N2                  N|0|2                                                       0.028013            
N2@                 N|0|2@                                                      0.028013            
NH3@                N|-3|H3@                                                    0.017031            
NH4+                N|-3|H4+                                                    0.018038            
NO3-                NO3-                                                        0.062005            
Na(CO3)-            NaCO3-                                                      0.082999            
Na(HCO3)@           NaHCO3@                                                     0.084007            
Na(SO4)-            Na(SO4)-                                                    0.119055            
Na+                 Na+                                                         0.022989            
Na2O                Na2O                                                        0.061979            
Na2SO4              Na2SO4                                                      0.142044            
NaOH@               NaOH@                                                       0.039997            
NaSiOH              ((NaOH)2.5SiO2H2O)0.2                                       0.035618            
O2                  O|0|2                                                       0.031999            
O2@                 O|0|2@                                                      0.031999            
OH-                 OH-                                                         0.017008            
Ord-Dol             CaMg(CO3)2                                                  0.184401            
Portlandite         Ca(OH)2                                                     0.074093            
Py                  FeS|0|S|-2|                                                 0.119979            
Qtz                 SiO2                                                        0.060084            
S2O3-2              S|2|2O3-2                                                   0.112133            
SCN-                S|0|C|0|N|-1|-                                              0.058085            
SO3-2               S|4|O3-2                                                    0.080066            
SO4-2               S|6|O4-2                                                    0.096066            
Sd                  FeCO3                                                       0.115854            
Si4O10-4            Si4O10-4                                                    0.272338            
SiO2@               SiO2@                                                       0.060084            
SiO3-2              SiO3-2                                                      0.076085            
Sr(CO3)@            Sr(CO3)@                                                    0.147629            
Sr(HCO3)+           SrHCO3+                                                     0.148636            
Sr(SO4)@            Sr(SO4)@                                                    0.183685            
Sr+2                Sr+2                                                        0.087619            
SrOH+               Sr(OH)+                                                     0.104627            
SrSiO3@             SrSiO3@                                                     0.163704            
Str                 SrCO3                                                       0.147629            
Sulfur              S|0|                                                        0.032067            
T2C-CNASHss         (CaO)1.5(SiO2)1(H2O)2.5                                     0.189239            
T5C-CNASHss         (CaO)1.25(SiO2)1.25(H2O)2.5                                 0.190240            
Tob-I               (SiO2)2.4(CaO)2(H2O)3.2                                     0.314006            
Tob-II              (SiO2)1(CaO)0.833333(H2O)1.333333                           0.130836            
TobH-CNASHss        (CaO)1(SiO2)1.5(H2O)2.5                                     0.191242            
Tro                 Fe|2|S|-2|                                                  0.087912            
chabazite           Ca(Al2Si4)O12(H2O)6                                         0.506468            
ettringite          ((H2O)2)Ca6Al2(SO4)3(OH)12(H2O)24                           1.255111            
ettringite03_ss     (SO4)Ca2Al0.6666667(OH)4(H2O)8.6666667                      0.418370            
ettringite05        Ca3Al(SO4)1.5(OH)6(H2O)13                                   0.627555            
ettringite13        Ca6Al2(SO4)3(OH)12(H2O)7                                    0.912820            
ettringite30        Ca6Al2(SO4)3(OH)12(H2O)24                                   1.219080            
ettringite9         Ca6Al2(SO4)3(OH)12(H2O)3                                    0.840759            
ettringite_ss       {SO4}3:Ca6Al2(OH)12(H2O)26                                  1.255111            
hemicarbonat10.5    (CaO)3Al2O3(CaCO3)0.5(CaO2H2)0.5(H2O)10                     0.537436            
hemicarbonate       (CaO)3Al2O3(CaCO3)0.5(CaO2H2)0.5(H2O)11.5                   0.564459            
hemicarbonate9      (CaO)3Al2O3(CaCO3)0.5(CaO2H2)0.5(H2O)8.5                    0.510413            
hemihydrate         CaSO4(H2O)0.5                                               0.145150            
hydrotalcite        Mg4Al2O7(H2O)10                                             0.443332            
monocarbonate       Ca4Al2CO9(H2O)11                                            0.568449            
monocarbonate05     Ca2AlC0.5O4.5(H2O)5.5                                       0.284224            
monocarbonate9      Ca4Al2CO9(H2O)9                                             0.532418            
mononitrate         Ca4Al2(OH)12N|5|2O6(H2O)4                                   0.614434            
mononitrite         Ca4Al2(OH)12N|3|2O4(H2O)4                                   0.582435            
monosulphate10.5    Ca4Al2SO10(H2O)10.5                                         0.595497            
monosulphate12      Ca4Al2SO10(H2O)12                                           0.622520            
monosulphate1205    Ca2AlS0.5O5(H2O)6                                           0.311260            
monosulphate14      Ca4Al2SO10(H2O)14                                           0.658550            
monosulphate16      Ca4Al2SO10(H2O)16                                           0.694581            
monosulphate9       Ca4Al2SO10(H2O)9                                            0.568474            
natrolite           Na2(Al2Si3)O10(H2O)2                                        0.380224            
straetlingite       Ca2Al2SiO7(H2O)8                                            0.418323            
straetlingite5.5    Ca2Al2SiO7(H2O)5.5                                          0.373285            
straetlingite7      Ca2Al2SiO7(H2O)7                                            0.400307            
syngenite           K2Ca(SO4)2H2O                                               0.328419            
thaumasite          (CaSiO3)(CaSO4)(CaCO3)(H2O)15                               0.622621            
tricarboalu         {CO3}3:Ca6Al2(OH)12(H2O)26                                  1.146944            
tricarboalu03       (CO3)Ca2Al0.6666667(OH)4(H2O)8.6666667                      0.382315            
zeoliteP_Ca         Ca(Al2Si2)O8(H2O)4.5                                        0.359276            
zeoliteX            Na2(Al2Si2.5)O9(H2O)6.2                                     0.425846            
zeoliteY            Na2(Al2Si4)O12(H2O)8                                        0.548400            

Inspecting the species in the database with given chemical elements#

Often, we are not interested in all species in a database, but only in those that contain some chemical elements. We show below how the species that can be formed from the elements H, O, C, and Ca can be collected and printed:

for species in db.species().withElements("H O C Ca"):
    print(species.name())
Arg
CH4
CH4@
CO2
CO2@
CO3-2
Ca(CO3)@
Ca(HCO3)+
Ca+2
CaOH+
Cal
Gr
H+
H2
H2@
H2O
H2O@
HCO3-
Lim
O2
O2@
OH-
Portlandite

Inspecting the species in the database with given aggregate state#

What if we want to collect only gaseous species from a database? Check next:

for species in db.speciesWithAggregateState(AggregateState.Gas):
    print(species.name())
CH4
CO2
H2
H2O
H2S
N2
O2

And what if only gases with C, H, O elements?

for species in db.speciesWithAggregateState(AggregateState.Gas).withElements("C H O"):
    print(species.name())
CH4
CO2
H2
H2O
O2

Inspecting the elements in the database#

We can also check all the chemical elements available in the database:

print(f"{'Symbol':<10}{'Molar Mass (kg/mol)':<10}")
for element in db.elements():
    print(f"{element.symbol():<10}{element.molarMass():<10.6f}")
Symbol    Molar Mass (kg/mol)
Al        0.026982  
Ca        0.040078  
H         0.001008  
O         0.015999  
Si        0.028086  
Na        0.022990  
S         0.032067  
C         0.012011  
Mg        0.024305  
Cl        0.035453  
Fe        0.055845  
Sr        0.087620  
K         0.039098  
N         0.014007  

That’s it. You should now be able to load and inspect databases in Reaktoro the way you want!

Tip

You might want to check the API documentation of all Reaktoro components (classes and their methods) used in this tutorial: