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.2.tar.gz (20.5 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.2-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pythermocalcdb_nasa-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b0d96d0714700da3e9d38451a5a80907c1fdd230ca2c5f2723198c381b1a7188
MD5 41303dfca23fc01446d980e83f32a347
BLAKE2b-256 edfc2852d3a3cbccbc091696cf1912b3dfa52ae981f5d0b03e07194612c5831d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pythermocalcdb_nasa-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f1f53dacb9ef2a6f694d7d2c12caed59481c308254ee6ab1cfdeba146ba92d44
MD5 8dba1cc1c46f16f1a4ad4e19ee81c79a
BLAKE2b-256 90cb6282db752b27c58bbcd72f9f22c92aedc844c76c29d3318d0cb40a7aad75

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