Skip to main content

Python Thermodynamic Calculation Engine powered by PyThermoDB.

Project description

PyThermoCalcDB

PyPI Downloads PyPI Python Version License Download on the App Store

PyThermoCalcDB — Python Thermodynamic Calculation Engine powered by PyThermoDB

PyThermoCalcDB is a companion package to PyThermoDB, designed to provide a robust set of thermodynamic calculations, utilities, and workflows — using thermodynamic properties, constants, and equations built with PyThermoDB.

Calculations can also be done on your mobile with the MoziThermoCalc iOS app: Download on the App Store.

🚀 Why PyThermoCalcDB?

  • Seamless integration with PyThermoDB: use the database of thermodynamic data (pure component properties, correlations, etc.) as the foundation.
  • Reusable calculation tools: functions for various calculations.
  • Consistent with your thermodynamic ecosystem: fits with existing packages like PyThermoModels, PyPhaseEQ, PyThermoFlash — offering a central “calculation engine” layer.
  • Minimal dependencies: lean design, using PyThermoDB as core data source; optionally depend on well-known numerical libraries (e.g. NumPy, SciPy) if needed for complex calculations.
  • Flexible use-cases: from quick property lookups to advanced process calculations, or integration in larger workflows or multi-agent systems.

📦 Installation

pip install pyThermoCalcDB

🚀 Usage

PyThermoCalcDB provides high-level thermodynamic routines built on PyThermoDB. It is optimized for scripts, notebooks, and pipelines ? the examples/ directory contains runnable workflows.

1) Build a ModelSource

  • Collect ThermoDB pickle paths for your components and load them with pyThermoLinkDB.load_and_build_model_source.
import os
import pyThermoLinkDB as ptdblink
from pythermodb_settings.models import Component, ComponentRule, ComponentThermoDBSource, Temperature, Pressure

CO2 = Component(name="carbon dioxide", formula="CO2", state="g")
thermodb_dir = "/path/to/thermodb"
CO2_src = ComponentThermoDBSource(
    component=CO2,
    source=os.path.join(thermodb_dir, "carbon dioxide-g.pkl"),
)

model_source = ptdblink.load_and_build_model_source(
    thermodb_sources=[CO2_src],
    original_equation_label=False
)

2) Call helper modules

  • Thermodynamic properties (pyThermoCalcDB.docs.thermo): calc_En, calc_GiFrEn, calc_En_range, calc_GiFrEn_range, calc_dEn (Delta H between temperatures), calc_dEnt (Delta S with pressures and phase), calc_En_mix (mixture enthalpy with optional departure/excess terms and output_unit).
  • Saturation & phase change (pyThermoCalcDB.docs.sat): calc_VaPr, calc_VaPr_range, calc_EnVap, calc_EnVap_range, calc_T_sat, calc_VaPr_sensitivity, calc_VaPr_sensitivity_range.
  • Reactions (pyThermoCalcDB.reactions.reactions): dEn_rxn_STD and dGiFrEn_rxn_STD for standard reaction energetics.

Example:

from pyThermoCalcDB.docs import thermo, sat
from pythermodb_settings.models import Temperature, Pressure

T = Temperature(value=300.0, unit="K")
P = Pressure(value=1.5e6, unit="Pa")

enthalpy = thermo.calc_En(component=CO2, model_source=model_source, temperature=T)
gibbs = thermo.calc_GiFrEn(component=CO2, model_source=model_source, temperature=T, phase="IG")
VaPr = sat.calc_VaPr(component=CO2, model_source=model_source, temperature=T)
Tsat = sat.calc_T_sat(
    component=CO2,
    model_source=model_source,
    pressure=P,
    temperature_guess=T,
    method="least_squares",
)

Notes:

  • All helpers expect typed Component, Temperature, and Pressure inputs plus a model_source from PyThermoLinkDB.
  • The optional mode kwarg accepts silent, log, or attach to control logging and timing.

🤝 Contributing

Contributions are highly welcome — bug fixes, new calculation routines, mixture models, extended unit tests, documentation, etc.

📝 License

This project is distributed under the Apache License, Version 2.0, which grants you broad freedom to use, modify, and integrate the software into your own applications or projects, provided that you comply with the conditions outlined in the license. Although Apache 2.0 does not require users to retain explicit author credit beyond standard copyright and license notices, I kindly request that if you incorporate this work into your own software, you acknowledge Sina Gilassi as the original author. Referencing the original repository or documentation is appreciated, as it helps recognize the effort invested in developing and maintaining this project.

❓ 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

pythermocalcdb-0.7.9.tar.gz (59.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pythermocalcdb-0.7.9-py3-none-any.whl (75.2 kB view details)

Uploaded Python 3

File details

Details for the file pythermocalcdb-0.7.9.tar.gz.

File metadata

  • Download URL: pythermocalcdb-0.7.9.tar.gz
  • Upload date:
  • Size: 59.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.8

File hashes

Hashes for pythermocalcdb-0.7.9.tar.gz
Algorithm Hash digest
SHA256 34ea3eabcdae5b50e14c5a36c404d2c34b18cd1892a07d06346d2cff127a55d3
MD5 bd58fdf24ca942c495067bd1a8328610
BLAKE2b-256 c0768eda9f693f37a60d9a876f1770deb2fd0685e21849b8492978c7c3ca16c3

See more details on using hashes here.

File details

Details for the file pythermocalcdb-0.7.9-py3-none-any.whl.

File metadata

File hashes

Hashes for pythermocalcdb-0.7.9-py3-none-any.whl
Algorithm Hash digest
SHA256 994c362b43afb9d2aba821368da8758df439aefdfb8b26a0fe563916b3709922
MD5 2490c1a5e70c9e6f1bbe0f3449f082c1
BLAKE2b-256 bbffc967b4ad3491e85e88e02c5aa06a9df6ba4947554b48110030a008ad0815

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page