# Database#

Combustion Toolbox generates its own databases taking into account the NASA-9 polynomials fitting to evaluate the dimensionless thermodynamic functions of the species for the specific heat, enthalpy, and entropy as function of temperature, namely

\begin{eqnarray} c_p^\circ/R &=& a_1T^{-2} + a_2T^{-1} + a_3 + a_4T + a_5T^2 + a_6T^3 + a_7T^4,\\ h^\circ/RT &=& -a_1T^{-2} + a_2T^{-1} \ln{T} + a_3 + a_4T/2 + a_5T^2/3 + a_6T^3/4 \\ &\phantom{{}={}}& + a_7T^4/5 + a_8/T,\\ s^\circ/R &=& -a_1T^{-2}/2 - a_2T^{-1} + a_3\ln{T} + a_4T + a_5T^2/2 + a_6T^3/3 \\ &\phantom{{}={}}& + a_7T^4/4 + a_9, \end{eqnarray}

where $$a_i$$ from $$i=1, \dots, 7$$ are the temperature coefficients and $$i =8, 9$$ are the integration constants, respectively. Depending of the species the polynomials fit up to 20000 K . These values are available in the source code and can be also obtained from NASA’s thermo build website.

To compute the dimensionless Gibbs energy, $$g_i^\circ (T) / RT$$, from NASA’s polynomials we use the next expression

\begin{equation} g_i^\circ/RT = h^\circ/RT - s^\circ/R, \end{equation}

or equivalently

\begin{eqnarray} g_i^\circ/RT &=& -a_1T^{-2}/2 + a_2T^{-1} (1 + \ln{T}) + a_3(1 - \ln{T}) - a_4T/2 - a_5T^2/6 - a_6T^3/12 \\ &\phantom{{}={}}& - a_7T^4/20 + a_8/T - a_9. \end{eqnarray}

This data is collected and formatted into a more accessible structure. We can distinguish from:

• DB_master: structured database from NASA’s thermo file.

• DB: structured database with piecewise cubic Hermite interpolating polynomials and linear extrapolation for faster data access.

The use of piecewise cubic Hermite interpolating polynomials increments the performance of Combustion Toolbox in approximate 200% as shown in Figure 1 obtaining the same results as seen in Figure 2. To evaluate the thermodynamic functions, e.g., the Gibbs energy [kJ/mol] function, or the thermal enthalpy [kJ/mol] of $$\text{CO}_2$$ at $$T = 2000 \text{ K}$$ is as simple as using these callbacks

>> g0_CO2  = species_g0('CO2', 2000, DB)
>> DhT_CO2 = species_DhT('CO2', 2000, DB) Figure 1: Performance test, execution times for over $10^5$ calculations of the specific heat at constant pressure, enthalpy, Gibbs energy, and entropy, denoted as $c_p$, $h_0$, $g_0$, and $s_0$, respectively, using the NASA’s 9 coefficient polynomials (dark blue) and the piecewise cubic Hermite interpolating polynomials (teal). The test has been carried out with an Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz. Note: lower is better. Figure 2: Comparison of entropy [kJ/(mol-K)] as a function of temperature [K] obtained using the piecewise cubic Hermite interpolating polynomials (lines) and using the NASA’s 9 coefficient polynomials (symbols) for a set of species.

Another important parameter comes from the conservation of mass, which is the stoichiometric matrix $$A_0$$, by generalizing this constraint condition we have

\begin{equation} \sum\limits_{j = 1}^{\text{NS}} a_{ij} n_j - b_i^\circ = 0, \end{equation}

or in matricial form

\begin{equation} \underbrace{\left(\begin{array}{c c c c} a_{11} & a_{21} & \cdots & a_{\text{NS}1} \\ a_{12} & a_{22} & \cdots & a_{\text{NS}2} \\ \vdots & \vdots & & \vdots \\ a_{1\text{NE}} & a_{2\text{NE}} & \cdots & a_{\text{NS}\text{NE}} \\ \end{array}\right)}_{\mathbf{A^T}} \underbrace{\left(\begin{matrix} \ce{n_1}\\ \ce{n_2}\\ \ce{\vdots}\\ \ce{n_{\text{NS}}} \end{matrix}\right)}_{\mathbf{N}} - \underbrace{\left(\begin{matrix} \ce{b_1}\\ \ce{b_2}\\ \ce{\vdots}\\ \ce{b_{\text{NE}}} \end{matrix}\right)}_{\mathbf{b^\circ}} = 0, \end{equation}

where $$a_{ij}$$ are the stoichiometric coefficients of the species, which represent the number of atoms of element $$i$$ per mole of species $$j$$. The number of moles and the total number of atoms of the $$j$$ species and $$i$$ element reads $$n_j$$ and $$b_i$$, respectively. This is computed during the initialization of the variable self. Using one of the predefined list of species, e.g., soot formation, this can be initializate as

