Skip to main content

🚀 PyThermoCalcDB-NASA

PyPI Downloads PyPI Python Version License Download on the App Store

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.

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


✨ 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)
  • Embedded NASA-9 SQLite database with component availability checks and direct ModelSource building
  • The same thermochemistry calculations can be done on mobile via the MoziThermoCalc app
  • 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 used for model-source and reaction handling:

pip install pythermodb-settings pythermodb pythermolinkdb pyreactlab-core rich

⚡ Quick start

Build a ModelSource from the embedded NASA-9 SQLite database and evaluate properties:

from pythermodb_settings.models import Component, Temperature
from pyreactlab_core.models.reaction import Reaction
from pythermocalcdb_nasa import (
    Cp_T,
    Keq,
    build_model_source_from_database,
    check_component_availability,
)

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")

components = [CH4, CO2, H2O, CO, H2]

availability = check_component_availability(components)
if availability["missing_components"]:
    raise ValueError(f"Missing components: {availability['missing_components']}")

model_source = build_model_source_from_database(
    components=availability["matched_components"],
    temperature=Temperature(value=298.15, unit="K"),
)

# 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)

Build ModelSource From REFERENCE

If you already have NASA reference content, you can still build a ModelSource through PyThermoDB and PyThermoLinkDB. This is the pattern used by examples/model_source/model_source_2.py.

from pyThermoDB import build_component_thermodb_from_reference
from pyThermoLinkDB import build_components_model_source, build_model_source

thermodb_components = []

for comp in components:
    thermodb_component = build_component_thermodb_from_reference(
        component_name=comp.name,
        component_formula=comp.formula,
        component_state=comp.state,
        reference_content=REFERENCE_CONTENT,
        check_labels=False,
    )
    if thermodb_component is None:
        raise ValueError(f"thermodb_component for {comp.name} is None")
    thermodb_components.append(thermodb_component)

component_model_source = build_components_model_source(
    components_thermodb=thermodb_components,
    rules=None,
)

model_source = build_model_source(source=component_model_source)

Use this workflow when you need NASA-7 data or a custom reference source. The embedded SQLite helper currently builds NASA-9 model sources.


Helper functions

Available helpers (all return CustomProp or None):

  • check_component_availability - check whether components exist in the embedded NASA-9 database
  • build_reference_content_from_database - build PyThermoDB-compatible reference content from SQLite rows
  • build_model_source_from_database - build a ready ModelSource from the embedded NASA-9 database
  • 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/exp-4.py - water-gas shift calculations using a reference-built model source
  • examples/exp-6.py - water-gas shift calculations using a SQLite-built model source
  • examples/model_source/model_source_3.py - build a SQLite model source for random gas-phase components
  • examples/model_source/model_source_4.py - build a SQLite model source for specific WGS components
  • 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

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.3.0.tar.gz (354.3 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.3.0-py3-none-any.whl (355.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pythermocalcdb_nasa-0.3.0.tar.gz
Algorithm Hash digest
SHA256 974be9eec2f03c39d3096fee72991551e8e142e0a0b42ae1c703682677ccf189
MD5 e3260a5a516947503a8c702158637bb6
BLAKE2b-256 48ebea503233529b478b56f529fc5030133c155af2c5cfebfdf6978e6da569c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pythermocalcdb_nasa-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ebd383256adf16aefbf6ebc944b5806d072abae4a8f4020dfba440ef6dd67283
MD5 4c61d78085f86bccc75150a7e07e6e66
BLAKE2b-256 e129c80630049200b80b5c8d5cbe48dc8735c2cf6f8e4e9a2d01452073c55b51

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.2.0

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

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