PyThermoDB is a lightweight and user-friendly Python package designed to provide quick access to essential thermodynamic data.
Project description
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:
Installation
Install PyThermoDB with pip
import pyThermoDB as ptdb
# check version
print(ptdb.__version__)
Usage Example
- databook reference initialization:
# ===============================
# databook reference initialization
# ===============================
tdb = ptdb.init()
- list databooks:
# ===============================
# DATABOOK LIST
# ===============================
# databook
db_list = tdb.list_databooks()
print(db_list)
- list tables:
# ===============================
# TABLE LIST
# ===============================
# table list
tb_lists = tdb.list_tables(1)
print(tb_lists)
- Display table info:
# ===============================
# TABLE INFO
# ===============================
# display a table
tb_info = tdb.table_info(1, 2)
print(tb_info)
- Load an equation (before building):
# ===============================
# LOAD TABLES
# ===============================
# 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:
# ====================================
# CHECK COMPONENT AVAILABILITY IN A TABLE
# ====================================
# 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:
# ====================================
# BUILD DATA
# ====================================
# build data
CO2_data = tdb.build_data(comp1, 1, 2)
pp(CO2_data.data_structure())
pp(CO2_data.get_property(4))
- Build an equation object:
# ====================================
# BUILD EQUATION
# ====================================
# 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
# ====================================
# 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
# ====================================
# 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
# ====================================
# ref
thermodb_file = 'Carbon Dioxide.pkl'
thermodb_path = os.path.join(os.getcwd(), thermodb_file)
pp(thermodb_path)
# ====================================
# LOAD THERMODB
# ====================================
# load thermodb
CO2_thermodb = ptdb.load_thermodb(thermodb_path)
pp(type(CO2_thermodb))
# ====================================
# CHECK THERMODB
# ====================================
# check all properties and functions registered
pp(CO2_thermodb.check())
FAQ
For any question, contact me on LinkedIn
Authors
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for PyThermoDB-1.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 712726417c58110762d720823e0ccf1046e555d5fe00e7f95a9219169db7e588 |
|
MD5 | d10a3b1c7d996894471a6048b696d562 |
|
BLAKE2b-256 | 8e51d4c6fbae431cd83ffc294e5798b88355d0f4ea196fa67214b5ba04584559 |