pyThermoDB 1.11.12__py3-none-any.whl

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.
Files changed (81) hide show
  1. pyThermoDB/__init__.py +21 -0
  2. pyThermoDB/api/__init__.py +1 -0
  3. pyThermoDB/api/manage.py +68 -0
  4. pyThermoDB/app.py +535 -0
  5. pyThermoDB/config/__init__.py +2 -0
  6. pyThermoDB/config/constants.py +8 -0
  7. pyThermoDB/config/reference.yml +1267 -0
  8. pyThermoDB/config/setting.py +6 -0
  9. pyThermoDB/config/symbols.yml +29 -0
  10. pyThermoDB/data/Antoine constants.csv +70 -0
  11. pyThermoDB/data/CO2 hydrogenation - General Data.csv +8 -0
  12. pyThermoDB/data/CO2 hydrogenation - The Molar Heat Capacities of Gases in the Ideal Gas (Zero-Pressure) State.csv +8 -0
  13. pyThermoDB/data/CO2 hydrogenation - Vapor Pressure.csv +8 -0
  14. pyThermoDB/data/Critical constants and acentric factors.csv +74 -0
  15. pyThermoDB/data/Section C Ideal Gas and Liquid Heat Capacities.csv +311 -0
  16. pyThermoDB/data/TABLE 2-141 Critical Constants and Acentric Factors of Inorganic and Organic Compounds.csv +348 -0
  17. pyThermoDB/data/TABLE 2-153 Heat Capacities of Inorganic and Organic Liquids.csv +351 -0
  18. pyThermoDB/data/TABLE 2-155 Heat Capacity at Constant Pressure of Inorganic and Organic Compounds in the Ideal Gas.csv +64 -0
  19. pyThermoDB/data/TABLE 2-179 Enthalpies and Gibbs Energies of Formation, Entropies, and Net Enthalpies of Combustion.csv +348 -0
  20. pyThermoDB/data/TABLE 2-32 Densities of Inorganic and Organic Liquids.csv +349 -0
  21. pyThermoDB/data/TABLE 2-8 Vapor Pressure of Inorganic and Organic Liquids.csv +348 -0
  22. pyThermoDB/data/Table A.1 General data for selected compounds.csv +47 -0
  23. pyThermoDB/data/Table A.2 Vapor pressure correlations for selected compounds.csv +50 -0
  24. pyThermoDB/data/Table A.3 Liquid density correlations for selected compounds.csv +46 -0
  25. pyThermoDB/data/Table A.4 Enthalpy of vaporization correlations for selected compounds.csv +47 -0
  26. pyThermoDB/data/Table A.5 Liquid heat capacity correlations for selected compounds.csv +47 -0
  27. pyThermoDB/data/Table A.II The Molar Heat Capacities of Gases in the Ideal Gas (Zero-Pressure) State.csv +105 -0
  28. pyThermoDB/data/Table A.IV Enthalpies and Gibbs Energies of Formation.csv +130 -0
  29. pyThermoDB/data/Table B.1 Characteristic Properties of Pure Species.csv +92 -0
  30. pyThermoDB/data/Table B.2 Constants for the Antoine Equation for Vapor Pressures of Pure Species.csv +45 -0
  31. pyThermoDB/data/__init__.py +1 -0
  32. pyThermoDB/data/ref.py +10 -0
  33. pyThermoDB/docs/__init__.py +33 -0
  34. pyThermoDB/docs/compbuilder.py +662 -0
  35. pyThermoDB/docs/compexporter.py +177 -0
  36. pyThermoDB/docs/customref.py +644 -0
  37. pyThermoDB/docs/managedata.py +1407 -0
  38. pyThermoDB/docs/tabledata.py +358 -0
  39. pyThermoDB/docs/tableequation.py +964 -0
  40. pyThermoDB/docs/tablematrixdata.py +1105 -0
  41. pyThermoDB/docs/tablematrixequation.py +1091 -0
  42. pyThermoDB/docs/tableref.py +994 -0
  43. pyThermoDB/docs/thermo.py +2350 -0
  44. pyThermoDB/docs/transdata.py +72 -0
  45. pyThermoDB/docs/transmatrixdata.py +62 -0
  46. pyThermoDB/handlers/__init__.py +0 -0
  47. pyThermoDB/handlers/errors.py +32 -0
  48. pyThermoDB/models/__init__.py +9 -0
  49. pyThermoDB/models/ref.py +64 -0
  50. pyThermoDB/references/__init__.py +17 -0
  51. pyThermoDB/references/builder.py +292 -0
  52. pyThermoDB/references/checker.py +1245 -0
  53. pyThermoDB/references/config.py +122 -0
  54. pyThermoDB/references/content.py +138 -0
  55. pyThermoDB/references/databook.py +523 -0
  56. pyThermoDB/references/main.py +75 -0
  57. pyThermoDB/references/reference.py +353 -0
  58. pyThermoDB/references/table.py +391 -0
  59. pyThermoDB/source/__init__.py +0 -0
  60. pyThermoDB/static/css/styles.css +110 -0
  61. pyThermoDB/static/css/styles2.css +111 -0
  62. pyThermoDB/static/img/logo-2.png +0 -0
  63. pyThermoDB/static/js/app.js +413 -0
  64. pyThermoDB/static/js/app2.js +925 -0
  65. pyThermoDB/templates/__init__.py +0 -0
  66. pyThermoDB/templates/index.html +283 -0
  67. pyThermoDB/templates/table_view.html +200 -0
  68. pyThermoDB/ui/__init__.py +2 -0
  69. pyThermoDB/ui/launch.py +117 -0
  70. pyThermoDB/ui/launcher.py +157 -0
  71. pyThermoDB/utils/__init__.py +12 -0
  72. pyThermoDB/utils/convertor.py +163 -0
  73. pyThermoDB/utils/logger.py +27 -0
  74. pyThermoDB/utils/result_generator.py +31 -0
  75. pyThermoDB/utils/utility.py +26 -0
  76. pyThermoDB/utils/validators.py +20 -0
  77. pythermodb-1.11.12.dist-info/METADATA +424 -0
  78. pythermodb-1.11.12.dist-info/RECORD +81 -0
  79. pythermodb-1.11.12.dist-info/WHEEL +5 -0
  80. pythermodb-1.11.12.dist-info/licenses/LICENSE +21 -0
  81. pythermodb-1.11.12.dist-info/top_level.txt +1 -0