self = App('soot formation')


A simple test can be performed by considering the global exothermic reaction of hydrogen bromide with $$n_j$$ moles

\begin{equation} \text{H}_2 + \text{Br}_2 \rightleftharpoons 2\text{HBr} \end{equation}

which have only three species involve. The system obtained is

\begin{equation} \left(\begin{array}{c c c} 0 & 2 & 1\\ 2 & 0 & 1\\ \end{array}\right) \left(\begin{matrix} n_{\ce{H_2}}\\ n_{\ce{Br_2}}\\ n_{\ce{HBr}}\\ \end{matrix}\right) - \left(\begin{matrix} b_{\ce{Br}}^\circ\\ b_{\ce{H}}^\circ\\ \end{matrix}\right) = 0. \end{equation}

A quick check using Combustion Toolbox:

>> self = App({'H2', 'Br2', 'HBr'});
>> print_stoichiometric_matrix(self, 'transpose')

Transpose stoichiometric matrix:

H2    Br2    HBr
__    ___    ___

BR    0      2      1
H     2      0      1


Routines
FullName2name(species)#

Get full name of the given species

Parameters

species (str) – Chemical species

Returns

name (str) – Full name of the given species

check_DB(self, DB_master, DB, varargin)#

Include not defined species in database from master database

Parameters
• self (struct) – struct with elements data

• DB_master (struct) – Database with the thermodynamic data of the chemical species

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Optional Args:

LS_check (cell)

Returns

Tuple containing

• DB (struct): Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

• E (struct): Elements data

• S (struct): Slements data

• C (struct): Constant data

compute_change_moles_gas_reaction(element_matrix, swtCondensed)#

In order to compute the internal energy of formation from the enthalpy of formation of a given species, we must determine the change in moles of gases during the formation reaction of a mole of that species starting from the elements in their reference state.

Notes: The only elements that are stable as diatomic gases are elements 1 (H), 8 (N), 9 (O), 10 (F), and 18 (Cl). The remaining elements that are stable as (monoatomic) gases are the noble gases He (3), Ne (11), Ar (19), Kr (37), Xe (55), and Rn (87), which do not form any compound.

Parameters
• element_matrix (float) – Element matrix of the species

• swtCondensed (float) – 0 or 1 indicating gas or condensed species

Returns

Delta_n (float) – Change in moles of gases during the formation reaction of a mole of that species starting from the elements in their reference state

compute_interval_NASA(species, T, DB, tRange, ctTInt)#

Compute interval NASA polynomials

Parameters
• species (str) – Chemical species

• T (float) – Temperature [K]

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

• tRange (cell) – Ranges of temperatures [K]

• ctTInt (float) – Number of intervals of temperatures

Returns

tInterval (float) – Index of the interval of temperatures

detect_location_of_phase_specifier(species)#

Detect the location of the opening pharenthesis of the phase identifier (if any)

Parameters

species (str) – Chemical species

Returns

n_open_parenthesis (float) – Index of the location of the open parenthesis

generate_DB(DB_master)#

Generate Database (DB) with thermochemical interpolation curves for the species contained in DB_master

Parameters

DB_master (struct) – Database with the thermodynamic data of the chemical species

Returns

DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

generate_DB_Theo()#

Generate database for theoretical computation of the jump conditions of a diatomic species only considering dissociation.

Returns

DB_Theo (struct) – Database with quantum data of several diatomic species

generate_DB_master(varargin)#

Generate Mater Database (DB_master) with the thermodynamic data of the chemical species

Optional args:
• reducedDB (flag): Flag indicating reduced database

• thermoFile (file): File with NASA’s thermodynamic database

Returns

DB_master (struct) – Database with the thermodynamic data of the chemical species

generate_DB_master_reduced(DB_master)#

Generate Reduced Mater Database (DB_master_reduced) with the thermodynamic data of the chemical species

Parameters

DB_master (struct) – Database with the thermodynamic data of the chemical species

Returns

DB_master_reduced (struct) – Reduced database with the thermodynamic data of the chemical species

get_g0(self, species, T, DB)#

Compute Compute Gibbs energy [kJ/mol] of the species at the given temperature [K] using NASA’s 9 polynomials

Parameters
• self (str) – Data of the mixture, conditions, and databases

• species (str) – Chemical species

• temperature (float) – Range of temperatures to evaluate [K]

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns

g0 (float) – Gibbs energy [kJ/mol]

get_interval(species, T, DB)#

Get interval of the NASA’s polynomials from the Database (DB) for the given species and temperature [K].

Parameters
• species (str) – Chemical species

• T (float) – Temperature [K]

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns

tInterval (float) – Index of the interval of temperatures

