🚀 PyThermoCalcDB-NASA
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 constantsK(T) - Van't Hoff shortcut helper (
Keq_vh_shortcut) usingDelta H^0(298 K) - Embedded NASA-9 SQLite database with component availability checks and direct
ModelSourcebuilding - The same thermochemistry calculations can be done on mobile via the MoziThermoCalc app
- Clean separation of data (PyThermoDB/LinkDB) from the calculation engine
- Returns
CustomPropobjects with units and metadata; optional timing logs viamode
📦 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 databasebuild_reference_content_from_database- build PyThermoDB-compatible reference content from SQLite rowsbuild_model_source_from_database- build a readyModelSourcefrom the embedded NASA-9 databaseH_T,S_T,G_T,Cp_T- species properties on molar or mass basisdH_rxn_STD,dS_rxn_STD,dG_rxn_STD- reaction properties from stoichiometryKeq,Keq_vh_shortcut- equilibrium constants fromDelta G^0(T)or Van't Hoff
📚 Examples
Run from the project root, e.g. python examples/exp-2.py:
examples/exp-1.py- buildModelSourceobjects and inspect NASA segmentsexamples/exp-2.py- evaluateH_T,S_T,G_T, andCp_Tfor CO2/CH4examples/exp-3.py- water-gas shift reaction properties andKeq(T)examples/exp-4.py- water-gas shift calculations using a reference-built model sourceexamples/exp-6.py- water-gas shift calculations using a SQLite-built model sourceexamples/model_source/model_source_3.py- build a SQLite model source for random gas-phase componentsexamples/model_source/model_source_4.py- build a SQLite model source for specific WGS componentsexamples/build-thermodb.py- generate ThermoDB pickles from reference dataexamples/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
Metadata
Release files for pythermocalcdb-nasa 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pythermocalcdb_nasa-0.3.0.tar.gz | 354.3 kB | Without provenance | Details for pythermocalcdb_nasa-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pythermocalcdb_nasa-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for pythermocalcdb_nasa-0.3.0-py3-none-any.whl |
Total release size: 709.3 kB
Release files / pythermocalcdb_nasa-0.3.0.tar.gz
| Download URL | pythermocalcdb_nasa-0.3.0.tar.gz |
|---|---|
| Size | 354.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
974be9eec2f03c39d3096fee72991551e8e142e0a0b42ae1c703682677ccf189
|
|
BLAKE2b-256 checksum How to use checksums |
48ebea503233529b478b56f529fc5030133c155af2c5cfebfdf6978e6da569c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.8
|
Release files / pythermocalcdb_nasa-0.3.0-py3-none-any.whl
| Download URL | pythermocalcdb_nasa-0.3.0-py3-none-any.whl |
|---|---|
| Size | 355.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ebd383256adf16aefbf6ebc944b5806d072abae4a8f4020dfba440ef6dd67283
|
|
BLAKE2b-256 checksum How to use checksums |
e129c80630049200b80b5c8d5cbe48dc8735c2cf6f8e4e9a2d01452073c55b51
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.8
|
Security for pythermocalcdb-nasa 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.