Thermodynamic calculations using NASA7/9 polynomials
npm install mozithermocalcdb-nasasrc/.
DataLoader/loadModelSource script in scripts/ to parse CSVs once into an in-memory ModelSource; invalid or incomplete rows are skipped early via transformRow validation.
Name-State, Formula-State, Name-Formula) so lookups avoid string recomputation in hot paths.
{ path, range } objects to batch all ranges in a single pass.
Source resolves a component's equation set by id and validates required coefficients before returning data.
buildRangePreference) to keep calculations moving when partial data exists.
validateRangeData filters out records with missing or non-finite coefficients to prevent downstream math errors.
HSG lazily extracts and caches NASA7/NASA9 coefficients on construction, avoiding repeated Source lookups per call.
requireCoeffs); failures return null instead of throwing inside the compute path to keep execution cheap.
props) so mass-basis conversions reuse the same value instead of re-reading coefficient blobs.
HSGs builds and caches per-component HSG instances up front and reuses them for all property calculations.
selectNasaType) is shared across the batch in calc_components_hsg, reducing branching inside per-component loops.
RXNAdapter) consume these batch results directly, so reaction properties reuse the already-computed component thermodynamics.
src/thermo are pure functions: they convert to Kelvin once, operate on numbers, and return CustomProp structs with units intact.
toMassBasis) are applied only when explicitly requested via basis: 'mass'; default is molar to avoid extra work.
modelSource, then reuse a single Source/HSG or HSGs instance for repeated queries.
H_T, S_T, G_T, Cp_T for single values.
dH_rxn_STD, dS_rxn_STD, dG_rxn_STD, Keq, Keq_vh_shortcut for multi-component calculations in one pass.
'nasa9' unless you need NASA7 data; NASA9 has fuller validation (b1/b2) and better range coverage in the fallback order.
examples/appUsage.ts end-to-end with npx ts-node --esm --experimental-specifier-resolution=node examples/appUsage.ts to load the bundled NASA9 CSVs and print species/reaction properties.
loadExampleModelSource call inside examples/appUsage.ts to match your files.
ts
import { loadModelSource } from './scripts/DataLoader';
import { H_T, dG_rxn_STD } from './src/app';
const modelSource = await loadModelSource([
{ path: 'data/nasa9_range1.csv', range: 'nasa9_200_1000_K' },
{ path: 'data/nasa9_range2.csv', range: 'nasa9_1000_6000_K' }
]);
const water = { name: 'Water', formula: 'H2O', state: 'g' } as const;
const H = H_T({ component: water, temperature: { value: 900, unit: 'K' }, model_source: modelSource });
const reaction = {
name: 'water-formation-gas',
reaction: '2 H2(g) + O2(g) => 2 H2O(g)',
components: [
{ name: 'Hydrogen', formula: 'H2', state: 'g' },
{ name: 'Oxygen', formula: 'O2', state: 'g' },
water
]
} as const;
const dG = dG_rxn_STD({ reaction, temperature: { value: 900, unit: 'K' }, model_source: modelSource });
``