API
Calculator
Thermochemical properties calculator.
Computes Cp(T), H°(T), S°(T) from NASA polynomial coefficients stored in a SQLite database.
- All values returned as floats in standard units:
Cp, S° → J/(mol·K) H° → J/mol
- class pyglenn.calculator.ThermochemicalCalculator(db_file=None)[source]
Bases:
objectHigh-level interface for calculating thermochemical properties.
Uses the bundled
thermo.dbby default — no manual build step needed.Supports context-manager protocol for automatic connection management:
with ThermochemicalCalculator() as calc: props = calc.calculate_properties(species_id, 1000.0)
- Parameters:
db_file (str | None)
- connect()[source]
Connect to the database.
- Returns:
True if connection succeeded, False otherwise.
- Return type:
- get_available_species(search_pattern='')[source]
Return a list of available species, optionally filtered by name.
- calculate_properties(species_id, temperature)[source]
Calculate thermochemical properties at a given temperature.
- Parameters:
- Returns:
temperature: Input temperature (K) - cp: Heat capacity in J/(mol·K) - h_relative: Enthalpy relative to 0 K in J/mol - s: Absolute entropy in J/(mol·K) - temp_interval: [T_min, T_max] - species_name: Species name - phase: Phase (‘gas’ or ‘condensed’)
Or None if calculation fails.
- Return type:
Dictionary with keys
- calculate_enthalpy_change(species_id, T1, T2)[source]
Calculate ΔH°(T₂) − ΔH°(T₁) in J/mol.
Uses H°(T) values relative to 0 K.
Database
Database query interface for thermochemical data. Provides SQLite access, species lookup, and NASA polynomial calculations.
- class pyglenn.database.ThermoDBQuery(db_file='thermo.db')[source]
Bases:
objectClass for querying thermochemical database.
- Parameters:
db_file (str)
- connect()[source]
Connect to database.
- Returns:
True if connection succeeded, False otherwise.
- Return type:
- get_species_for_temperature(species_id, temperature)[source]
Get valid coefficients for a specific temperature.
- static calculate_cp(coeffs, temperature)[source]
Calculate Cp(T)/R using NASA-7 polynomial coefficients.
Builder
Database builder: converts thermo.inp (NASA FORTRAN format) → SQLite3.
- FORTRAN Record Structure (Appendix C):
RECORD 1 – Species identification RECORD 2 – General information RECORD 3 – Temperature interval definition RECORD 4 – First 5 polynomial coefficients RECORD 5 – Last 2 coefficients + integration constants
Records 3–5 repeat for each temperature interval.
- class pyglenn.builder.ThermoDBBuilder(inp_file, db_file)[source]
Bases:
objectBuild a SQLite database from a thermo.inp file.
- static parse_species_record(line)[source]
Extract species name (cols 1-16) and comments (cols 19-80).
- static is_temperature_line(line)[source]
Detect RECORD 3 (temperature interval).
A temperature line has two valid floats in cols 0-11 and 11-22 where the first is strictly less than the second.