ThermoFun is an open-source client that delivers thermodynamic properties of substances and reactions at the temperature and pressure of interest.
Import ThermoFun python package
import thermofun as fun
ThermoFun is initialized with a ThermoDataSet. A ThermoDataSet is a collection of records of substances and/or reactions also known in the (geo)chemical community as a thermodynamic database, e.g. SUPCRT98, PSI-Nagra, CEMDATA18. In this example we use a provided database file aq17-thermofun.json
containing several substances (aqueous species, gases, and minerals).
Load a database from file. The available databases for testing are found in the databases/
folder.
database = fun.Database('databases/aq17-gem-lma-thermofun.json')
database
offers several functionalities to retrieve information on what exactly it contains. For example one can get the map of substances. In python substances
is a dictionary (symbol : substance).
substances = database.mapSubstances()
To print all the available substance records (symbols) use the print function of python.
print(substances.keys())
dict_keys(['Akermanite', 'Al(OH)2+', 'Al(OH)3@', 'Al(OH)4-', 'Al+3', 'AlH3SiO4+2', 'AlOH+2', 'Albite', 'Albite high', 'Amesite-Mg', 'Analcite', 'Andalusite', 'Anorthite', 'Anthophyll-Mg', 'Antigorite', 'Aragonite', 'Boehmite', 'Brucite', 'CH4', 'CH4@', 'CO', 'CO2', 'CO2@', 'CO3-2', 'CO@', 'Ca+2', 'CaCO3@', 'CaCl+', 'CaCl2@', 'CaHCO3+', 'CaHSiO3+', 'CaOH+', 'CaSiO3@', 'Calcite', 'Carpholite-Mg', 'Cceladonite-Mg', 'Celadonite-Mg', 'Chlorite-Mg', 'Chloritoid-Mg', 'Chrysotile', 'Cl-', 'Clinochlore', 'Clinohumite', 'Clinozoisite', 'Coesite', 'Cordierite-Mg', 'Corundum', 'Cristobalite', 'Cummingtonite', 'Diamond', 'Diaspore', 'Diopside', 'Dolomite', 'Dolomite-od', 'Eastonite', 'Edenite-Mg', 'Enstatite', 'Forsterite', 'Gedrite-Mg', 'Gehlenite', 'Gibbsite', 'Glaucophane-Mg', 'Graphite', 'Grossular', 'H+', 'H2', 'H2@', 'H2O', 'H2O@', 'H4SiO4@', 'HCO3-', 'HCl@', 'HSiO3-', 'Halite', 'Hcordierite-Mg', 'Heulandite', 'Jadeite', 'K+', 'KAlO2@', 'KCO3-', 'KCl@', 'KHCO3@', 'KOH@', 'Kalsilite', 'Kaolinite', 'Kyanite', 'Larnite', 'Laumontite', 'Lawsonite', 'Leucite', 'Lime', 'Magnesite', 'Margarite', 'Meionite-Ca', 'Meionite-Na', 'Merwinite', 'Mg+2', 'MgCO3@', 'MgCl+', 'MgCl2@', 'MgHCO3+', 'MgHSiO3+', 'MgOH+', 'MgSiO3@', 'Microcline', 'Mizzonite', 'Monticellite', 'Muscovite', 'Na+', 'NaAl(OH)4@', 'NaCO3-', 'NaCl@', 'NaHCO3@', 'NaHSiO3@', 'NaOH@', 'Nceladonite-Mg', 'Nepheline', 'O2', 'O2@', 'OH-', 'Omphacite-Mg', 'Osumilite1-Mg', 'Osumilite2-Mg', 'Paragonite', 'Pargasite-Mg', 'Periclase', 'Phlogopite', 'Phlogopite-Na', 'Portlandite', 'Prehnite', 'Pseudowoll', 'Pumpellyite-Mg', 'Pyrope', 'Pyrophyllite', 'Quartz', 'Rankinite', 'Sanidine', 'Sapphirine4-Mg', 'Sapphirine5-Mg', 'SiO2@', 'Sillimanite', 'Spinel', 'Spurrite', 'Staurolite-Mg', 'Stilbite', 'Stilpnomelane-Mg', 'Stishovite', 'Sudoite-Mg', 'Sylvite', 'Talc-Mg', 'Tilleyite', 'Topaz-OH', 'Tremolite-Mg', 'Tridymite', 'Tschermak-Ca', 'Tschermak-Mg', 'Tschermakite-Mg', 'Ttalc-Mg', 'Vesuvianite', 'Wairakite', 'Wollastonite', 'Zoisite'])
To retrieve one substance use the symbol of the substance as follows:
Corundum = substances['Corundum']
Corundum
contains several functions to retrieve and modify data of this substance.
Corundum.formula()
'Al2O3'
Warning: All changes to the substance will also be present in the database. For example:
Corundum.setFormula('O3Al2')
Corundum2 = substances['Corundum']
Corundum2.formula()
'O3Al2'
If you want to use data for substances or reactions kept in other files, maybe for testing different parameters, you cal always add new data to the database using the appendData
function.
database.appendData('mydata-thermofun.json') # in this file we have a substance record with the symbol my_Al(OH)2+ with a different standard entropy value
sm_entropy = database.getSubstance('my_Al(OH)2+').thermoReferenceProperties().entropy.val
f'my refrences entropy {sm_entropy}'
'my refrences entropy -50.0'
sm_entropy = database.getSubstance('Al(OH)2+').thermoReferenceProperties().entropy.val
f'original reference entropy {sm_entropy}'
'original reference entropy -27.530000686646'