Writers¶
Clapeyron (https://github.com/ClapeyronThermo/Clapeyron.jl)¶
ugropy
provides a writers module for constructing input files for various thermodynamic libraries.
To utilize this function, you must import the module as follows:
[1]:
from ugropy import Groups, writers
To utilize the function, you need to provide a list of dictionaries for the functional groups of UNIFAC and PSRK, where each dictionary contains the functional groups of the molecules.
If the user wishes to write critical properties .csv files, they must provide a list of Joback objects. Let’s illustrate this with a simple example:
[2]:
names = ["limonene", "adrenaline", "Trinitrotoluene"]
grps = [Groups(n) for n in names]
# Write the csv files into a database directory
writers.to_clapeyron(
molecules_names=names,
unifac_groups=[g.unifac.subgroups for g in grps],
psrk_groups=[g.psrk.subgroups for g in grps],
joback_objects=[g.joback for g in grps],
path="database"
)
In the example provided, we create a Groups object to obtain all the information of the molecules. Then, we use list comprehension to create the lists for the to_clapeyron function.
The molecules_name argument in this case receives the names used to create the Groups objects, but it can be different if desired. These names will be set as the molecule names in the .csv files.
You can omit certain arguments if desired:
If you omit the psrk_groups argument: the PSRK_groups.csv file will not be created.
If you omit the unifac_groups argument: the ogUNIFAC_groups.csv file will not be created.
If you omit the joback_objects argument: the critical.csv file will not be created.
Thermo (https://github.com/CalebBell/thermo)¶
ugropy
also provides a translator of its subgroups dictionaries to the Thermo
library dictionaries.
Let’s recreate the simple example of the Thermo
documentation:
https://thermo.readthedocs.io/activity_coefficients.html#unifac-example
[3]:
from thermo.unifac import UFIP, UFSG, UNIFAC
from ugropy import Groups, unifac, writers
names = ["hexane", "2-butanone"]
grps = [Groups(n) for n in names]
thermo_groups = [writers.to_thermo(g.unifac.subgroups, unifac) for g in grps]
print(thermo_groups)
[{1: 2, 2: 4}, {1: 1, 2: 1, 18: 1}]
[4]:
GE = UNIFAC.from_subgroups(
chemgroups=thermo_groups,
T=60+273.15,
xs=[0.5, 0.5],
version=0,
interaction_data=UFIP,
subgroups=UFSG
)
GE.gammas()
[4]:
[1.4276025835624184, 1.3646545010104223]