PyThermoDB


NamePyThermoDB JSON
Version 1.5.0 PyPI version JSON
download
home_pageNone
SummaryPyThermoDB is a lightweight and user-friendly Python package designed to provide quick access to essential thermodynamic data.
upload_time2024-09-22 18:04:34
maintainerNone
docs_urlNone
authorSina Gilassi
requires_python>=3.6
licenseMIT
keywords python chemical engineering thermodynamics pythermodb
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# PyThermoDB



![Downloads](https://img.shields.io/pypi/dm/PyThermoDB) ![PyPI](https://img.shields.io/pypi/v/PyThermoDB) ![Python Version](https://img.shields.io/pypi/pyversions/PyThermoDB.svg) ![License](https://img.shields.io/pypi/l/PyThermoDB) ![Read the Docs](https://img.shields.io/readthedocs/pythermodb)



Python Thermodynamics Databook



PyThermoDB is a lightweight and user-friendly Python package designed to provide quick access to essential thermodynamic data. Whether you're a student, researcher, or engineer, this package serves as a valuable resource for retrieving thermodynamic properties, equations, and constants from your `custom thermodynamic database` (csv files).



Key Features:



- **Handbook Data**: The package sources its data from well-established thermodynamics handbooks, ensuring accuracy and reliability (*updated regularly*).

- **Custom Thermodynamic Database**: It is possible to builtin your own thermodynamic databook for your project.

- **Minimal Dependencies**: Built with simplicity in mind, the package has minimal external dependencies, making it easy to integrate into your projects.

- **Open Source**: Feel free to explore, contribute, and customize the package according to your needs.



## Google Colab



You can use the following code to run `PyThermoDB` in Google Colab:



[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1jWkaSJ280AZFn9t8X7_bqz_pYtY2QKbr?usp=sharing)





## Installation



Install PyThermoDB with pip



```python

import pyThermoDB as ptdb

# check version

print(ptdb.__version__)

```



## Usage Example



* databook reference initialization:



```python

# databook reference initialization

tdb = ptdb.init()

```



* DATABOOK LIST:



```python

# databook

db_list = tdb.list_databooks()

print(db_list)

```



* TABLE LIST:



```python

# table list

tb_lists = tdb.list_tables(1)

print(tb_lists)

```



* TABLE INFO:



```python

# display a table

tb_info = tdb.table_info(1, 2)

print(tb_info)

```



* LOAD TABLES (before building):



```python

# load equation to check

vapor_pressure_tb = tdb.equation_load(1, 4)

pp(vapor_pressure_tb.eq_structure(1))

# load data to check

data_table = tdb.data_load(1, 2)

pp(data_table.data_structure())

```



* CHECK COMPONENT AVAILABILITY IN A TABLE:



```python

# check component availability in the databook and table

comp1 = "carbon Dioxide"

# CO2_check_availability = tdb.check_component(comp1, 1, 2)



# load comp data

# comp_data = tdb.get_component_data(comp1, 1, 2, dataframe=True)

# pp(comp_data)

```



* BUILD DATA OBJECT:



```python

# build data

CO2_data = tdb.build_data(comp1, 1, 2)

pp(CO2_data.data_structure())

pp(CO2_data.get_property(4))

```



* BUILD EQUATION OBJECT:



```python

# build an equation

eq = tdb.build_equation(comp1, 1, 4)

pp(eq.args)

res = eq.cal(T=298.15)

pp(res*1e-5)

```



### Build ThermoDB for Components



DataTable & EquationTable saved as an object in `Carbon Dioxide.pkl`



* BUILD THERMODB:



```python

# build a thermodb

thermo_db = ptdb.build_thermodb()

pp(type(thermo_db))



# * add TableData

thermo_db.add_data('general', comp1_data)

# * add TableEquation

thermo_db.add_data('heat-capacity', comp1_eq)

thermo_db.add_data('vapor-pressure', vapor_pressure_eq)

# add string

# thermo_db.add_data('dHf', {'dHf_IG': 152})

# file name

# thermodb_file_path = os.path.join(os.getcwd(), f'{comp1}')

# save

thermo_db.save(

    f'{comp1}', file_path='E:\\Python Projects\\pyThermoDB\\tests')

```



* CHECK THERMODB:



```python

# check all properties and functions registered

pp(thermo_db.check_properties())

pp(thermo_db.check_functions())

```



### Load a ThermoDB



`Carbon Dioxide.pkl` can be loaded as:



* LOAD THERMODB



```python

# ref

thermodb_file = 'Carbon Dioxide.pkl'

thermodb_path = os.path.join(os.getcwd(), thermodb_file)

pp(thermodb_path)

```



* LOAD THERMODB



```python

# load thermodb

CO2_thermodb = ptdb.load_thermodb(thermodb_path)

pp(type(CO2_thermodb))

```



* CHECK THERMODB



```python

# check all properties and functions registered

pp(CO2_thermodb.check())

```



### Custom Integral



* Step 1:



Modify `yml file` by adding `CUSTOM-INTEGRAL`.



* Step 2:



Add a name for the new integral body.



* Step 3:



Add a list containing the integral body.



```yml

CUSTOM-INTEGRAL:

    Cp/R:

        - A1 = parms['a0']*args['T1']

        - B1 = (parms['a1']/2)*(args['T1']**2)

        - C1 = (parms['a2']/3)*(args['T1']**3)

        - D1 = (parms['a3']/4)*(args['T1']**4)

        - E1 = (parms['a4']/5)*(args['T1']**5)

        - res1 =  A1 + B1 + C1 + D1 + E1

        - A2 = parms['a0']*args['T2']

        - B2 = (parms['a1']/2)*(args['T2']**2)

        - C2 = (parms['a2']/3)*(args['T2']**3)

        - D2 = (parms['a3']/4)*(args['T2']**4)

        - E2 = (parms['a4']/5)*(args['T2']**5)

        - res2 =  A2 + B2 + C2 + D2 + E2

        - res = res2 - res1

```



* CHECK AS:



```python

# check custom integral

pp(comp1_eq.custom_integral)

# check body

pp(comp1_eq.check_custom_integral_equation_body('Cp/R'))



# Cp/R

Cp_cal_custom_integral_Cp__R = comp1_eq.cal_custom_integral(

    'Cp/R', T1=298.15, T2=320)

pp(Cp_cal_custom_integral_Cp__R)

```



## FAQ



For any question, contact me on [LinkedIn](https://www.linkedin.com/in/sina-gilassi/) 





## Authors



- [@sinagilassi](https://www.github.com/sinagilassi)


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "PyThermoDB",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "python, chemical engineering, thermodynamics, PyThermoDB",
    "author": "Sina Gilassi",
    "author_email": "<sina.gilassi@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/4f/57/0e0c899e9c5ab8d839da9cd0c1c0efc342653a1f118e3941830c9052afea/pythermodb-1.5.0.tar.gz",
    "platform": null,
    "description": "\r\n# PyThermoDB\r\n\r\n\r\n\r\n![Downloads](https://img.shields.io/pypi/dm/PyThermoDB) ![PyPI](https://img.shields.io/pypi/v/PyThermoDB) ![Python Version](https://img.shields.io/pypi/pyversions/PyThermoDB.svg) ![License](https://img.shields.io/pypi/l/PyThermoDB) ![Read the Docs](https://img.shields.io/readthedocs/pythermodb)\r\n\r\n\r\n\r\nPython Thermodynamics Databook\r\n\r\n\r\n\r\nPyThermoDB is a lightweight and user-friendly Python package designed to provide quick access to essential thermodynamic data. Whether you're a student, researcher, or engineer, this package serves as a valuable resource for retrieving thermodynamic properties, equations, and constants from your `custom thermodynamic database` (csv files).\r\n\r\n\r\n\r\nKey Features:\r\n\r\n\r\n\r\n- **Handbook Data**: The package sources its data from well-established thermodynamics handbooks, ensuring accuracy and reliability (*updated regularly*).\r\n\r\n- **Custom Thermodynamic Database**: It is possible to builtin your own thermodynamic databook for your project.\r\n\r\n- **Minimal Dependencies**: Built with simplicity in mind, the package has minimal external dependencies, making it easy to integrate into your projects.\r\n\r\n- **Open Source**: Feel free to explore, contribute, and customize the package according to your needs.\r\n\r\n\r\n\r\n## Google Colab\r\n\r\n\r\n\r\nYou can use the following code to run `PyThermoDB` in Google Colab:\r\n\r\n\r\n\r\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1jWkaSJ280AZFn9t8X7_bqz_pYtY2QKbr?usp=sharing)\r\n\r\n\r\n\r\n\r\n\r\n## Installation\r\n\r\n\r\n\r\nInstall PyThermoDB with pip\r\n\r\n\r\n\r\n```python\r\n\r\nimport pyThermoDB as ptdb\r\n\r\n# check version\r\n\r\nprint(ptdb.__version__)\r\n\r\n```\r\n\r\n\r\n\r\n## Usage Example\r\n\r\n\r\n\r\n* databook reference initialization:\r\n\r\n\r\n\r\n```python\r\n\r\n# databook reference initialization\r\n\r\ntdb = ptdb.init()\r\n\r\n```\r\n\r\n\r\n\r\n* DATABOOK LIST:\r\n\r\n\r\n\r\n```python\r\n\r\n# databook\r\n\r\ndb_list = tdb.list_databooks()\r\n\r\nprint(db_list)\r\n\r\n```\r\n\r\n\r\n\r\n* TABLE LIST:\r\n\r\n\r\n\r\n```python\r\n\r\n# table list\r\n\r\ntb_lists = tdb.list_tables(1)\r\n\r\nprint(tb_lists)\r\n\r\n```\r\n\r\n\r\n\r\n* TABLE INFO:\r\n\r\n\r\n\r\n```python\r\n\r\n# display a table\r\n\r\ntb_info = tdb.table_info(1, 2)\r\n\r\nprint(tb_info)\r\n\r\n```\r\n\r\n\r\n\r\n* LOAD TABLES (before building):\r\n\r\n\r\n\r\n```python\r\n\r\n# load equation to check\r\n\r\nvapor_pressure_tb = tdb.equation_load(1, 4)\r\n\r\npp(vapor_pressure_tb.eq_structure(1))\r\n\r\n# load data to check\r\n\r\ndata_table = tdb.data_load(1, 2)\r\n\r\npp(data_table.data_structure())\r\n\r\n```\r\n\r\n\r\n\r\n* CHECK COMPONENT AVAILABILITY IN A TABLE:\r\n\r\n\r\n\r\n```python\r\n\r\n# check component availability in the databook and table\r\n\r\ncomp1 = \"carbon Dioxide\"\r\n\r\n# CO2_check_availability = tdb.check_component(comp1, 1, 2)\r\n\r\n\r\n\r\n# load comp data\r\n\r\n# comp_data = tdb.get_component_data(comp1, 1, 2, dataframe=True)\r\n\r\n# pp(comp_data)\r\n\r\n```\r\n\r\n\r\n\r\n* BUILD DATA OBJECT:\r\n\r\n\r\n\r\n```python\r\n\r\n# build data\r\n\r\nCO2_data = tdb.build_data(comp1, 1, 2)\r\n\r\npp(CO2_data.data_structure())\r\n\r\npp(CO2_data.get_property(4))\r\n\r\n```\r\n\r\n\r\n\r\n* BUILD EQUATION OBJECT:\r\n\r\n\r\n\r\n```python\r\n\r\n# build an equation\r\n\r\neq = tdb.build_equation(comp1, 1, 4)\r\n\r\npp(eq.args)\r\n\r\nres = eq.cal(T=298.15)\r\n\r\npp(res*1e-5)\r\n\r\n```\r\n\r\n\r\n\r\n### Build ThermoDB for Components\r\n\r\n\r\n\r\nDataTable & EquationTable saved as an object in `Carbon Dioxide.pkl`\r\n\r\n\r\n\r\n* BUILD THERMODB:\r\n\r\n\r\n\r\n```python\r\n\r\n# build a thermodb\r\n\r\nthermo_db = ptdb.build_thermodb()\r\n\r\npp(type(thermo_db))\r\n\r\n\r\n\r\n# * add TableData\r\n\r\nthermo_db.add_data('general', comp1_data)\r\n\r\n# * add TableEquation\r\n\r\nthermo_db.add_data('heat-capacity', comp1_eq)\r\n\r\nthermo_db.add_data('vapor-pressure', vapor_pressure_eq)\r\n\r\n# add string\r\n\r\n# thermo_db.add_data('dHf', {'dHf_IG': 152})\r\n\r\n# file name\r\n\r\n# thermodb_file_path = os.path.join(os.getcwd(), f'{comp1}')\r\n\r\n# save\r\n\r\nthermo_db.save(\r\n\r\n    f'{comp1}', file_path='E:\\\\Python Projects\\\\pyThermoDB\\\\tests')\r\n\r\n```\r\n\r\n\r\n\r\n* CHECK THERMODB:\r\n\r\n\r\n\r\n```python\r\n\r\n# check all properties and functions registered\r\n\r\npp(thermo_db.check_properties())\r\n\r\npp(thermo_db.check_functions())\r\n\r\n```\r\n\r\n\r\n\r\n### Load a ThermoDB\r\n\r\n\r\n\r\n`Carbon Dioxide.pkl` can be loaded as:\r\n\r\n\r\n\r\n* LOAD THERMODB\r\n\r\n\r\n\r\n```python\r\n\r\n# ref\r\n\r\nthermodb_file = 'Carbon Dioxide.pkl'\r\n\r\nthermodb_path = os.path.join(os.getcwd(), thermodb_file)\r\n\r\npp(thermodb_path)\r\n\r\n```\r\n\r\n\r\n\r\n* LOAD THERMODB\r\n\r\n\r\n\r\n```python\r\n\r\n# load thermodb\r\n\r\nCO2_thermodb = ptdb.load_thermodb(thermodb_path)\r\n\r\npp(type(CO2_thermodb))\r\n\r\n```\r\n\r\n\r\n\r\n* CHECK THERMODB\r\n\r\n\r\n\r\n```python\r\n\r\n# check all properties and functions registered\r\n\r\npp(CO2_thermodb.check())\r\n\r\n```\r\n\r\n\r\n\r\n### Custom Integral\r\n\r\n\r\n\r\n* Step 1:\r\n\r\n\r\n\r\nModify `yml file` by adding `CUSTOM-INTEGRAL`.\r\n\r\n\r\n\r\n* Step 2:\r\n\r\n\r\n\r\nAdd a name for the new integral body.\r\n\r\n\r\n\r\n* Step 3:\r\n\r\n\r\n\r\nAdd a list containing the integral body.\r\n\r\n\r\n\r\n```yml\r\n\r\nCUSTOM-INTEGRAL:\r\n\r\n    Cp/R:\r\n\r\n        - A1 = parms['a0']*args['T1']\r\n\r\n        - B1 = (parms['a1']/2)*(args['T1']**2)\r\n\r\n        - C1 = (parms['a2']/3)*(args['T1']**3)\r\n\r\n        - D1 = (parms['a3']/4)*(args['T1']**4)\r\n\r\n        - E1 = (parms['a4']/5)*(args['T1']**5)\r\n\r\n        - res1 =  A1 + B1 + C1 + D1 + E1\r\n\r\n        - A2 = parms['a0']*args['T2']\r\n\r\n        - B2 = (parms['a1']/2)*(args['T2']**2)\r\n\r\n        - C2 = (parms['a2']/3)*(args['T2']**3)\r\n\r\n        - D2 = (parms['a3']/4)*(args['T2']**4)\r\n\r\n        - E2 = (parms['a4']/5)*(args['T2']**5)\r\n\r\n        - res2 =  A2 + B2 + C2 + D2 + E2\r\n\r\n        - res = res2 - res1\r\n\r\n```\r\n\r\n\r\n\r\n* CHECK AS:\r\n\r\n\r\n\r\n```python\r\n\r\n# check custom integral\r\n\r\npp(comp1_eq.custom_integral)\r\n\r\n# check body\r\n\r\npp(comp1_eq.check_custom_integral_equation_body('Cp/R'))\r\n\r\n\r\n\r\n# Cp/R\r\n\r\nCp_cal_custom_integral_Cp__R = comp1_eq.cal_custom_integral(\r\n\r\n    'Cp/R', T1=298.15, T2=320)\r\n\r\npp(Cp_cal_custom_integral_Cp__R)\r\n\r\n```\r\n\r\n\r\n\r\n## FAQ\r\n\r\n\r\n\r\nFor any question, contact me on [LinkedIn](https://www.linkedin.com/in/sina-gilassi/) \r\n\r\n\r\n\r\n\r\n\r\n## Authors\r\n\r\n\r\n\r\n- [@sinagilassi](https://www.github.com/sinagilassi)\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "PyThermoDB is a lightweight and user-friendly Python package designed to provide quick access to essential thermodynamic data.",
    "version": "1.5.0",
    "project_urls": null,
    "split_keywords": [
        "python",
        " chemical engineering",
        " thermodynamics",
        " pythermodb"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0758460a90af091e91a4aeb2ac662bc161ff09f0428775cc193624734e1dc702",
                "md5": "4e9c13c9fd4949ca80fac231ca5c2447",
                "sha256": "c4a09a6d8da85d956c772ca951e971e6cf6c05f2d0837eb40e89dec655300807"
            },
            "downloads": -1,
            "filename": "PyThermoDB-1.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4e9c13c9fd4949ca80fac231ca5c2447",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 91228,
            "upload_time": "2024-09-22T18:04:33",
            "upload_time_iso_8601": "2024-09-22T18:04:33.399871Z",
            "url": "https://files.pythonhosted.org/packages/07/58/460a90af091e91a4aeb2ac662bc161ff09f0428775cc193624734e1dc702/PyThermoDB-1.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4f570e0c899e9c5ab8d839da9cd0c1c0efc342653a1f118e3941830c9052afea",
                "md5": "a6c6377b53678a32de79de29e230302b",
                "sha256": "663dc4e7ada4eaec33a4b7eaef9433845682afa8b8345bc4f8531c1b7e2e1b2c"
            },
            "downloads": -1,
            "filename": "pythermodb-1.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a6c6377b53678a32de79de29e230302b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 80812,
            "upload_time": "2024-09-22T18:04:34",
            "upload_time_iso_8601": "2024-09-22T18:04:34.479047Z",
            "url": "https://files.pythonhosted.org/packages/4f/57/0e0c899e9c5ab8d839da9cd0c1c0efc342653a1f118e3941830c9052afea/pythermodb-1.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-22 18:04:34",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pythermodb"
}
        
Elapsed time: 0.35514s