get_reference_elements_with_T_intervals()#

Get list with reference form of elements and its temperature intervals

Returns

list (cell) – List with reference form of elements and its temperature intervals

get_speciesProperties(DB, species, T, MassOrMolar, echo)#

Calculates the thermodynamic properties of any species included in the NASA database

Parameters
• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

• species (str) – Chemical species

• T (float) – Temperature [K]

• MassOrMolar (str) – Label indicating mass [kg] or molar [mol] units

• echo (float) – 0 or 1 indicating species not found

Returns

Tuple containing

• txFormula (str): Chemical formula

• mm (float): Molar weight [g/mol]

• cP0 (float): Specific heat at constant pressure [J/(mol-k)]

• cV0 (float): Specific heat at constant volume [J/(mol-k)]

• hf0 (float): Enthalpy of formation [J/mol]

• h0 (float): Enthalpy [J/mol]

• ef0 (float): Internal energy of formation [J/mol]

• e0 (float): Enthalpy [J/mol]

• s0 (float): Entropy [J/(mol-k)]

• Dg0 (float): Gibbs energy [J/mol]

isRefElm(reference_elements, species, T)#

Check if the given species is a reference element

Parameters
• reference_elements (cell) – List of reference elements with temperature intervals [K]

• species (str) – Chemical species

• T (float) – Temperature

Returns

name (str) – Full name of the given species

name_with_parenthesis(species)#

Update the name of the given string with parenthesis. The character b if comes in pair represents parenthesis in the NASA’s database

Parameters

species (str) – Chemical species in NASA’s Database format

Returns

species_with (str) – Chemical species with parenthesis

set_element_matrix(txFormula, elements)#

Compute element matrix of the given species

Parameters

txFormula (str) – Chemical formula

Returns

element_matrix(float) – Element matrix

Example

For CO2

element_matrix = [7, 9; 1, 2]

That is, the species contains 1 atom of element 7 (C) and 2 atoms of element 9 (O)

set_g0(LS, T, DB)#

Function that computes the vector of gibbs free energy for the given set of species [J/mol]

Parameters
• LS (cell) – List of species

• T (float) – Temperature [K]

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns

g0 (float) – Gibbs energy [J/mol]

set_h0(LS, T, DB)#

Function that computes the vector of enthalpies for the given set of species [J/mol]

Parameters
• LS (cell) – List of species

• T (float) – Temperature [K]

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns

h0 (float) – Gibbs energy [J/mol]

set_reference_form_of_elements#

Get list with reference form of elements

Returns

list (cell) – List with reference form of elements

set_reference_form_of_elements_with_T_intervals#

Get list with reference form of elements and its temperature intervals

Returns

list (cell) – List with reference form of elements and its temperature intervals

species_DeT(species, T, DB)#

Compute thermal internal energy [kJ/mol] of the species at the given temperature [K] using piecewise cubic Hermite interpolating polynomials and linear extrapolation

Parameters
• species (str) – Chemical species

• T (float) – Temperature [K]

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns

DeT (float) – Thermal internal energy [kJ/mol]

species_DeT_NASA(species, temperature, DB)#

Compute thermal internal energy [kJ/mol] of the species at the given temperature [K] using NASA’s 9 polynomials

Parameters
• species (str) – Chemical species

• temperature (float) – Range of temperatures to evaluate [K]

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns

DeT (float) – Thermal internal energy [kJ/mol]

species_DhT(species, T, DB)#

Compute thermal enthalpy [kJ/mol] of the species at the given temperature [K] using piecewise cubic Hermite interpolating polynomials and linear extrapolation

Parameters
• species (str) – Chemical species

• T (float) – Temperature [K]

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns

DhT (float) – Thermal enthalpy [kJ/mol]

species_DhT_NASA(species, temperature, DB)#

Compute thermal enthalpy [kJ/mol] of the species at the given temperature [K] using NASA’s 9 polynomials

Parameters
• species (str) – Chemical species

• temperature (float) – Range of temperatures to evaluate [K]

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns

DhT (float) – Thermal enthalpy [kJ/mol]

species_cP(species, T, DB)#

Compute specific heat at constant pressure [J/(mol-K)] of the species at the given temperature [K] using piecewise cubic Hermite interpolating polynomials and linear extrapolation

Parameters
• species (str) – Chemical species

• T (float) – Temperature [K]

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns

cP (float) – Specific heat at constant pressure [J/(mol-K)]

species_cP_NASA(species, temperature, DB)#

Compute specific heats at constant pressure and at constant volume [J/(mol-K)] of the species at the given temperature [K] using NASA’s 9 polynomials

Parameters
• species (str) – Chemical species

• temperature (float) – Range of temperatures to evaluate [K]

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns

Tuple containing

