PyThermoLinkDB 1.3.2__tar.gz → 1.3.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pythermolinkdb-1.3.4/PKG-INFO +276 -0
- pythermolinkdb-1.3.4/PyThermoLinkDB.egg-info/PKG-INFO +276 -0
- {pythermolinkdb-1.3.2 → pythermolinkdb-1.3.4}/PyThermoLinkDB.egg-info/SOURCES.txt +2 -9
- pythermolinkdb-1.3.4/pyproject.toml +44 -0
- pythermolinkdb-1.3.4/test/test-0.py +6 -0
- {pythermolinkdb-1.3.2 → pythermolinkdb-1.3.4}/test/test-3.py +77 -2
- pythermolinkdb-1.3.2/LICENSE +0 -21
- pythermolinkdb-1.3.2/PKG-INFO +0 -292
- pythermolinkdb-1.3.2/PyThermoLinkDB.egg-info/PKG-INFO +0 -292
- pythermolinkdb-1.3.2/pyThermoLinkDB/config/__init__.py +0 -3
- pythermolinkdb-1.3.2/pyThermoLinkDB/config/settings.py +0 -8
- pythermolinkdb-1.3.2/pyThermoLinkDB/data/__init__.py +0 -0
- pythermolinkdb-1.3.2/pyThermoLinkDB/docs/__init__.py +0 -4
- pythermolinkdb-1.3.2/pyThermoLinkDB/docs/thermodbhub.py +0 -649
- pythermolinkdb-1.3.2/pyThermoLinkDB/docs/thermolink.py +0 -179
- pythermolinkdb-1.3.2/pyThermoLinkDB/docs/utils.py +0 -339
- pythermolinkdb-1.3.2/setup.py +0 -53
- {pythermolinkdb-1.3.2 → pythermolinkdb-1.3.4}/PyThermoLinkDB.egg-info/dependency_links.txt +0 -0
- {pythermolinkdb-1.3.2 → pythermolinkdb-1.3.4}/PyThermoLinkDB.egg-info/requires.txt +0 -0
- {pythermolinkdb-1.3.2 → pythermolinkdb-1.3.4}/PyThermoLinkDB.egg-info/top_level.txt +0 -0
- {pythermolinkdb-1.3.2 → pythermolinkdb-1.3.4}/README.md +0 -0
- {pythermolinkdb-1.3.2 → pythermolinkdb-1.3.4}/pyThermoLinkDB/__init__.py +0 -0
- {pythermolinkdb-1.3.2 → pythermolinkdb-1.3.4}/pyThermoLinkDB/app.py +0 -0
- {pythermolinkdb-1.3.2 → pythermolinkdb-1.3.4}/setup.cfg +0 -0
- {pythermolinkdb-1.3.2 → pythermolinkdb-1.3.4}/test/test-1.py +0 -0
- {pythermolinkdb-1.3.2 → pythermolinkdb-1.3.4}/test/test-2.py +0 -0
- {pythermolinkdb-1.3.2 → pythermolinkdb-1.3.4}/test/test-4.py +0 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: PyThermoLinkDB
|
|
3
|
+
Version: 1.3.4
|
|
4
|
+
Summary: PyThermoLinkDB is a Python package providing a robust and efficient interface between `PyThermoDB` and other applications.
|
|
5
|
+
Author-email: Sina Gilassi <sina.gilassi@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/sinagilassi/PyThermoLinkDB
|
|
8
|
+
Project-URL: Documentation, https://pythermolinkdb.readthedocs.io/en/latest/
|
|
9
|
+
Project-URL: Source, https://github.com/sinagilassi/PyThermoLinkDB
|
|
10
|
+
Project-URL: Issue Tracker, https://github.com/sinagilassi/PyThermoLinkDB/issues
|
|
11
|
+
Keywords: chemical engineering,thermodynamics,PyThermoDB
|
|
12
|
+
Classifier: Development Status :: 1 - Planning
|
|
13
|
+
Classifier: Intended Audience :: Education
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Operating System :: Unix
|
|
16
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
17
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
Requires-Dist: PyYAML
|
|
21
|
+
Requires-Dist: PyThermoDB
|
|
22
|
+
|
|
23
|
+
# PyThermoLinkDB
|
|
24
|
+
|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
   
