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.0.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.0-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pythermocalcdb_nasa-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 6361a84284f61f17d184be0abfe7aa1981034eddb623a8d28c80cb51f346ffcb
MD5 93d2cc9ba7b3893adfab5775149f1be5
BLAKE2b-256 f94b6ebcdc5488a59322d11a8c2e66a19fed7e596fd38f32490190d9b46e1b4b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pythermocalcdb_nasa-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd31d445a7aab7c2eb95909ee915f5c4df393791a9dd8d56eaf8649710e96c17
MD5 aaccb7694a75011945bcdfca7efa3af0
BLAKE2b-256 8f80aa2c3da71c5470f44d6fca6a2b09cb560854f98f57db1125bff892733eef

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