pyThermoDB/__init__.py ADDED
@@ -0,0 +1,21 @@
1
+ from .config import __version__, __author__, __description__
2
+ from .docs import (
3
+ ThermoDB, CompBuilder,
4
+ TableData, TableEquation,
5
+ TableMatrixData, TableMatrixEquation,
6
+ ManageData, CustomRef
7
+ )
8
+ from .app import (
9
+ init, ref, build_thermodb, load_thermodb,
10
+ build_component_thermodb, build_components_thermodb
11
+ )
12
+
13
+ __all__ = [
14
+ '__version__', '__author__', '__description__',
15
+ 'ThermoDB', 'CompBuilder',
16
+ 'TableData', 'TableEquation',
17
+ 'TableMatrixData', 'TableMatrixEquation',
18
+ 'init', 'ref', 'build_thermodb', 'load_thermodb',
19
+ 'build_component_thermodb', 'build_components_thermodb',
20
+ 'ManageData', 'CustomRef',
21
+ ]
@@ -0,0 +1 @@
1
+ from .manage import Manage
@@ -0,0 +1,68 @@
1
+ # import packages/modules
2
+ # externals
3
+ import requests
4
+ # internal
5
+
6
+
7
+ class Manage:
8
+ def __init__(self, api_url, databook_id, table_id):
9
+ self.api_url = api_url
10
+ self.databook_id = databook_id
11
+ self.table_id = table_id
12
+
13
+ def component_list(self) -> list:
14
+ # parameters
15
+ reqtype = 'read'
16
+ id = str(self.databook_id).strip()
17
+ fid = str(self.table_id).strip()
18
+ parameters = f"?reqtype={reqtype}&id={id}&fid={fid}"
19
+ # all data
20
+ get_all = self.api_url + parameters
21
+ response = requests.get(get_all)
22
+
23
+ if response.status_code == 200:
24
+ payload = response.json()
25
+ data = payload['records']
26
+ # header
27
+ header = data[0]
28
+ # records
29
+ records = data[1:]
30
+ # find the index
31
+ for i, item in enumerate(header):
32
+ if item.lower() == "name":
33
+ name_id = int(i)
34
+ # component names
35
+ component_names = [record[name_id] for record in records]
36
+ return component_names
37
+ else:
38
+ print("error", response.status_code)
39
+ return []
40
+
41
+ def component_info(self, component_name: str, search_col_name="Name"):
42
+ '''
43
+ get component info
44
+ '''
45
+ # parameters
46
+ reqtype = 'search'
47
+ id = str(self.databook_id).strip()
48
+ fid = str(self.table_id).strip()
49
+ # query
50
+ query = {
51
+ "reqtype": reqtype,
52
+ "id": id,
53
+ "fid": fid,
54
+ "search_col_name": search_col_name,
55
+ "name": component_name
56
+ }
57
+
58
+ # post
59
+ response = requests.post(self.api_url, json=query, headers={
60
+ "Content-Type": "application/json"})
61
+
62
+ if response.status_code == 200:
63
+ payload = response.json()
64
+ data = payload
65
+ return data
66
+ else:
67
+ print("error", response.status_code)
68
+ return []
pyThermoDB/app.py ADDED
@@ -0,0 +1,535 @@
1
+ # import packages/modules
2
+ import logging
3
+ from typing import (
4
+ Optional,
5
+ Dict,
6
+ List,
7
+ Union,
8
+ Any
9
+ )
10
+ # internal
11
+ from .docs import (
12
+ ThermoDB,
13
+ TableReference,
14
+ CustomRef,
15
+ CompBuilder,
16
+ )
17
+ from .references import ReferenceConfig
18
+
19
+
20
+ def init(
21
+ custom_reference: Optional[
22
+ Dict[str, List[str | Dict[str, Any]]]
23
+ ] = None
24
+ ) -> ThermoDB:
25
+ '''
26
+ Initialize thermodb app to check and build thermodynamic data and equations.
27
+
28
+ Parameters
29
+ ----------
30
+ custom_reference : dict | None, optional
31
+ set-up external reference (custom reference) dict for databook and tables (check examples)
32
+
33
+ Returns
34
+ -------
35
+ ThermoDB : object
36
+ ThermoDB object used for checking and building data and equation objects
37
+
38
+ Notes
39
+ ------
40
+ ### Set-up external reference dict for databook and tables
41
+
42
+ - `format ref_external = {'yml':[yml files], 'csv':[csv files]}`
43
+ - `format ref_external = {'reference':[yml files], 'tables':[csv files]}`
44
+
45
+ ### Examples
46
+
47
+ ```python
48
+ # custom ref
49
+ custom_reference = {
50
+ 'reference': [yml_path],
51
+ 'tables': [csv_path_1, csv_path_2]
52
+ }
53
+
54
+ # init app
55
+ tdb = ptdb.init(custom_reference=custom_reference)
56
+ ```
57
+ '''
58
+ try:
59
+ # check new custom ref
60
+ check_ref = False
61
+ if custom_reference:
62
+ CustomRefC = CustomRef(custom_reference)
63
+ # check ref
64
+ check_ref = CustomRefC.init_ref()
65
+
66
+ # check
67
+ if check_ref:
68
+ return ThermoDB(CustomRefC)
69
+ else:
70
+ return ThermoDB()
71
+ except Exception as e:
72
+ raise Exception(f"Initializing app failed! {e}")
73
+
74
+
75
+ def ref(
76
+ custom_reference: Optional[Dict[str, List[str]]] = None
77
+ ) -> TableReference:
78
+ '''
79
+ Checking references (custom reference) object including databook and tables to display data
80
+
81
+ Parameters
82
+ ----------
83
+ custom_reference : dict
84
+ set-up external reference dict for databook and tables, format `ref_external = {'yml':[yml files], 'csv':[csv files]}`
85
+
86
+ Returns
87
+ -------
88
+ TableReferenceC : object
89
+ TableReference object used for checking references
90
+
91
+ Notes
92
+ ------
93
+ ### Check external reference dict for databook and tables
94
+
95
+ - `format ref_external = {'yml':[yml files], 'csv':[csv files]}`
96
+ - `format ref_external = {'reference':[yml files], 'tables':[csv files]}`
97
+
98
+ ### Examples
99
+
100
+ ```python
101
+ # custom ref
102
+ custom_reference = {
103
+ 'reference': [yml_path],
104
+ 'tables': [csv_path_1, csv_path_2]
105
+ }
106
+
107
+ # init app
108
+ tdb = ptdb.ref(custom_reference=custom_reference)
109
+ ```
110
+ '''
111
+ try:
112
+ # check new custom ref
113
+ check_ref = False
114
+ if custom_reference:
115
+ CustomRefC = CustomRef(custom_reference)
116
+ # check ref
117
+ check_ref = CustomRefC.init_ref()
118
+
119
+ # check
120
+ if check_ref:
121
+ return TableReference(custom_ref=CustomRefC)
122
+ else:
123
+ # init
124
+ return TableReference()
125
+
126
+ except Exception as e:
127
+ raise Exception(f'Building reference failed! {e}')
128
+
129
+
130
+ def build_thermodb(
131
+ thermodb_name: Optional[str] = None,
132
+ message: Optional[str] = None
133
+ ) -> CompBuilder:
134
+ '''
135
+ Build thermodb object to check and build thermodynamic data and equations
136
+
137
+ Parameters
138
+ ----------
139
+ thermodb_name : str
140
+ name of the thermodb object
141
+ - `thermodb_name` : str, name of the thermodb object
142
+ message : str, optional
143
+ a short description of the thermodb object, by default None
144
+
145
+ Returns
146
+ -------
147
+ CompBuilder : object
148
+ CompBuilder object used for building thermodynamic data and equations
149
+ '''
150
+ try:
151
+ # init class
152
+ return CompBuilder(thermodb_name=thermodb_name, message=message)
153
+ except Exception as e:
154
+ raise Exception("Building thermodb failed!, ", e)
155
+
156
+
157
+ def load_thermodb(thermodb_file: str) -> CompBuilder:
158
+ '''
159
+ Load thermodb object to read thermodynamic data and equations
160
+
161
+ Parameters
162
+ ----------
163
+ thermodb_file : str
164
+ filename path
165
+
166
+ Returns
167
+ -------
168
+ CompBuilder : object
169
+ CompBuilder object used for loading thermodynamic data and equations
170
+ '''
171
+ try:
172
+ # init class
173
+ return CompBuilder.load(thermodb_file)
174
+ except Exception as e:
175
+ raise Exception("Loading thermodb failed!, ", e)
176
+
177
+
178
+ def build_component_thermodb(
179
+ component_name: str,
180
+ reference_config: Union[
181
+ Dict[str, Dict[str, str]],
182
+ str
183
+ ],
184
+ custom_reference: Optional[
185
+ Dict[
186
+ str,
187
+ List[str | Dict[str, Any]]
188
+ ]
189
+ ] = None,
190
+ thermodb_name: Optional[str] = None,
191
+ message: Optional[str] = None
192
+ ):
193
+ '''
194
+ Build component thermodynamic databook (thermodb) including data and equations.
195
+
196
+ Parameters
197
+ ----------
198
+ component_name : str
199
+ Name of the component to build thermodynamic databook for.
200
+ reference_config : Dict[str, Dict[str, Any]] | str
201
+ Dictionary containing properties of the component to be included in the thermodynamic databook.
202
+ thermodb_name : Optional[str], optional
203
+ Name of the thermodynamic databook to be built, by default None
204
+ custom_reference : Optional[Dict[str, List[str | dict]]], optional
205
+ Custom reference dictionary for external references, by default None
206
+ message : Optional[str], optional
207
+ A short description of the component thermodynamic databook, by default None
208
+
209
+ Notes
210
+ -----
211
+ Property dict should contain the following format:
212
+
213
+ ```python
214
+ # Dict[str, Dict[str, str]]
215
+ reference_config = {
216
+ 'heat-capacity': {
217
+ 'databook': 'CUSTOM-REF-1',
218
+ 'table': 'Ideal-Gas-Molar-Heat-Capacity',
219
+ },
220
+ 'vapor-pressure': {
221
+ 'databook': 'CUSTOM-REF-1',
222
+ 'table': 'Vapor-Pressure',
223
+ },
224
+ 'general': {
225
+ 'databook': 'CUSTOM-REF-1',
226
+ 'table': 'General-Data',
227
+ },
228
+ }
229
+ ```
230
+ '''
231
+ try:
232
+ # NOTE: check inputs
233
+ if not isinstance(component_name, str):
234
+ raise TypeError("component_name must be a string")
235
+
236
+ # NOTE: reference_config check
237
+ if not isinstance(reference_config, (dict, str)):
238
+ raise TypeError("property must be a dictionary or a string")
239
+
240
+ # NOTE: check if reference_config is a string
241
+ if isinstance(reference_config, str):
242
+ # ! init ReferenceConfig
243
+ ReferenceConfig_ = ReferenceConfig()
244
+ # convert to dict
245
+ reference_config_ = \
246
+ ReferenceConfig_.set_reference_config(
247
+ reference_config
248
+ )
249
+
250
+ # ! extract component reference config
251
+ reference_config = reference_config_.get(component_name, {})
252
+ # check if reference_config is empty
253
+ if not reference_config:
254
+ raise ValueError(
255
+ f"No reference config found for component '{component_name}' in the provided reference config."
256
+ )
257
+
258
+ # NOTE: check if reference_config is a dict
259
+ if not isinstance(reference_config, dict):
260
+ raise TypeError("reference_config must be a dictionary")
261
+
262
+ # SECTION: build thermodb
263
+ thermodb = init(
264
+ custom_reference=custom_reference
265
+ )
266
+
267
+ # init res
268
+ res = {}
269
+
270
+ # NOTE: databook list
271
+ databook_list = thermodb.list_databooks(res_format='list')
272
+ if not isinstance(databook_list, list):
273
+ raise TypeError("Databook list must be a list")
274
+
275
+ # SECTION: check both databook and table
276
+ for prop_name, prop_idx in reference_config.items():
277
+ # property name
278
+ prop_name = prop_name.strip()
279
+
280
+ # ! databook
281
+ databook_ = prop_idx.get('databook', None)
282
+ if databook_ is None:
283
+ raise ValueError(
284
+ f"Databook for property '{prop_name}' is not specified.")
285
+ if databook_ not in databook_list:
286
+ raise ValueError(
287
+ f"Databook '{databook_}' for property '{prop_name}' is not found in the databook list.")
288
+
289
+ # NOTE: tables
290
+ table_dict_ = thermodb.list_tables(
291
+ databook=databook_,
292
+ res_format='dict'
293
+ )
294
+ # check
295
+ if not isinstance(table_dict_, dict):
296
+ raise TypeError("Table list must be a list")
297
+
298
+ # ! table list
299
+ table_list_ = list(table_dict_.values())
300
+ if not isinstance(table_list_, list) or not table_list_:
301
+ raise TypeError("Table list must be a list")
302
+
303
+ # ! table
304
+ table_ = prop_idx.get('table', None)
305
+ if table_ is None:
306
+ raise ValueError(
307
+ f"Table for property '{prop_name}' is not specified.")
308
+
309
+ # check table
310
+ if table_ not in table_list_:
311
+ logging.error(
312
+ f"Table '{table_}' for property '{prop_name}' is not found in the databook '{databook_}'."
313
+ )
314
+ # ? skip if table is not found
315
+ continue
316
+
317
+ # NOTE: check component
318
+ component_checker_ = thermodb.check_component(
319
+ component_name=component_name,
320
+ databook=databook_,
321
+ table=table_,
322
+ res_format='dict'
323
+ )
324
+
325
+ # check
326
+ if not isinstance(component_checker_, dict):
327
+ raise TypeError("Component checker must be a dictionary")
328
+
329
+ if not component_checker_['availability']:
330
+ continue # skip if component is not available in the table
331
+
332
+ # NOTE: build thermodb items
333
+ item_ = thermodb.build_thermo_property(
334
+ [component_name],
335
+ databook_,
336
+ table_,
337
+ )
338
+
339
+ # save
340
+ res[prop_name] = item_
341
+
342
+ # SECTION: build component thermodb
343
+ # NOTE: check thermodb_name
344
+ if thermodb_name is None:
345
+ thermodb_name = component_name
346
+ # NOTE: check message
347
+ if message is None:
348
+ prop_names_list = ', '.join(list(reference_config.keys()))
349
+ message = f"Thermodb including {prop_names_list} for component: {component_name}"
350
+
351
+ # init thermodb
352
+ thermodb_comp = build_thermodb(
353
+ thermodb_name=thermodb_name,
354
+ message=message
355
+ )
356
+
357
+ # add items to thermodb
358
+ for prop_name, prop_value in res.items():
359
+ # add item to thermodb
360
+ thermodb_comp.add_data(
361
+ prop_name,
362
+ prop_value
363
+ )
364
+
365
+ # NOTE: build
366
+ thermodb_comp.build()
367
+
368
+ # return
369
+ return thermodb_comp
370
+
371
+ # SECTION: init
372
+ except Exception as e:
373
+ raise Exception(f"Building {component_name} thermodb failed! {e}")
374
+
375
+
376
+ def build_components_thermodb(
377
+ component_names: List[str],
378
+ reference_config: Dict[str, Dict[str, str]],
379
+ thermodb_name: Optional[str] = None,
380
+ custom_reference: Optional[Dict[str, List[str | dict]]] = None,
381
+ message: Optional[str] = None
382
+ ):
383
+ '''
384
+ Build components thermodynamic databook (thermodb) including matrix-data.
385
+
386
+ Parameters
387
+ ----------
388
+ component_names : List[str]
389
+ List of component names (binary system) to build thermodynamic databook for.
390
+ reference_config : Dict[str, Dict[str, Any]]
391
+ Dictionary containing properties of the components to be included in the thermodynamic databook.
392
+ thermodb_name : Optional[str], optional
393
+ Name of the thermodynamic databook to be built, by default None
394
+ custom_reference : Optional[Dict[str, List[str | dict]]], optional
395
+ Custom reference dictionary for external references, by default None
396
+ message : Optional[str], optional
397
+ A short description of the component thermodynamic databook, by default None
398
+
399
+ '''
400
+ try:
401
+ # NOTE: check inputs
402
+ if not isinstance(component_names, list):
403
+ raise TypeError("component_name must be a list")
404
+ if not all(isinstance(c, str) for c in component_names):
405
+ raise TypeError("All component names must be strings")
406
+
407
+ # ? check binary system
408
+ if len(component_names) != 2:
409
+ raise ValueError(
410
+ "Only binary systems are supported, provide exactly two component names.")
411
+
412
+ # reference_config check
413
+ if not isinstance(reference_config, dict):
414
+ raise TypeError("property must be a dictionary")
415
+
416
+ # property names
417
+ property_names = list(reference_config.keys())
418
+
419
+ # SECTION: build thermodb
420
+ thermodb = init(custom_reference=custom_reference)
421
+
422
+ # init res
423
+ res = {}
424
+
425
+ # NOTE: databook list
426
+ databook_list = thermodb.list_databooks(res_format='list')
427
+ if not isinstance(databook_list, list):
428
+ raise TypeError("Databook list must be a list")
429
+
430
+ # check both databook and table
431
+ for prop_name, prop_idx in reference_config.items():
432
+ # property name
433
+ prop_name = prop_name.strip()
434
+
435
+ # ! databook
436
+ databook_ = prop_idx.get('databook', None)
437
+ if databook_ is None:
438
+ raise ValueError(
439
+ f"Databook for property '{prop_name}' is not specified.")
440
+ if databook_ not in databook_list:
441
+ raise ValueError(
442
+ f"Databook '{databook_}' for property '{prop_name}' is not found in the databook list.")
443
+
444
+ # tables
445
+ table_dict_ = thermodb.list_tables(
446
+ databook=databook_, res_format='dict')
447
+ # check
448
+ if not isinstance(table_dict_, dict):
449
+ raise TypeError("Table list must be a list")
450
+ # table list
451
+ table_list_ = list(table_dict_.values())
452
+ if not isinstance(table_list_, list) or not table_list_:
453
+ raise TypeError("Table list must be a list")
454
+
455
+ # ! table
456
+ table_ = prop_idx.get('table', None)
457
+ if table_ is None:
458
+ raise ValueError(
459
+ f"Table for property '{prop_name}' is not specified.")
460
+
461
+ # check table
462
+ if table_ not in table_list_:
463
+ raise ValueError(
464
+ f"Table '{table_}' for property '{prop_name}' is not found in the databook '{databook_}'.")
465
+
466
+ # ! table info
467
+ table_info_ = thermodb.table_info(
468
+ databook=databook_,
469
+ table=table_,
470
+ res_format='dict'
471
+ )
472
+ # check table info
473
+ if not isinstance(table_info_, dict):
474
+ raise TypeError("Table info must be a dictionary")
475
+
476
+ table_data_type = table_info_.get('Type', None)
477
+ # check
478
+ if table_data_type != 'Matrix-Data':
479
+ raise ValueError(
480
+ f"Table '{table_}' for property '{prop_name}' is not a matrix data table.")
481
+
482
+ # NOTE: check component
483
+ component_checker_ = thermodb.check_component(
484
+ component_name=component_names,
485
+ databook=databook_,
486
+ table=table_,
487
+ res_format='dict'
488
+ )
489
+
490
+ # check
491
+ if not isinstance(component_checker_, dict):
492
+ raise TypeError("Component checker must be a dictionary")
493
+
494
+ if not component_checker_['availability']:
495
+ continue # skip if component is not available in the table
496
+
497
+ # NOTE: build thermodb items
498
+ item_ = thermodb.build_thermo_property(
499
+ component_names,
500
+ databook_,
501
+ table_,
502
+ )
503
+
504
+ # save
505
+ res[prop_name] = item_
506
+
507
+ # SECTION: build component thermodb
508
+ # NOTE: check thermodb_name
509
+ if thermodb_name is None:
510
+ thermodb_name = '-'.join(component_names)
511
+ # NOTE: check message
512
+ if message is None:
513
+ prop_names_list = ', '.join(property_names)
514
+ component_names_ = [c.strip() for c in component_names]
515
+ message = f"Thermodb including {prop_names_list} for components: {component_names_}"
516
+
517
+ # init thermodb
518
+ thermodb_comp = build_thermodb(
519
+ thermodb_name=thermodb_name,
520
+ message=message
521
+ )
522
+
523
+ # add items to thermodb
524
+ for prop_name, prop_value in res.items():
525
+ # add item to thermodb
526
+ thermodb_comp.add_data(
527
+ prop_name, prop_value
528
+ )
529
+
530
+ # NOTE: build
531
+ thermodb_comp.build()
532
+ # return
533
+ return thermodb_comp
534
+ except Exception as e:
535
+ raise Exception(f"Building {component_names} thermodb failed! {e}")
@@ -0,0 +1,2 @@
1
+ from .constants import __version__, __author__, __description__, __email__
2
+ from .setting import API_URL
@@ -0,0 +1,8 @@
1
+ # pyThermoDB version
2
+ __version__ = "1.11.12"
3
+ # author
4
+ __author__ = "Sina Gilassi"
5
+ # email
6
+ __email__ = "sina.gilassi@gmail.com"
7
+ # description
8
+ __description__ = "PyThermoDB is a lightweight and user-friendly Python package designed to provide quick access to essential thermodynamic data."