ThermoFun is an open-source client that delivers thermodynamic properties of substances and reactions at the temperature and pressure of interest.
The Batch class is useful for doing multiple (batch) calculations for a given list of substances, reactions, properties, and desired temperature and pressure grid. Several options to set the input and output properties units are available.
import thermofun as fun
Load a database from file. The available databases for testing are found in the databases/
folder. .
database = fun.Database("databases/slop98-inorganic-thermofun.json")
Initialize a batch
object using the database
object
batch = fun.ThermoBatch(database)
Important! ThermoFun uses SI units, but the ThermoBatch
class allows the user to set the desired units for the input and output parameters.
batch.setPropertiesUnits(["temperature", "pressure"],["degC","bar"])
Optional: Set significant digits (same order as the list of property symbols).
batch.setPropertiesDigits(["gibbs_energy","entropy", "volume",
"enthalpy","logKr", "temperature", "pressure"], [0, 4, 4, 4, 4, 0, 3])
Setup the list of substances or reactions and the properties you wish to calculate.
substances = ["Na+", "Mg+2", "Ca+2", "SiO2@"]
properties = ["gibbs_energy", "enthalpy", "entropy"]
There are different ways to define the temperatures and pressures at which the calculations should be done. One way is defining a temperature pressure pair list:
temperature_pressure_pairs = [[50,1000], [150,1000], [200,1000], [250,1000], [300,1000], [350,1000],
[400,1000], [450,1000], [500,1000], [550,1000], [600,1000], [650,1000],
[700,1000], [800,1000], [900,1000], [1000,1000]]
To do the calculations and write the results to a CSV file:
batch.thermoPropertiesSubstance(temperature_pressure_pairs, substances, properties).toCSV("results.csv")
How do the results look on a plot:
from common.functions import plot_substances_properties_vs_temperature
figure = plot_substances_properties_vs_temperature('results.csv', substances, 1000)