Metadata-Version: 2.4
Name: pyglenn
Version: 0.1.7rc4
Summary: Thermochemical properties calculator — computes Cp(T), H°(T), S°(T) from NASA polynomial coefficients stored in SQLite
Author-email: "Dr. Reginaldo G. Leão Jr." <prof.reginaldo.leao@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://profleao.github.io/pyglenn
Project-URL: Repository, https://github.com/ProfLeao/pyglenn
Project-URL: Issues, https://github.com/ProfLeao/pyglenn/issues
Keywords: thermochemistry,thermodynamics,NASA-polynomials,heat-capacity,enthalpy,entropy
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Chemistry
Classifier: Topic :: Scientific/Engineering :: Physics
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: ruff>=0.5.0; extra == "dev"
Requires-Dist: mypy>=1.10.0; extra == "dev"
Requires-Dist: pre-commit>=3.7.0; extra == "dev"
Provides-Extra: examples
Requires-Dist: jupyterlab>=4.0; extra == "examples"
Requires-Dist: matplotlib>=3.7; extra == "examples"
Provides-Extra: doc
Requires-Dist: sphinx>=7.0; extra == "doc"
Requires-Dist: renku-sphinx-theme>=0.5.0; extra == "doc"
Requires-Dist: myst-nb>=1.1.0; extra == "doc"
Requires-Dist: matplotlib>=3.7; extra == "doc"
Dynamic: license-file

# pyglenn — Thermochemical Properties Calculator

[![CI](https://github.com/ProfLeao/pyglenn/actions/workflows/ci.yml/badge.svg)](https://github.com/ProfLeao/pyglenn/actions/workflows/ci.yml)
[![Docs](https://github.com/ProfLeao/pyglenn/actions/workflows/docs.yml/badge.svg)](https://profleao.github.io/pyglenn)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)

Computes **Cp(T)**, **H°(T)**, **S°(T)** from NASA polynomial coefficients stored in a SQLite database, converted from FORTRAN `thermo.inp` files.

**Author:** Dr. Reginaldo G. Leão Jr. — [prof.reginaldo.leao@gmail.com](mailto:prof.reginaldo.leao@gmail.com)

📖 **Documentation:** [profleao.github.io/pyglenn](https://profleao.github.io/pyglenn)

## Features

- Parse NASA-format `thermo.inp` (FORTRAN Appendix C) → SQLite3 database
- Query species by name, phase, molecular weight
- Calculate Cp(T), H°(T), S°(T) at any valid temperature
- Enthalpy of formation lookup
- Enthalpy change between two temperatures
- Command-line interface
- ~2030 species, 3772 temperature intervals

## Installation

### From PyPI (pip)

```bash
pip install pyglenn
```

### From source

```bash
git clone https://github.com/ProfLeao/pyglenn.git
cd pyglenn
pip install .
```

### Conda

```bash
conda build conda.recipe/
conda install --use-local pyglenn
```

## Quick Start

The database is **bundled with the package** — no manual build step needed.

### Python API

```python
from pyglenn import ThermochemicalCalculator

# No need to specify a DB file — uses the bundled thermo.db
calc = ThermochemicalCalculator()
calc.connect()

# Find O2
species = calc.get_available_species('O2')
o2 = species[0]

# Calculate properties at 1000 K
props = calc.calculate_properties(o2['id'], 1000.0)
print(f"Cp = {props['cp']:.2f} J/(mol·K)")
print(f"H° = {props['h_relative']:.1f} J/mol")
print(f"S° = {props['s']:.3f} J/(mol·K)")

calc.close()
```

Or use the **context manager** for automatic cleanup:

```python
from pyglenn import ThermochemicalCalculator

with ThermochemicalCalculator() as calc:
    species = calc.get_available_species('CH4')
    props = calc.calculate_properties(species[0]['id'], 500.0)
    print(f"Cp = {props['cp']:.2f} J/(mol·K)")
```

### CLI

```bash
pyglenn query -s O2
```

### Rebuilding the database

Only needed if the database is corrupted or you modify ``thermo.inp`` manually:

```bash
pyglenn build -i thermo.inp -o thermo.db
```

## Database Structure

| Table | Description |
|---|---|
| `species` | Chemical species (name, formula, phase, MW, ΔH°f) |
| `temperature_intervals` | Valid T ranges per species |
| `coefficients` | NASA-7 polynomial coefficients (a1–a7, b1, b2) |
| `file_metadata` | Global file metadata |

## Requirements

- Python ≥ 3.9
- SQLite3 (stdlib)

## License

MIT — see [LICENSE](LICENSE) file.
