Skip to content

Commit

Permalink
Merge pull request #7 from SalvadorBrandolin/main
Browse files Browse the repository at this point in the history
to clapeyron
  • Loading branch information
SalvadorBrandolin authored Dec 26, 2023
2 parents 8354b68 + 0981f48 commit 5c6d4e2
Show file tree
Hide file tree
Showing 27 changed files with 1,063 additions and 11 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ exclude tox.ini
exclude .readthedocs.yml
exclude requirements-dev.txt
exclude *.png
exclude binder.ipynb
exclude reminder.md

recursive-exclude dist *
Expand Down
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ in the molecule.
ugropy is in an early development stage, leaving issues of examples of
molecules that ugropy fails solving the UNIFAC's groups is very helpful.

## Try ugropy now
You can try ugropy from it's
[Binder](https://mybinder.org/v2/gh/ipqa-research/ugropy/main). Open the
binder.ipynb file to explore the basic features.

## Models supported v1.0.0
- Classic liquid-vapor UNIFAC
- Predictive Soave-Redlich-Kwong (PSRK)
- Joback

## Example of use
You can check the full tutorial [here](https://ugropy.readthedocs.io/en/latest/tutorial/tutorial.html).
You can check the full tutorial
[here](https://ugropy.readthedocs.io/en/latest/tutorial/tutorial.html).

Get UNIFAC groups from the molecule's name:

Expand Down Expand Up @@ -70,6 +76,26 @@ print(f"{limonene.joback.vapor_pressure(176 + 273.15)} bar")
657.4486692170663 K
1.0254019428522743 bar

Write down the [Clapeyron.jl](https://github.com/ClapeyronThermo/Clapeyron.jl)
.csv input files.

```python
from ugropy import writers

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_groups for g in grps],
psrk_groups=[g.psrk_groups for g in grps],
joback_objects=[g.joback for g in grps],
path="./database"
)
```

## Installation
At the moment ugropy is not uploaded in PyPI (will be soon).

Expand Down
183 changes: 183 additions & 0 deletions binder.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Welcome to the ugropy's Binder\n",
"\n",
"You can use this notebook to try the basics features of ugropy. You can \n",
"check the full tutorial here: https://ugropy.readthedocs.io/en/latest/index.html\n",
"\n",
"Let's use the Groups class to obtain information of the desired molecules:"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [],
"source": [
"from ugropy import Groups\n",
"\n",
"# Write the molecule's name as it appears on pubchem\n",
"molecule_name = \"ethanol\"\n",
"\n",
"mol = Groups(molecule_name)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Get groups information and properties from the Joback model"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'CH3': 1, 'CH2': 1, 'OH': 1}\n",
"{'CH3': 1, 'CH2': 1, 'OH': 1}\n",
"{'-CH3': 1, '-CH2-': 1, '-OH (alcohol)': 1}\n"
]
}
],
"source": [
"print(mol.unifac_groups)\n",
"print(mol.psrk_groups)\n",
"print(mol.joback.groups)"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"57.56641437226128\n",
"499.40737356625846\n",
"1.702089531406276\n"
]
}
],
"source": [
"# Experimental value of ethanol's critical pressure is 61.37 bar\n",
"print(mol.joback.critical_pressure)\n",
"\n",
"# Experimental value of ethanol's critical temperature is 514.0 K\n",
"print(mol.joback.critical_temperature)\n",
"\n",
"# Vapor pressure at the normal boiling temperature of ethanol\n",
"print(mol.joback.vapor_pressure(78.37 + 273.15))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can provide the normal boiling point of the molecules to improve some \n",
"Joback's predictions."
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [],
"source": [
"mol = Groups(molecule_name, normal_boiling_temperature=78.37+273.15)"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"520.0914853232541\n",
"1.0132499999999998\n"
]
}
],
"source": [
"print(mol.joback.critical_temperature)\n",
"\n",
"print(mol.joback.vapor_pressure(78.37+273.15))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can also create a Groups object from the molecule's SMILES."
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"520.0914853232541\n",
"1.0132499999999998\n"
]
}
],
"source": [
"# Ethanol again\n",
"mol = Groups(\n",
" \"CCO\", \n",
" identifier_type=\"smiles\", \n",
" normal_boiling_temperature=78.37+273.15\n",
")\n",
"\n",
"print(mol.joback.critical_temperature)\n",
"\n",
"print(mol.joback.vapor_pressure(78.37+273.15))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Check the tutorial to explore more features."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "ugropy",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
19 changes: 19 additions & 0 deletions docs/source/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,25 @@ Estimate properties with the Joback model!
657.4486692170663 K
1.0254019428522743 bar

Write down the Clapeyron.jl .csv input files.

.. code:: python
from ugropy import writers
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_groups for g in grps],
psrk_groups=[g.psrk_groups for g in grps],
joback_objects=[g.joback for g in grps],
path="./database"
)
Installation
============