|
|
28
|
+
|
|
29
|
+
`PyThermoLinkDB` is a Python package providing a robust and efficient interface between `PyThermoDB` and other applications. It enables seamless thermodynamic data exchange, integration, and analysis. With PyThermoLinkDB, developers can easily link PyThermoDB to various tools, frameworks, and databases, streamlining thermodynamic workflows.
|
|
30
|
+
|
|
31
|
+
## ✨ **Key Features**
|
|
32
|
+
|
|
33
|
+
- 🔹 Simple and intuitive API
|
|
34
|
+
- ⚡ Efficient data transfer and integration
|
|
35
|
+
- 📂 Compatible with multiple data formats
|
|
36
|
+
- 📚 Extensive documentation and examples
|
|
37
|
+
|
|
38
|
+
Ideal for researchers, engineers, and developers working with thermodynamic data, PyThermoLinkDB simplifies data integration and analysis, accelerating scientific discoveries and industrial applications.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## 🌐 **Google Colab**
|
|
42
|
+
|
|
43
|
+
You can run `PyThermoLinkDB` in Google Colab:
|
|
44
|
+
|
|
45
|
+
- Basic Usage 1 [](https://colab.research.google.com/drive/1JU1ljkHgKcBNe_CuSh2Bg7hoKwQUJti0?usp=sharing)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## 📥 **Installation**
|
|
49
|
+
|
|
50
|
+
Install `pyThermoLinkDB` and `PyThermoDB` with pip
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
pip install pyThermoLinkDB
|
|
54
|
+
pip install PyThermoDB
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 🛠️ **Usage Example**
|
|
58
|
+
|
|
59
|
+
### 🔄 **Load ThermoDB**
|
|
60
|
+
|
|
61
|
+
This section demonstrates how to load thermodynamic data files from `PyThermoDB`.
|
|
62
|
+
|
|
63
|
+
Multiple thermodynamic databases are imported: one for CO2, one for methanol, and one for NRTL interaction parameters. Each database is loaded from a pickle file using the `load_thermodb` function, and then verified with the `check()` method to ensure data integrity.
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
# import packages/modules
|
|
67
|
+
import os
|
|
68
|
+
from rich import print
|
|
69
|
+
import pyThermoLinkDB as ptdblink
|
|
70
|
+
import pyThermoDB as ptdb
|
|
71
|
+
|
|
72
|
+
# SECTION CO2
|
|
73
|
+
CO2_thermodb_file = os.path.join(
|
|
74
|
+
os.getcwd(), 'test', 'carbon dioxide-1.pkl')
|
|
75
|
+
# load
|
|
76
|
+
CO2_thermodb = ptdb.load_thermodb(CO2_thermodb_file)
|
|
77
|
+
print(type(CO2_thermodb))
|
|
78
|
+
|
|
79
|
+
# check
|
|
80
|
+
print(CO2_thermodb.check())
|
|
81
|
+
|
|
82
|
+
# SECTION methanol
|
|
83
|
+
# thermodb file name
|
|
84
|
+
MeOH_thermodb_file = os.path.join(os.getcwd(), 'test', 'methanol-1.pkl')
|
|
85
|
+
print(f"thermodb file: {MeOH_thermodb_file}")
|
|
86
|
+
# load
|
|
87
|
+
MeOH_thermodb = ptdb.load_thermodb(MeOH_thermodb_file)
|
|
88
|
+
print(type(MeOH_thermodb))
|
|
89
|
+
|
|
90
|
+
MeOH_thermodb
|
|
91
|
+
|
|
92
|
+
# check
|
|
93
|
+
print(MeOH_thermodb.check())
|
|
94
|
+
|
|
95
|
+
# SECTION nrtl
|
|
96
|
+
# thermodb file name
|
|
97
|
+
nrtl_thermodb_file = os.path.join(
|
|
98
|
+
os.getcwd(), 'test', 'thermodb_nrtl_1.pkl')
|
|
99
|
+
print(f"thermodb file: {nrtl_thermodb_file}")
|
|
100
|
+
# load
|
|
101
|
+
nrtl_thermodb = ptdb.load_thermodb(nrtl_thermodb_file)
|
|
102
|
+
print(type(nrtl_thermodb))
|
|
103
|
+
|
|
104
|
+
# check
|
|
105
|
+
print(nrtl_thermodb.check())
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 🔌 **Initialize Thermodb Hub**
|
|
109
|
+
|
|
110
|
+
This section demonstrates how to initialize a ThermoDB hub using the `init()` function, which creates a central repository for thermodynamic data.
|
|
111
|
+
|
|
112
|
+
The code shows adding different component databases (methanol, CO2) as well as interaction parameter data (NRTL) to the hub. The `items()` method is used to list all components currently stored in the hub.
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
# init thermodb hub
|
|
116
|
+
thub1 = ptdblink.init()
|
|
117
|
+
print(type(thub1))
|
|
118
|
+
|
|
119
|
+
# add component thermodb
|
|
120
|
+
thub1.add_thermodb('MeOH', MeOH_thermodb)
|
|
121
|
+
thub1.add_thermodb('CO2', CO2_thermodb)
|
|
122
|
+
# matrix data
|
|
123
|
+
thub1.add_thermodb('NRTL', nrtl_thermodb)
|
|
124
|
+
|
|
125
|
+
# get components
|
|
126
|
+
print(thub1.items())
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### ⚙️ **ThermoDB Link Configuration**
|
|
130
|
+
|
|
131
|
+
This section shows the format of the YAML configuration file used to define thermodynamic properties and equations for different compounds. Each component has a `DATA` section for properties (like critical pressure, temperature) and an `EQUATIONS` section for thermodynamic relationships. The configuration file structure helps maintain consistent property mapping across the database.
|
|
132
|
+
|
|
133
|
+
You can use markdown (`.md`), YAML (`.yml`), or text (`.txt`) files to set the ThermoDB configuration. It is also possible to define a variable directly in your code and add the content of a `.yml`, `.txt`, or `.md` file as a string, as long as the format is correct and parsable.
|
|
134
|
+
|
|
135
|
+
Thermodb rule format (`thermodb_config.yml`):
|
|
136
|
+
|
|
137
|
+
```yml
|
|
138
|
+
CO2:
|
|
139
|
+
DATA:
|
|
140
|
+
Pc: Pc
|
|
141
|
+
Tc: Tc
|
|
142
|
+
AcFa: AcFa
|
|
143
|
+
EQUATIONS:
|
|
144
|
+
vapor-pressure: VaPr
|
|
145
|
+
heat-capacity: Cp_IG
|
|
146
|
+
acetylene:
|
|
147
|
+
DATA:
|
|
148
|
+
Pc: Pc
|
|
149
|
+
Tc: Tc
|
|
150
|
+
AcFa: AcFa
|
|
151
|
+
EQUATIONS:
|
|
152
|
+
vapor-pressure: VaPr
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
```markdown
|
|
156
|
+
## CO2
|
|
157
|
+
|
|
158
|
+
- DATA:
|
|
159
|
+
Pc: Pc
|
|
160
|
+
Tc: Tc
|
|
161
|
+
AcFa: AcFa
|
|
162
|
+
- EQUATIONS:
|
|
163
|
+
vapor-pressure: VaPr
|
|
164
|
+
heat-capacity: Cp_IG
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
```txt
|
|
168
|
+
# CO2
|
|
169
|
+
- DATA:
|
|
170
|
+
Pc: Pc
|
|
171
|
+
Tc: Tc
|
|
172
|
+
AcFa: AcFa
|
|
173
|
+
- EQUATIONS:
|
|
174
|
+
vapor-pressure: VaPr
|
|
175
|
+
heat-capacity: Cp_IG
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
# add thermodb rule
|
|
180
|
+
thermodb_config_file = os.path.join(os.getcwd(), 'test', 'thermodb_config.yml')
|
|
181
|
+
|
|
182
|
+
# all components
|
|
183
|
+
res_ = thub1.config_thermodb_rule(thermodb_config_file)
|
|
184
|
+
# selected components
|
|
185
|
+
#res_ = thub1.config_thermodb_rule(thermodb_config_file, names=["MeOH", "CO2"])
|
|
186
|
+
print(res_)
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### 🔧 **Add/Update ThermoDB Rule**
|
|
190
|
+
|
|
191
|
+
This section demonstrates how to add or update a ThermoDB rule for a specific chemical compound (e.g., CO2). The rule includes critical data properties and equations related to the compound, which are then added to the ThermoDB using the `add_thermodb_rule` method.
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
# update thermodb rule
|
|
195
|
+
thermodb_rule_CO2 = {
|
|
196
|
+
'DATA': {
|
|
197
|
+
'Pc': 'Pc1',
|
|
198
|
+
'Tc': 'Tc1',
|
|
199
|
+
'AcFa': 'AcFa1'
|
|
200
|
+
},
|
|
201
|
+
'EQUATIONS': {
|
|
202
|
+
'vapor-pressure': 'VaPr1',
|
|
203
|
+
'heat-capacity': 'Cp_IG1'
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
# add thermodb rule for CO2
|
|
208
|
+
thub1.add_thermodb_rule('CO2', thermodb_rule_CO2)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### 🗑️ **Delete ThermoDB Rule**
|
|
212
|
+
|
|
213
|
+
This section demonstrates how to delete a specific ThermoDB rule using the `delete_thermodb_rule` method. In this example, the rule associated with 'CO2' is being removed.
|
|
214
|
+
|
|
215
|
+
```python
|
|
216
|
+
# delete thermodb rule for CO2
|
|
217
|
+
thub1.delete_thermodb_rule('CO2')
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### 🔨 **Build ThermoDB Hub**
|
|
221
|
+
|
|
222
|
+
This section demonstrates the process of building data sources and equation sources using the `build` method, and then prints the resulting objects. Additionally, it showcases accessing and printing the `hub` attribute.
|
|
223
|
+
|
|
224
|
+
```python
|
|
225
|
+
# build
|
|
226
|
+
datasource, equationsource = thub1.build()
|
|
227
|
+
print(datasource)
|
|
228
|
+
print(equationsource)
|
|
229
|
+
|
|
230
|
+
# hub
|
|
231
|
+
print(thub1.hub)
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### 📊 **Retrieve Data/Equation**
|
|
235
|
+
|
|
236
|
+
This section demonstrates how to access various thermodynamic data and equations from the built ThermoDB hub. Examples include retrieving critical properties (Pc, Tc) for different components, NRTL interaction parameters, and calculating values using vapor pressure and activity coefficient equations at specified conditions.
|
|
237
|
+
|
|
238
|
+
```python
|
|
239
|
+
# CO2 data
|
|
240
|
+
dt1_ = datasource['CO2']['Pc']
|
|
241
|
+
print(type(dt1_))
|
|
242
|
+
print(dt1_)
|
|
243
|
+
|
|
244
|
+
# MeOH data
|
|
245
|
+
dt2_ = datasource['MeOH']['Tc']
|
|
246
|
+
print(type(dt2_))
|
|
247
|
+
print(dt2_)
|
|
248
|
+
|
|
249
|
+
# NRTL data
|
|
250
|
+
dt3_ = datasource['NRTL']['alpha_i_j']
|
|
251
|
+
print(type(dt3_))
|
|
252
|
+
print(dt3_.ij("Alpha_methanol_ethanol"))
|
|
253
|
+
|
|
254
|
+
# CO2 equation
|
|
255
|
+
eq1_ = equationsource['CO2']['VaPr']
|
|
256
|
+
print(type(eq1_))
|
|
257
|
+
print(eq1_)
|
|
258
|
+
print(eq1_.args)
|
|
259
|
+
print(eq1_.cal(T=298.15))
|
|
260
|
+
|
|
261
|
+
# nrtl equation
|
|
262
|
+
eq2_ = equationsource['NRTL']['tau_i_j']
|
|
263
|
+
print(type(eq2_))
|
|
264
|
+
print(eq2_)
|
|
265
|
+
print(eq2_.args)
|
|
266
|
+
print(eq2_.cal(T=298.15))
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## ❓ **FAQ**
|
|
270
|
+
|
|
271
|
+
For any question, contact me on [LinkedIn](https://www.linkedin.com/in/sina-gilassi/)
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
## 👨💻 **Authors**
|
|
275
|
+
|
|
276
|
+
- [@sinagilassi](https://www.github.com/sinagilassi)
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: PyThermoLinkDB
|
|
3
|
+
Version: 1.3.4
|
|
4
|
+
Summary: PyThermoLinkDB is a Python package providing a robust and efficient interface between `PyThermoDB` and other applications.
|
|
5
|
+
Author-email: Sina Gilassi <sina.gilassi@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/sinagilassi/PyThermoLinkDB
|
|
8
|
+
Project-URL: Documentation, https://pythermolinkdb.readthedocs.io/en/latest/
|
|
9
|
+
Project-URL: Source, https://github.com/sinagilassi/PyThermoLinkDB
|
|
10
|
+
Project-URL: Issue Tracker, https://github.com/sinagilassi/PyThermoLinkDB/issues
|
|
11
|
+
Keywords: chemical engineering,thermodynamics,PyThermoDB
|
|
12
|
+
Classifier: Development Status :: 1 - Planning
|
|
13
|
+
Classifier: Intended Audience :: Education
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Operating System :: Unix
|
|
16
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
17
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
Requires-Dist: PyYAML
|
|
21
|
+
Requires-Dist: PyThermoDB
|
|
22
|
+
|
|
23
|
+
# PyThermoLinkDB
|
|
24
|
+
|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
   
|
|
28
|
+
|
|
29
|
+
`PyThermoLinkDB` is a Python package providing a robust and efficient interface between `PyThermoDB` and other applications. It enables seamless thermodynamic data exchange, integration, and analysis. With PyThermoLinkDB, developers can easily link PyThermoDB to various tools, frameworks, and databases, streamlining thermodynamic workflows.
|
|
30
|
+
|
|
31
|
+
## ✨ **Key Features**
|
|
32
|
+
|
|
33
|
+
- 🔹 Simple and intuitive API
|
|
34
|
+
- ⚡ Efficient data transfer and integration
|
|
35
|
+
- 📂 Compatible with multiple data formats
|
|
36
|
+
- 📚 Extensive documentation and examples
|
|
37
|
+
|
|
38
|
+
Ideal for researchers, engineers, and developers working with thermodynamic data, PyThermoLinkDB simplifies data integration and analysis, accelerating scientific discoveries and industrial applications.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## 🌐 **Google Colab**
|
|
42
|
+
|
|
43
|
+
You can run `PyThermoLinkDB` in Google Colab:
|
|
44
|
+
|
|
45
|
+
- Basic Usage 1 [](https://colab.research.google.com/drive/1JU1ljkHgKcBNe_CuSh2Bg7hoKwQUJti0?usp=sharing)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## 📥 **Installation**
|
|
49
|
+
|
|
50
|
+
Install `pyThermoLinkDB` and `PyThermoDB` with pip
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
pip install pyThermoLinkDB
|
|
54
|
+
pip install PyThermoDB
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 🛠️ **Usage Example**
|
|
58
|
+
|
|
59
|
+
### 🔄 **Load ThermoDB**
|
|
60
|
+
|
|
61
|
+
This section demonstrates how to load thermodynamic data files from `PyThermoDB`.
|
|
62
|
+
|
|
63
|
+
Multiple thermodynamic databases are imported: one for CO2, one for methanol, and one for NRTL interaction parameters. Each database is loaded from a pickle file using the `load_thermodb` function, and then verified with the `check()` method to ensure data integrity.
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
# import packages/modules
|
|
67
|
+
import os
|
|
68
|
+
from rich import print
|
|
69
|
+
import pyThermoLinkDB as ptdblink
|
|
70
|
+
import pyThermoDB as ptdb
|
|
71
|
+
|
|
72
|
+
# SECTION CO2
|
|
73
|
+
CO2_thermodb_file = os.path.join(
|
|
74
|
+
os.getcwd(), 'test', 'carbon dioxide-1.pkl')
|
|
75
|
+
# load
|
|
76
|
+
CO2_thermodb = ptdb.load_thermodb(CO2_thermodb_file)
|
|
77
|
+
print(type(CO2_thermodb))
|
|
78
|
+
|
|
79
|
+
# check
|
|
80
|
+
print(CO2_thermodb.check())
|
|
81
|
+
|
|
82
|
+
# SECTION methanol
|
|
83
|
+
# thermodb file name
|
|
84
|
+
MeOH_thermodb_file = os.path.join(os.getcwd(), 'test', 'methanol-1.pkl')
|
|
85
|
+
print(f"thermodb file: {MeOH_thermodb_file}")
|
|
86
|
+
# load
|
|
87
|
+
MeOH_thermodb = ptdb.load_thermodb(MeOH_thermodb_file)
|
|
88
|
+
print(type(MeOH_thermodb))
|
|
89
|
+
|
|
90
|
+
MeOH_thermodb
|
|
91
|
+
|
|
92
|
+
# check
|
|
93
|
+
print(MeOH_thermodb.check())
|
|
94
|
+
|
|
95
|
+
# SECTION nrtl
|
|
96
|
+
# thermodb file name
|
|
97
|
+
nrtl_thermodb_file = os.path.join(
|
|
98
|
+
os.getcwd(), 'test', 'thermodb_nrtl_1.pkl')
|
|
99
|
+
print(f"thermodb file: {nrtl_thermodb_file}")
|
|
100
|
+
# load
|
|
101
|
+
nrtl_thermodb = ptdb.load_thermodb(nrtl_thermodb_file)
|
|
102
|
+
print(type(nrtl_thermodb))
|
|
103
|
+
|
|
104
|
+
# check
|
|
105
|
+
print(nrtl_thermodb.check())
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 🔌 **Initialize Thermodb Hub**
|
|
109
|
+
|
|
110
|
+
This section demonstrates how to initialize a ThermoDB hub using the `init()` function, which creates a central repository for thermodynamic data.
|
|
111
|
+
|
|
112
|
+
The code shows adding different component databases (methanol, CO2) as well as interaction parameter data (NRTL) to the hub. The `items()` method is used to list all components currently stored in the hub.
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
# init thermodb hub
|
|
116
|
+
thub1 = ptdblink.init()
|
|
117
|
+
print(type(thub1))
|
|
118
|
+
|
|
119
|
+
# add component thermodb
|
|
120
|
+
thub1.add_thermodb('MeOH', MeOH_thermodb)
|
|
121
|
+
thub1.add_thermodb('CO2', CO2_thermodb)
|
|
122
|
+
# matrix data
|
|
123
|
+
thub1.add_thermodb('NRTL', nrtl_thermodb)
|
|
124
|
+
|
|
125
|
+
# get components
|
|
126
|
+
print(thub1.items())
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### ⚙️ **ThermoDB Link Configuration**
|
|
130
|
+
|
|
131
|
+
This section shows the format of the YAML configuration file used to define thermodynamic properties and equations for different compounds. Each component has a `DATA` section for properties (like critical pressure, temperature) and an `EQUATIONS` section for thermodynamic relationships. The configuration file structure helps maintain consistent property mapping across the database.
|
|
132
|
+
|
|
133
|
+
You can use markdown (`.md`), YAML (`.yml`), or text (`.txt`) files to set the ThermoDB configuration. It is also possible to define a variable directly in your code and add the content of a `.yml`, `.txt`, or `.md` file as a string, as long as the format is correct and parsable.
|
|
134
|
+
|
|
135
|
+
Thermodb rule format (`thermodb_config.yml`):
|
|
136
|
+
|
|
137
|
+
```yml
|
|
138
|
+
CO2:
|
|
139
|
+
DATA:
|
|
140
|
+
Pc: Pc
|
|
141
|
+
Tc: Tc
|
|
142
|
+
AcFa: AcFa
|
|
143
|
+
EQUATIONS:
|
|
144
|
+
vapor-pressure: VaPr
|
|
145
|
+
heat-capacity: Cp_IG
|
|
146
|
+
acetylene:
|
|
147
|
+
DATA:
|
|
148
|
+
Pc: Pc
|
|
149
|
+
Tc: Tc
|
|
150
|
+
AcFa: AcFa
|
|
151
|
+
EQUATIONS:
|
|
152
|
+
vapor-pressure: VaPr
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
```markdown
|
|
156
|
+
## CO2
|
|
157
|
+
|
|
158
|
+
- DATA:
|
|
159
|
+
Pc: Pc
|
|
160
|
+
Tc: Tc
|
|
161
|
+
AcFa: AcFa
|
|
162
|
+
- EQUATIONS:
|
|
163
|
+
vapor-pressure: VaPr
|
|
164
|
+
heat-capacity: Cp_IG
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
```txt
|
|
168
|
+
# CO2
|
|
169
|
+
- DATA:
|
|
170
|
+
Pc: Pc
|
|
171
|
+
Tc: Tc
|
|
172
|
+
AcFa: AcFa
|
|
173
|
+
- EQUATIONS:
|
|
174
|
+
vapor-pressure: VaPr
|
|
175
|
+
heat-capacity: Cp_IG
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
# add thermodb rule
|
|
180
|
+
thermodb_config_file = os.path.join(os.getcwd(), 'test', 'thermodb_config.yml')
|
|
181
|
+
|
|
182
|
+
# all components
|
|
183
|
+
res_ = thub1.config_thermodb_rule(thermodb_config_file)
|
|
184
|
+
# selected components
|
|
185
|
+
#res_ = thub1.config_thermodb_rule(thermodb_config_file, names=["MeOH", "CO2"])
|
|
186
|
+
print(res_)
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### 🔧 **Add/Update ThermoDB Rule**
|
|
190
|
+
|
|
191
|
+
This section demonstrates how to add or update a ThermoDB rule for a specific chemical compound (e.g., CO2). The rule includes critical data properties and equations related to the compound, which are then added to the ThermoDB using the `add_thermodb_rule` method.
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
# update thermodb rule
|
|
195
|
+
thermodb_rule_CO2 = {
|
|
196
|
+
'DATA': {
|
|
197
|
+
'Pc': 'Pc1',
|
|
198
|
+
'Tc': 'Tc1',
|
|
199
|
+
'AcFa': 'AcFa1'
|
|
200
|
+
},
|
|
201
|
+
'EQUATIONS': {
|
|
202
|
+
'vapor-pressure': 'VaPr1',
|
|
203
|
+
'heat-capacity': 'Cp_IG1'
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
# add thermodb rule for CO2
|
|
208
|
+
thub1.add_thermodb_rule('CO2', thermodb_rule_CO2)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### 🗑️ **Delete ThermoDB Rule**
|
|
212
|
+
|
|
213
|
+
This section demonstrates how to delete a specific ThermoDB rule using the `delete_thermodb_rule` method. In this example, the rule associated with 'CO2' is being removed.
|
|
214
|
+
|
|
215
|
+
```python
|
|
216
|
+
# delete thermodb rule for CO2
|
|
217
|
+
thub1.delete_thermodb_rule('CO2')
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### 🔨 **Build ThermoDB Hub**
|
|
221
|
+
|
|
222
|
+
This section demonstrates the process of building data sources and equation sources using the `build` method, and then prints the resulting objects. Additionally, it showcases accessing and printing the `hub` attribute.
|
|
223
|
+
|
|
224
|
+
```python
|
|
225
|
+
# build
|
|
226
|
+
datasource, equationsource = thub1.build()
|
|
227
|
+
print(datasource)
|
|
228
|
+
print(equationsource)
|
|
229
|
+
|
|
230
|
+
# hub
|
|
231
|
+
print(thub1.hub)
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### 📊 **Retrieve Data/Equation**
|
|
235
|
+
|
|
236
|
+
This section demonstrates how to access various thermodynamic data and equations from the built ThermoDB hub. Examples include retrieving critical properties (Pc, Tc) for different components, NRTL interaction parameters, and calculating values using vapor pressure and activity coefficient equations at specified conditions.
|
|
237
|
+
|
|
238
|
+
```python
|
|
239
|
+
# CO2 data
|
|
240
|
+
dt1_ = datasource['CO2']['Pc']
|
|
241
|
+
print(type(dt1_))
|
|
242
|
+
print(dt1_)
|
|
243
|
+
|
|
244
|
+
# MeOH data
|
|
245
|
+
dt2_ = datasource['MeOH']['Tc']
|
|
246
|
+
print(type(dt2_))
|
|
247
|
+
print(dt2_)
|
|
248
|
+
|
|
249
|
+
# NRTL data
|
|
250
|
+
dt3_ = datasource['NRTL']['alpha_i_j']
|
|
251
|
+
print(type(dt3_))
|
|
252
|
+
print(dt3_.ij("Alpha_methanol_ethanol"))
|
|
253
|
+
|
|
254
|
+
# CO2 equation
|
|
255
|
+
eq1_ = equationsource['CO2']['VaPr']
|
|
256
|
+
print(type(eq1_))
|
|
257
|
+
print(eq1_)
|
|
258
|
+
print(eq1_.args)
|
|
259
|
+
print(eq1_.cal(T=298.15))
|
|
260
|
+
|
|
261
|
+
# nrtl equation
|
|
262
|
+
eq2_ = equationsource['NRTL']['tau_i_j']
|
|
263
|
+
print(type(eq2_))
|
|
264
|
+
print(eq2_)
|
|
265
|
+
print(eq2_.args)
|
|
266
|
+
print(eq2_.cal(T=298.15))
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## ❓ **FAQ**
|
|
270
|
+
|
|
271
|
+
For any question, contact me on [LinkedIn](https://www.linkedin.com/in/sina-gilassi/)
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
## 👨💻 **Authors**
|
|
275
|
+
|
|
276
|
+
- [@sinagilassi](https://www.github.com/sinagilassi)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
LICENSE
|
|
2
1
|
README.md
|
|
3
|
-
|
|
2
|
+
pyproject.toml
|
|
4
3
|
PyThermoLinkDB.egg-info/PKG-INFO
|
|
5
4
|
PyThermoLinkDB.egg-info/SOURCES.txt
|
|
6
5
|
PyThermoLinkDB.egg-info/dependency_links.txt
|
|
@@ -8,13 +7,7 @@ PyThermoLinkDB.egg-info/requires.txt
|
|
|
8
7
|
PyThermoLinkDB.egg-info/top_level.txt
|
|
9
8
|
pyThermoLinkDB/__init__.py
|
|
10
9
|
pyThermoLinkDB/app.py
|
|
11
|
-
|
|
12
|
-
pyThermoLinkDB/config/settings.py
|
|
13
|
-
pyThermoLinkDB/data/__init__.py
|
|
14
|
-
pyThermoLinkDB/docs/__init__.py
|
|
15
|
-
pyThermoLinkDB/docs/thermodbhub.py
|
|
16
|
-
pyThermoLinkDB/docs/thermolink.py
|
|
17
|
-
pyThermoLinkDB/docs/utils.py
|
|
10
|
+
test/test-0.py
|
|
18
11
|
test/test-1.py
|
|
19
12
|
test/test-2.py
|
|
20
13
|
test/test-3.py
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "PyThermoLinkDB"
|
|
7
|
+
version = "1.3.4"
|
|
8
|
+
description = "PyThermoLinkDB is a Python package providing a robust and efficient interface between `PyThermoDB` and other applications."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [
|
|
11
|
+
{name = "Sina Gilassi", email = "sina.gilassi@gmail.com"}
|
|
12
|
+
]
|
|
13
|
+
license = {text = "MIT"}
|
|
14
|
+
requires-python = ">=3.10"
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 1 - Planning",
|
|
17
|
+
"Intended Audience :: Education",
|
|
18
|
+
"Programming Language :: Python :: 3.10",
|
|
19
|
+
"Operating System :: Unix",
|
|
20
|
+
"Operating System :: MacOS :: MacOS X",
|
|
21
|
+
"Operating System :: Microsoft :: Windows",
|
|
22
|
+
]
|
|
23
|
+
keywords = ["chemical engineering", "thermodynamics", "PyThermoDB"]
|
|
24
|
+
dependencies = [
|
|
25
|
+
"PyYAML",
|
|
26
|
+
"PyThermoDB"
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://github.com/sinagilassi/PyThermoLinkDB"
|
|
31
|
+
Documentation = "https://pythermolinkdb.readthedocs.io/en/latest/"
|
|
32
|
+
Source = "https://github.com/sinagilassi/PyThermoLinkDB"
|
|
33
|
+
"Issue Tracker" = "https://github.com/sinagilassi/PyThermoLinkDB/issues"
|
|
34
|
+
|
|
35
|
+
[tool.setuptools]
|
|
36
|
+
packages = ["pyThermoLinkDB"]
|
|
37
|
+
include-package-data = true
|
|
38
|
+
|
|
39
|
+
# package data files
|
|
40
|
+
[tool.setuptools.package-data]
|
|
41
|
+
pyThermoLinkDB = ["data/**/*"]
|
|
42
|
+
|
|
43
|
+
[tool.setuptools.exclude-package-data]
|
|
44
|
+
"*" = ["tests", "*.tests", "*.tests.*"]
|