ThermoFun is a universal open-source client that delivers thermodynamic properties of substances and reactions at the temperature and pressure of interest.

  • The library comes as a C++ and Python API for single or batch calculations

  • ThermoFun takes the input data for its calculations locally from JSON files or via (remote) access to the ThermoHub using ThermoHubClient.

  • ThermoFun graphical user interface is used for tabulating thermodynamic properties of substances or reactions.

  • Results passed in memory to codes that call ThermoFun or are written in a CSV table file.

  • The library contains a collection of models and Equations Of State (EoS) for: solid, aqueous, gaseous, and melt –components Methods.

  • A certain model or EoS is not present? ThermoFun library is always extendable with new methods and EoS models. Taking advantage of the modular structure in which adding a new method should be straight forward.

For questions and issues don't hesitate to chat with us on Gitter.

Try it out in your browser

ThermoFun Tutorial

Wait until the Jupyter Lab Notebook server starts (~1 min) then double click on any how-to-... tutorial notebook, or create a new Notebook.

Info

Not using the browser tab for more than a few minutes will turn off the virtual server. To restart the Jupyter Lab Notebook server click again on the launch binder icon above. Refreshing the webpage will not help restarting the server.

ThermoFun interactive webapp

ThermoFun Interactive WebApp

Where to get ThermoFun

The open source code is available in the github repository:

ThermoFun Github Repository

ThermoFun library can be installed on a local machine (Windows, Mac, Linux) using Conda/Miniconda

   conda install -c conda-forge thermofun

Conda-Forge

How it works?

  • 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.
  • ThermoFun can access any ThermoDataSet available in the ThermoHub database. In addition the user can provide substances and reactions records, or a ThermoDataSet from a local file in a human-readable JSON format.
  • Once ThermoFun is initialized (e.g. with SUPCRT98 ThermoDataSet) the library will provide the user with the standard state properties of a substance or list of substances (available in SUPCRT98) at given temperatures and pressures (in the interval of applicability of the model and ThermoDataSet used, e.g. 0-1000 C, 1-5000 bar, for SUPCRT98). The calculations are done by calling the appropriate models or Equations of State (EoS) for doing the temperature and pressure extrapolations from reference conditions T (298.15 K, 25 C) and P (1e05 Pa, 1 bar) to the specified T and P (e.g. HKF EoS in case of SUPCRT98 aqueous species substance records).

Questions that ThermoFun can answer

  • What are the values of selected thermodynamic properties (Gibbs energy, entropy, reaction constant, etc.) of a substance or a reaction for given T and P ranges?

  • What are the thermodynamic functions/properties for a list of substances (GEM) or a list of reactions (LMA) at given T and P?

Python example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import thermofun as fun

engine = fun.ThermoEngine('slop98-thermofun.json')

substance_properties = engine.thermoPropertiesSubstance(473, 2000e5, "Ca+2")

G = properties.gibbs_energy.val
A = properties.helmholtz_energy.val
U = properties.internal_energy.val
H = properties.enthalpy.val
S = properties.entropy.val
V = properties.volume.val
Cp= properties.heat_capacity_cp.val

reaction_properties = engine.thermoPropertiesReaction(298.15, 1e5, "Cal = Ca+2 + CO3-2")

logK = reaction_properties.log_equilibrium_constant.val
Gr = reaction_properties.reaction_gibbs_energy.val
Ar = reaction_properties.reaction_helmholtz_energy.val
Ur = reaction_properties.reaction_internal_energy.val
Hr = reaction_properties.reaction_enthalpy.val
Sr = reaction_properties.reaction_entropy.val
Vr = reaction_properties.reaction_volume.val
Cpr= reaction_properties.reaction_heat_capacity_cp.val

C++ example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#include "Thermofun/ThermoFun.h"
using namespace std;

int main()
{
    ThermoFun::Batch batch("aq17-thermofun.json");

    batch.setPropertiesUnits({"temperature", "pressure"},{"degC","bar"});
    batch.setTemperatureIncrement(0, 200, 25);
    batch.setPressureIncrement(100, 1000, 50);

    batch.thermoPropertiesSubstance({"Al+3", "OH-", "SiO2@"},
                                    {"gibbs_energy","entropy", "volume", "enthalpy"},
                                   ).toCSV("results.csv");
    return 0;
}