Expand Down
6 changes: 6 additions & 0 deletions docs/source/tutorial/database/PSRK/PSRK_groups.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Clapeyron Database File,
PSRK Groups [csvtype = groups,grouptype = PSRK]
species,groups
limonene,"[""CH3"" => 2, ""CH2"" => 3, ""CH"" => 1, ""CH2=C"" => 1, ""CH=C"" => 1]"
adrenaline,"[""CH2"" => 1, ""ACH"" => 3, ""ACCH"" => 1, ""OH"" => 1, ""ACOH"" => 2, ""CH3NH"" => 1]"
Trinitrotoluene,"[""ACH"" => 2, ""ACCH3"" => 1, ""ACNO2"" => 3]"
6 changes: 6 additions & 0 deletions docs/source/tutorial/database/critical.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Clapeyron Database File,,,,,
Critical Single Parameters,,,,,
species,CAS,Tc,Pc,Vc,acentricfactor
limonene,,657.4486692170663,2755561.066677689,0.0004965,0.3219127551737521
adrenaline,,953.7486693594541,5569169.079973267,0.0004115,1.6071531017924205
Trinitrotoluene,,1146.7095578060987,4067315.701790919,0.0005654999999999999,1.0796561474496789
6 changes: 6 additions & 0 deletions docs/source/tutorial/database/molarmass.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Clapeyron Database File,,
Molar Mases Single Params,,
species,CAS,Mw
limonene,,136.23760000000001
adrenaline,,183.20680000000002
Trinitrotoluene,,227.132
6 changes: 6 additions & 0 deletions docs/source/tutorial/database/ogUNIFAC/ogUNIFAC_groups.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Clapeyron Database File,
original UNIFAC Groups,[csvtype = groups,grouptype = originalUNIFAC]
species,groups
limonene,"[""CH3"" => 2, ""CH2"" => 3, ""CH"" => 1, ""CH2=C"" => 1, ""CH=C"" => 1]"
adrenaline,"[""CH2"" => 1, ""ACH"" => 3, ""ACCH"" => 1, ""OH"" => 1, ""ACOH"" => 2, ""CH3NH"" => 1]"
Trinitrotoluene,"[""ACH"" => 2, ""ACCH3"" => 1, ""ACNO2"" => 3]"
6 changes: 3 additions & 3 deletions docs/source/tutorial/easy_way.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
"metadata": {},
"source": [
"Well, that was easy... `ugropy` uses\n",
"[`PubChemPy`](https://github.com/mcs07/PubChemPy) to access to pubchem and\n",
"`PubChemPy` (https://github.com/mcs07/PubChemPy) to access to pubchem and\n",
"obtain the SMILES representation of the molecule. ugropy uses the SMILES\n",
"representation and the [`rdkit`](https://github.com/rdkit/rdkit) library to\n",
"representation and the `rdkit` (https://github.com/rdkit/rdkit) library to\n",
"obtain the functional groups of the molecules.\n",
"\n",
"The complete signature of the `Groups` class is the following:"
Expand Down Expand Up @@ -351,7 +351,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.10.6"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions docs/source/tutorial/hard_way.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"source": [
"#### Joback\n",
"\n",
"For context, check the [Joback's article](https://doi.org/10.1080/00986448708960487).\n",
"For context, check the Joback's article: https://doi.org/10.1080/00986448708960487\n",
"\n",
"The Joback object is instantiated by the Group object as we saw in the previous \n",
"tutorial but, a Joback object can be instantiated individually:"
Expand Down Expand Up @@ -314,7 +314,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.10.6"
}
},
"nbformat": 4,
Expand Down
10 changes: 8 additions & 2 deletions docs/source/tutorial/installation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@
"At the moment ugropy is not uploaded in PyPI (will be soon).\n",
"\n",
"```\n",
"pip install git+https://github.com/SalvadorBrandolin/ugropy.git\n",
"pip install git+https://github.com/ipqa-research/ugropy.git\n",
"```"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "ugropy",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
"name": "python",
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down
3 changes: 2 additions & 1 deletion docs/source/tutorial/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ Tutorial
installation.ipynb
easy_way.ipynb
hard_way.ipynb
ugropy_failing.ipynb
ugropy_failing.ipynb
writers.ipynb
Loading

0 comments on commit 5c6d4e2

Please sign in to comment.