Skip to main content

A NASA-polynomial thermochemistry engine for reaction and equilibrium calculations.

Project description

🚀 PyThermoCalcDB-NASA

PyPI Downloads PyPI Python Version License

NASA-polynomial thermochemistry for species, reactions, and equilibrium calculations.


🧭 Overview

PyThermoCalcDB-NASA is a scientific Python library for evaluating NASA-7 and NASA-9 polynomial thermochemistry for ideal-gas species and reactions. It focuses on reference-state consistency while staying decoupled from how data is stored or sourced.


✨ Key Features

  • NASA-7 and NASA-9 support with automatic temperature-break selection
  • Species properties: Cp(T), H^0(T), S^0(T), G^0(T) on molar or mass basis
  • Reaction properties: Delta H^0(T), Delta S^0(T), Delta G^0(T) plus equilibrium constants K(T)
  • Van't Hoff shortcut helper (Keq_vh_shortcut) using Delta H^0(298 K)
  • Clean separation of data (PyThermoDB/LinkDB) from the calculation engine
  • Returns CustomProp objects with units and metadata; optional timing logs via mode

📦 Installation

pip install pythermocalcdb-nasa

Examples rely on helper packages and the ThermoDB pickles shipped under examples/thermodb:

pip install pythermodb-settings pythermodb pythermolinkdb pyreactlab-core rich

⚡ Quick start

Build a ModelSource from the packaged NASA pickles and evaluate properties:

from pythermodb_settings.models import Component, ComponentThermoDBSource, Temperature
from pyThermoLinkDB import load_and_build_model_source
from pyreactlab_core.models.reaction import Reaction
from pythermocalcdb_nasa import Cp_T, Keq

CO2 = Component(name="carbon dioxide", formula="CO2", state="g")
CO = Component(name="carbon monoxide", formula="CO", state="g")
H2O = Component(name="dihydrogen monoxide", formula="H2O", state="g")
H2 = Component(name="dihydrogen", formula="H2", state="g")
CH4 = Component(name="methane", formula="CH4", state="g")

thermodb_sources = [
    ComponentThermoDBSource(component=CO2, source="examples/thermodb/carbon dioxide-CO2-g-nasa-1.pkl"),
    ComponentThermoDBSource(component=CO, source="examples/thermodb/carbon monoxide-CO-g-nasa-1.pkl"),
    ComponentThermoDBSource(component=H2O, source="examples/thermodb/dihydrogen monoxide-H2O-g-nasa-1.pkl"),
    ComponentThermoDBSource(component=H2, source="examples/thermodb/dihydrogen-H2-g-nasa-1.pkl"),
    ComponentThermoDBSource(component=CH4, source="examples/thermodb/methane-CH4-g-nasa-1.pkl"),
]

model_source = load_and_build_model_source(
    thermodb_sources=thermodb_sources,
    original_equation_label=False,  # normalize NASA labels
)

# Species property
Cp = Cp_T(
    component=CH4,
    temperature=Temperature(value=600.0, unit="K"),
    model_source=model_source,
    mode="log",  # optional timing log
)
print(Cp)

# Reaction equilibrium
reaction = Reaction(
    name="Water-Gas Shift",
    reaction="CO(g) + H2O(g) => CO2(g) + H2(g)",
    components=[CO, H2O, CO2, H2],
)

Keq_T = Keq(
    reaction=reaction,
    temperature=Temperature(value=1000.0, unit="K"),
    model_source=model_source,
)
print(Keq_T)

🧰 Helper functions

Available helpers (all return CustomProp or None):

  • H_T, S_T, G_T, Cp_T - species properties on molar or mass basis
  • dH_rxn_STD, dS_rxn_STD, dG_rxn_STD - reaction properties from stoichiometry
  • Keq, Keq_vh_shortcut - equilibrium constants from Delta G^0(T) or Van't Hoff

📚 Examples

Run from the project root, e.g. python examples/exp-2.py:

  • examples/exp-1.py - build ModelSource objects and inspect NASA segments
  • examples/exp-2.py - evaluate H_T, S_T, G_T, and Cp_T for CO2/CH4
  • examples/exp-3.py - water-gas shift reaction properties and Keq(T)
  • examples/build-thermodb.py - generate ThermoDB pickles from reference data
  • examples/filter_reference-thermodb.py - subset the reference dataset for examples/tests

📖 Documentation

Documentation is available at https://pythermocalcdb-nasa.readthedocs.io/en/latest/.


🤝 Contributing

Contributions are welcome: bug fixes, new calculation routines, expanded examples, unit tests, or documentation improvements.


⚖️ License

This project is distributed under the Apache License, Version 2.0. If you incorporate this work into your own software, please acknowledge Sina Gilassi as the original author (a repository or documentation reference is appreciated).


❓ FAQ

Questions? 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_nasa-0.1.1.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

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

pythermocalcdb_nasa-0.1.1-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file pythermocalcdb_nasa-0.1.1.tar.gz.

File metadata

  • Download URL: pythermocalcdb_nasa-0.1.1.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.3

File hashes

Hashes for pythermocalcdb_nasa-0.1.1.tar.gz
Algorithm Hash digest
SHA256 176bb909b20770548da88f4fb1832edbbb824dbb1b5fa378b5d2ba0e0df1448e
MD5 f6cf8621ab3e8b5544206c5cc82de24d
BLAKE2b-256 47b04f401cdabe83d2c6086e0d31a22da4ff20dd1e5902d2a1020578cdbc5ae6

See more details on using hashes here.

File details

Details for the file pythermocalcdb_nasa-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pythermocalcdb_nasa-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5fa4e79c8f19a1c290ef6b7ea1eedf23b2fa043cb3282cf2d79dcd88848983d9
MD5 2b16d944c24133c4dfcd8590470c0255
BLAKE2b-256 86e08aa2bbad00af288a8515f2afea83ccce1deb32345c5187a48be3e33078e0

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