Builder API
Converts NASA FORTRAN thermo.inp files → SQLite3 database.
FORTRAN Record Structure (Appendix C)
| Record | Content |
|---|---|
| RECORD 1 | Species identification (name, comments) |
| RECORD 2 | General information (numintervals, refcode, phase, MW, ΔH°f) |
| RECORD 3 | Temperature interval definition (Tmin, Tmax, H_298→0) |
| RECORD 4 | First 5 polynomial coefficients (a₁–a₅) |
| RECORD 5 | Last 2 coefficients + integration constants (a₆, a₇, b₁, b₂) |
Records 3–5 repeat for each temperature interval.
Quick Start
using Glenn
# Build from the bundled thermo.inp (shipped with the package)
builder = ThermoDBBuilder(default_inp_path(), "thermo.db")
ThermoBuilder.connect(builder)
ThermoBuilder.create_tables(builder)
ThermoBuilder.parse_and_load(builder)
ThermoBuilder.close(builder)
# Or use a custom thermo.inp
builder = ThermoDBBuilder("my_thermo.inp", "my_thermo.db")
ThermoBuilder.connect(builder)
ThermoBuilder.create_tables(builder)
ThermoBuilder.parse_and_load(builder)
ThermoBuilder.close(builder)API Reference
Glenn.ThermoDBBuilder — Type
ThermoDBBuilderBuilds a SQLite database from a thermo.inp file (NASA FORTRAN format).
Example
builder = ThermoDBBuilder("thermo.inp", "thermo.db")
connect(builder)
create_tables(builder)
parse_and_load(builder)
close(builder)Glenn.ThermoBuilder.connect — Function
connect(builder::ThermoDBBuilder)Connect to (or create) the SQLite database.
Glenn.ThermoBuilder.create_tables — Function
create_tables(builder::ThermoDBBuilder)Create the normalized table structure in the database.
Glenn.ThermoBuilder.parse_and_load — Function
parse_and_load(builder::ThermoDBBuilder)Parse the thermo.inp file and populate the database.
Reads the FORTRAN file line by line, detects record types, extracts species data, temperature intervals, and polynomial coefficients, then inserts everything into the normalized SQLite schema.
Parser Utilities
Glenn.ThermoBuilder.parse_float — Function
parse_float(value::AbstractString) -> Union{Float64, Nothing}Parse a FORTRAN-style float ('D' → 'E' notation). Returns nothing if parsing fails.
Glenn.ThermoBuilder.parse_species_record — Function
parse_species_record(line::AbstractString) -> Tuple{String, String}Extract species name (cols 1-16) and comments (cols 19-80) from RECORD 1.
Returns (species_name, comments).
Glenn.ThermoBuilder.parse_general_info_record — Function
parse_general_info_record(line::AbstractString) -> Dict{String, Any}Parse RECORD 2 – general information.
Returns a Dict with keys: num_intervals, ref_code, phase, molecular_weight, heat_of_formation.
Glenn.ThermoBuilder.parse_temp_interval_record — Function
parse_temp_interval_record(line::AbstractString) -> Dict{String, Any}Parse RECORD 3 – temperature interval.
Returns a Dict with keys: temp_min, temp_max, h_298_to_0.
Glenn.ThermoBuilder.parse_coefficients_record — Function
parse_coefficients_record(lines::Vector{<:AbstractString}) -> Dict{String, Any}Parse RECORDS 4-5 – polynomial coefficients.
Line 4: a₁[1:16], a₂[17:32], a₃[33:48], a₄[49:64], a₅[65:80] Line 5: a₆[1:16], a₇[17:32], (skip 33:48), b₁[49:64], b₂[65:80]
Returns a Dict with keys: a1–a7, b1, b2.
Glenn.ThermoBuilder.is_temperature_line — Function
is_temperature_line(line::AbstractString) -> BoolDetect RECORD 3 (temperature interval).
A temperature line has two valid floats in cols 1-11 and 12-22 where the first is strictly less than the second.
Glenn.ThermoBuilder.is_coefficient_line — Function
is_coefficient_line(line::AbstractString) -> BoolDetect coefficient lines containing FORTRAN D notation.
Uses regex to match the standard FORTRAN double-precision format (e.g. 1.23456789D+01).
Glenn.ThermoBuilder.read_thermo_file — Function
read_thermo_file(inp_file::AbstractString) -> Vector{String}Read thermo.inp, stripping comments (lines starting with '!') and blank lines.