• cP (float): Specific heat at constant pressure [J/(mol-K)]

• cV (float): Specific heat at constant volume [J/(mol-K)]

species_cV(species, T, DB)#

Compute specific heat at constant volume [J/(mol-K)] of the species at the given temperature [K] using piecewise cubic Hermite interpolating polynomials and linear extrapolation

Parameters
• species (str) – Chemical species

• T (float) – Temperature [K]

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns

cV (float) – Specific heat at constant volume [J/(mol-K)]

species_cV_NASA(species, temperature, DB)#

Compute specific heat at constant volume [J/(mol-K)] of the species at the given temperature [K] using NASA’s 9 polynomials

Parameters
• species (str) – Chemical species

• temperature (float) – Range of temperatures to evaluate [K]

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns

cV (float) – Specific heat at constant volume [J/(mol-K)]

species_e0_NASA(species, temperature, DB)#

Compute internal energy and the thermal internal energy [kJ/mol] of the species at the given temperature [K] using NASA’s 9 polynomials

Parameters
• species (str) – Chemical species

• temperature (float) – Range of temperatures to evaluate [K]

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns

Tuple containing

• e0 (float): Internal energy [kJ/mol]

• DeT (float): Thermal internal energy [kJ/mol]

species_g0(species, T, DB)#

Compute Gibbs energy [kJ/mol] of the species at the given temperature [K] using piecewise cubic Hermite interpolating polynomials and linear extrapolation

Parameters
• species (str) – Chemical species

• T (float) – Temperature [K]

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns

g0 (float) – Gibbs energy [kJ/mol]

species_g0_NASA(species, temperature, DB)#

Compute Compute Gibbs energy [kJ/mol] of the species at the given temperature [K] using NASA’s 9 polynomials

Parameters
• species (str) – Chemical species

• temperature (float) – Range of temperatures to evaluate [K]

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns

g0 (float) – Gibbs energy [kJ/mol]

species_h0(species, T, DB)#

Compute enthalpy [kJ/mol] of the species at the given temperature [K] using piecewise cubic Hermite interpolating polynomials and linear extrapolation

Parameters
• species (str) – Chemical species

• T (float) – Temperature [K]

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns

h0 (float) – enthalpy [kJ/mol]

species_h0_NASA(species, temperature, DB)#

Compute enthalpy and thermal enthalpy [kJ/mol] of the species at the given temperature [K] using NASA’s 9 polynomials

Parameters
• species (str) – Chemical species

• temperature (float) – Range of temperatures to evaluate [K]

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns

Tuple containing

• h0 (float): Enthalpy [kJ/mol]

• DhT (float): Thermal enthalpy [kJ/mol]

species_s0(species, T, DB)#

Compute entropy [kJ/(mol-K)] of the species at the given temperature [K] using piecewise cubic Hermite interpolating polynomials and linear extrapolation

Parameters
• species (str) – Chemical species

• T (float) – Temperature [K]

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns

s0 (float) – Entropy [kJ/(mol-K)]

species_s0_NASA(species, temperature, DB)#

Compute entropy [kJ/(mol-K)] of the species at the given temperature [K] using NASA’s 9 polynomials

Parameters
• species (str) – Chemical species

• temperature (float) – Range of temperatures to evaluate [K]

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns

s0 (float) – Entropy [kJ/(mol-K)]

species_thermo_NASA(species, temperature, DB)#

Compute thermodynamic function using NASA’s 9 polynomials

Parameters
• species (str) – Chemical species

• temperature (float) – Range of temperatures to evaluate [K]

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns

Tuple containing

• cP (float): Specific heat at constant pressure [J/(mol-K)]

• cV (float): Specific heat at constant volume [J/(mol-K)]

• h0 (float): Enthalpy [kJ/mol]

• DhT (float): Thermal enthalpy [kJ/mol]

• e0 (float): Internal energy [kJ/mol]

• DeT (float): Thermal internal energy [kJ/mol]

• s0 (float): Entropy [J/(mol-K)]

• g0 (float): Gibbs energy [kJ/mol]

unpack_NASA_coefficients(species, DB)#

Unpack NASA’s polynomials coefficients from database

Parameters
• species (str) – Chemical species

• DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns

Tuple containing

• a (cell): Temperature coefficients

• b (cell): Integration constants

• tRange (cell): Ranges of temperatures [K]

• tExponents (cell): Exponent coefficients

• ctTInt (float): Number of intervals of temperatures

• txFormula (str): Chemical formula

• swtCondensed (float): 0 or 1 indicating gas or condensed phase, respectively

1. McBride, Bonnie J. NASA Glenn coefficients for calculating thermodynamic properties of individual species. National Aeronautics and Space Administration, John H. Glenn Research Center at Lewis Field, 2002.