ThermoHubClient

ThermoHubClient for retrieving data from ThermoHub local or remote (db.thermohub.net) database.

  • Comes with a C++ and a Python interface.

  • A full ThermoDataSet can be retrieved as a JSON string or can be saved to a JSON file. This can be used to initialize ThermoFun for calculating thermodynamic properties for a given T and P.

  • Subsets of data can be saved based on a given list of elements, substances, substance classes, and aggregate states.

  • Functions to check for the available data.

  • By default it connects to db.thermohub.net remote thermodynamic database but it can also connect to a local arangodb database.

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

Try it out in your browser

ThermoHubClient Demo

Wait until the Jupyter Lab Notebook server starts (~1 min).

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.

Where to get ThermoHubClient

  • The open source code is available in the github repository:

ThermoHubClient Github Repository

  • ThermoHubClient library can be installed on a local machine (Windows, Mac, Linux) using Conda/Miniconda
   conda install -c conda-forge thermohubclient

Conda-Forge

Questions that ThermoHubClient can answer

  • Which (internally consistent) datasets are available in the database?

  • What are the elements, substances and reactions available in a certain dataset (e.g. PSI/Nagra or imported THEREDA database) for a given list of elements?

Python Example

import thermohubclient as client

# database connection(local or remote) using a configuration file (file example in /pytests)
dbc = client.DatabaseClient("hub-connection-config.json")

# default connection(remote) to db.thermohub.net
dbc_default = client.DatabaseClient()

# Save ThermoDataSet 'aq17' to a database file aq17-thermofun.json
dbc_default.saveDatabase("aq17")

# Save a subset of ThermoDataSet 'aq17' to a database file aq17-subset-thermofun.json, using a list of elements
dbc_default.saveDatabaseContainingElements(
    "aq17", ["H", "O", "Na", "K", "Si", "Al", "Cl", "Zr", "Zz"])

# Save a subset of ThermoDataSet 'mines16' to a database file mines16-subset-thermofun.json,
# using a (optional) list of elements, substances, and substance classes.
# Only the data that fulfils all selection criteria will be saved
dbc.saveDatabaseSubset("mines16", ["H", "O", "Na", "K", "Si", "Al", "Cl", "Zr", "Zz"],
                       ["O2@", "H2@", "NaHSiO3@", "Al(OH)2+", "NaAl(OH)4@", "Al+3",
                        "AlH3SiO4+2", "AlOH+2", "Al(OH)4-", "H2", "O2", "H2O"],
                       ["{\"1\":\"SC_GASFLUID\"}", "{\"3\":\"SC_AQSOLVENT\"}"])

# Get ThermoDataSet 'mines16' as a JSON string
# all 'save...' functions have a 'get...' function counterpart
# getDatabase, getDatabaseContainingElements, getDatabaseSubset
jsonMines16 = dbc.getDatabase("mines16")

print("ThermoDataSets")
for t in dbc.availableThermoDataSets():
    print(f'{t}')
print('\n')

print("Elements")
for e in dbc.elementsInThermoDataSet("aq17"):
    print(f'{e}')
print('\n')

print("Substances")
for e in dbc.substancesInThermoDataSet("aq17"):
    print(f'{e}')
print('\n')

print("Reactions")
for e in dbc.reactionsInThermoDataSet("mines16"):
    print(f'{e}')
print('\n')

print("Substances classes")
for e in dbc.substanceClassesInThermoDataSet("aq17"):
    print(f'{e}')
print('\n')

print("Substances aggregate state")
for e in dbc.substanceAggregateStatesInThermoDataSet("aq17"):
    print(f'{e}')
print('\n')

C++ Example

#include <iostream>
#include <ThermoHubClient/ThermoHubClient.h>
using namespace std;
using namespace ThermoHubClient;

int main()
{
    DatabaseClient dbc("hub-connection-config.json"); // database connection  (local or remote) using a configuration file

    DatabaseClient dbc_default; // default connection (remote) to db.thermohub.net

    // Save ThermoDataSet 'aq17' to a database file aq17-thermofun.json
    dbc_default.saveDatabase("aq17");

    // Save a subset of ThermoDataSet 'aq17' to a database file aq17-subset-thermofun.json, using a list of elements
    dbc_default.saveDatabaseContainingElements("aq17", {"H", "O", "Na", "K", "Si", "Al", "Cl", "Zr", "Zz"});

    // Save a subset of ThermoDataSet 'mines16' to a database file mines16-subset-thermofun.json, 
    // using a list of elements, substances, and substance classes. 
    // Only the data that fulfils all selection criteria will be saved
    dbc.saveDatabaseSubset("mines16", {"H", "O", "Na", "K", "Si", "Al", "Cl", "Zr", "Zz"},
                           {"O2@", "H2@", "NaHSiO3@", "Al(OH)2+", "NaAl(OH)4@", "Al+3", "AlH3SiO4+2", "AlOH+2", "Al(OH)4-", "H2", "O2", "H2O"},
                           {"{\"1\":\"SC_GASFLUID\"}", "{\"3\":\"SC_AQSOLVENT\"}"});

    // Get ThermoDataSet 'mines16' as a JSON string
    // all 'save...' functions have a 'get...' function counterpart
    // getDatabase, getDatabaseContainingElements, getDatabaseSubset
    std::string jsonMines16 = dbc.getDatabase("mines16");

    auto tds = dbc.availableThermoDataSets();
    cout << "ThermoDataSets" << endl;
    for (auto t : tds)
        cout << t << endl;

    cout << "Elements" << endl;
    for (auto e : dbc.elementsInThermoDataSet("aq17"))
        cout << e << " ";
    cout << endl;

    cout << "Substances" << endl;
    for (auto e : dbc.substancesInThermoDataSet("aq17"))
        cout << e << " ";
    cout << endl;

    cout << "Reactions" << endl;
    for (auto e : dbc.reactionsInThermoDataSet("mines16"))
        cout << e << " ";
    cout << endl;

    cout << "Substances classes" << endl;
    for (auto e : dbc.substanceClassesInThermoDataSet("aq17"))
        cout << e << " ";
    cout << endl;

    cout << "Substances aggregate state" << endl;
    for (auto e : dbc.substanceAggregateStatesInThermoDataSet("aq17"))
        cout << e << " ";
    cout << endl;

    return 0;
}