Thermochemical equilibrium module#
In this section, you will find the documentation of the kernel of the code, which is used to obtain the chemical equilibrium composition for a desired thermochemical transformation, e.g., constant enthalpy and pressure. It also includes routines to compute chemical equilibrium assuming a complete combustion and the calculation of the thermodynamic derivates. The code stems from the minimization of the free energy of the system by using Lagrange multipliers combined with a Newton-Raphson method, upon condition that initial gas properties are defined by two functions of states, e.g., temperature and pressure.
Note
The kernel of the code is based on Gordon, S., & McBride, B. J. (1994). NASA reference publication, 1311.
Thermodynamic derivatives#
All thermodynamic first derivatives can be obtained with any set of three independent first derivatives [1]. Combustion Toolbox computes all thermodynamic first derivatives from \((\partial \text{ln } V/\partial \text{ln } T)_p\), \((\partial \text{ln } V/\partial \text{ln } p)_T\), and \((\partial h/\partial T)_p = c_p\). Considering the ideal equation of state
and applying logarithms to both sides
is readily seen that
To compute \(c_p\) we have to distinguish between the frozen contribution and the reaction contribution
given by the following relations
with \(\eta_j = \text{ln } n_j\) and \(\delta_j = 1 \) for \(j=1,\dots,NG\) (non-condensed species), and \(\eta_j = n_j\) and \(\delta_j = 0\) for \(j = NG + 1, \dots, NS\) (condensed species).
Derivatives with respect to temperature#
Derivatives with respect to pressure#
Routines
- complete_combustion(self, mix, phi)#
Solve chemical equilibrium for CHNO mixtures assuming a complete combustion using the equilibrium constants method
- Parameters:
self (
struct
) – Data of the mixture, conditions, and databasesmix (
struct
) – Properties of the initial mixturephi (
float
) – Equivalence ratio [-]
- Returns:
Tuple containing
moles (float): Equilibrium composition [moles] at defined temperature
species (str): Species considered in the complemte combustion model
Example
[moles, species] = complete_combustion(self, self.PS.strR{1}, 0.5)
- equilibrate(self, mix1, pP, varargin)#
Obtain properties at equilibrium for the set thermochemical transformation
- Parameters:
self (
struct
) – Data of the mixture, conditions, and databasesmix1 (
struct
) – Properties of the initial mixturepP (
float
) – Pressure [bar]
- Optional Args:
mix2 (struct): Properties of the final mixture (previous calculation)
- Returns:
mix2 (struct) – Properties of the final mixture
Example
mix2 = equilibrate(self, self.PS.strR{1}, 1.01325)
- equilibrate_T(self, mix1, pP, TP, varargin)#
Obtain equilibrium properties and composition for the given temperature [K] and pressure [bar]
- Parameters:
self (
struct
) – Data of the mixture, conditions, and databasesmix1 (
struct
) – Properties of the initial mixturepP (
float
) – Pressure [bar]TP (
float
) – Temperature [K]
- Optional Args:
guess_moles (float): Mixture composition [mol] of a previous computation
- Returns:
mix2 (struct) – Properties of the final mixture
Example
mix2 = equilibrate(self, self.PS.strR{1}, 1.01325, 3000)
- equilibrate_T_tchem(self, mix1, pP, TP)#
Obtain equilibrium properties and composition for the given temperature [K] and pressure [bar] assuming a calorically perfect gas
- Parameters:
self (
struct
) – Data of the mixture, conditions, and databasesmix1 (
struct
) – Properties of the initial mixturepP (
float
) – Pressure [bar]TP (
float
) – Temperature [K]
- Returns:
mix2 (struct) – Properties of the final mixture assuming a calorically perfect gas
Example
mix2 = equilibrate_T_tchem(self, self.PS.strR{1}, 1.01325, 3000)
- equilibrium_dT(J, N0, A0, NE, ind_nswt, ind_swt, ind_elem, H0RT)#
Obtain thermodynamic derivative of the moles of the species and of the moles of the mixture respect to temperature from a given composition [moles] at equilibrium
- Parameters:
J (
float
) – Matrix J to solve the linear system J*x = bN0 (
float
) – Equilibrium composition [moles]A0 (
float
) – Stoichiometric matrixNE (
float
) – Temporal total number of elementsind (
float
) – Temporal index of species in the final mixtureind_nswt (
float
) – Temporal index of gaseous species in the final mixtureind_swt (
float
) – Temporal index of condensed species in the final mixtureind_elem (
float
) – Temporal index of elements in the final mixtureH0RT (
float
) – Dimensionless enthalpy
- Returns:
Tuple containing
dNi_T (float): Thermodynamic derivative of the moles of the species respect to temperature
dN_T (float): Thermodynamic derivative of the moles of the mixture respect to temperature
Example
[dNi_T, dN_T] = equilibrium_dT(J, N0, A0, NE, ind, ind_nswt, ind_swt, ind_elem, H0RT)
- equilibrium_dT_large(self, moles, T, A0, NG, NS, NE, ind, ind_nswt, ind_swt, ind_E)#
Obtain thermodynamic derivative of the moles of the species and of the moles of the mixture respect to temperature from a given composition [moles] at equilibrium
- Parameters:
self (
struct
) – Data of the mixture, conditions, and databasesmoles (
float
) – Equilibrium composition [moles]T (
float
) – Temperature [K]A0 (
float
) – Stoichiometric matrixNG (
float
) – Temporal total number of gaseous speciesNS (
float
) – Temporal total number of speciesNE (
float
) – Temporal total number of elementsind (
float
) – Temporal index of species in the final mixtureind_nswt (
float
) – Temporal index of gaseous species in the final mixtureind_swt (
float
) – Temporal index of condensed species in the final mixtureind_E (
float
) – Temporal index of elements in the final mixture
- Returns:
Tuple containing
dNi_T (float): Thermodynamic derivative of the moles of the species respect to temperature
dN_T (float): Thermodynamic derivative of the moles of the mixture respect to temperature
Example
[dNi_T, dN_T] = equilibrium_dT_large(self, moles, T, A0, NG, NS, NE, ind, ind_nswt, ind_swt, ind_E)
- equilibrium_dp(J, N0, A0, NE, ind_nswt, ind_swt, ind_elem)#
Obtain thermodynamic derivative of the moles of the species and of the moles of the mixture respect to pressure from a given composition [moles] at equilibrium
- Parameters:
J (
float
) – Matrix J to solve the linear system J*x = bN0 (
float
) – Equilibrium composition [moles]A0 (
float
) – Stoichiometric matrixNE (
float
) – Temporal total number of elementsind (
float
) – Temporal index of species in the final mixtureind_nswt (
float
) – Temporal index of gaseous species in the final mixtureind_swt (
float
) – Temporal index of condensed species in the final mixtureind_elem (
float
) – Temporal index of elements in the final mixture
- Returns:
Tuple containing
dNi_p (float): Thermodynamic derivative of the moles of the species respect to pressure
dN_p (float): Thermodynamic derivative of the moles of the mixture respect to pressure
Example
[dNi_p, dN_p] = equilibrium_dp(J, N0, A0, NE, ind, ind_nswt, ind_swt, ind_elem)
- equilibrium_dp_large(self, N0, A0, NG, NS, NE, ind, ind_nswt, ind_swt, ind_E)#
Obtain thermodynamic derivative of the moles of the species and of the moles of the mixture respect to pressure from a given composition [moles] at equilibrium
- Parameters:
self (
struct
) – Data of the mixture, conditions, and databasesN0 (
float
) – Equilibrium composition [moles]A0 (
float
) – Stoichiometric matrixNG (
float
) – Temporal total number of gaseous speciesNS (
float
) – Temporal total number of speciesNE (
float
) – Temporal total number of elementsind (
float
) – Temporal index of species in the final mixtureind_nswt (
float
) – Temporal index of gaseous species in the final mixtureind_swt (
float
) – Temporal index of condensed species in the final mixtureind_E (
float
) – Temporal index of elements in the final mixture
- Returns:
Tuple containing
dNi_p (float): Thermodynamic derivative of the moles of the species respect to pressure
dN_p (float): Thermodynamic derivative of the moles of the mixture respect to pressure
Example
[dNi_p, dN_p] = equilibrium_dp_large(self, N0, A0, NG, NS, NE, ind, ind_nswt, ind_swt, ind_E)
- equilibrium_gibbs(self, pP, TP, mix1, guess_moles)#
Obtain equilibrium composition [moles] for the given temperature [K] and pressure [bar]. The code stems from the minimization of the free energy of the system by using Lagrange multipliers combined with a Newton-Raphson method, upon condition that initial gas properties are defined by temperature and pressure.
The algorithm implemented take advantage of the sparseness of the upper left submatrix obtaining a matrix J of size NE + NS - NG + 1.
This method is based on the method outlined in Gordon, S., & McBride, B. J. (1994). NASA reference publication, 1311.
- Parameters:
self (
struct
) – Data of the mixture, conditions, and databasespP (
float
) – Pressure [bar]TP (
float
) – Temperature [K]mix1 (
struct
) – Properties of the initial mixtureguess_moles (
float
) – Mixture composition [mol] of a previous computation
- Returns:
Tuple containing
N0 (float): Composition matrix [n_i, FLAG_CONDENSED_i] for the given temperature [K] and pressure [bar] at equilibrium
dNi_T (float): Thermodynamic derivative of the moles of the species respect to temperature
dN_T (float): Thermodynamic derivative of the moles of the mixture respect to temperature
dNi_p (float): Thermodynamic derivative of the moles of the species respect to pressure
dN_p (float): Thermodynamic derivative of the moles of the mixture respect to pressure
ind (float): List of chemical species indices
STOP (float): Relative error in moles of species [-]
Examples
N0 = equilibrium_gibbs(self, 1.01325, 3000, self.PS.strR{1}, [])
[N0, dNi_T, dN_T, dNi_p, dN_p, ind, STOP, STOP_ions] = equilibrium_gibbs(self, 1.01325, 3000, self.PS.strR{1}, [])
- equilibrium_gibbs_eos(self, pP, TP, mix1, guess_moles)#
Obtain equilibrium composition [moles] for the given temperature [K] and pressure [bar]. The code stems from the minimization of the free energy of the system by using Lagrange multipliers combined with a Newton-Raphson method, upon condition that initial gas properties are defined by temperature and pressure.
This method is based on the method outlined in Gordon, S., & McBride, B. J. (1994). NASA reference publication, 1311.
- Parameters:
self (
struct
) – Data of the mixture, conditions, and databasespP (
float
) – Pressure [bar]TP (
float
) – Temperature [K]mix1 (
struct
) – Properties of the initial mixtureguess_moles (
float
) – Mixture composition [mol] of a previous computation
- Returns:
Tuple containing
N0 (float): Equilibrium composition [moles] for the given temperature [K] and pressure [bar]
dNi_T (float): Thermodynamic derivative of the moles of the species respect to temperature
dN_T (float): Thermodynamic derivative of the moles of the mixture respect to temperature
dNi_p (float): Thermodynamic derivative of the moles of the species respect to pressure
dN_p (float): Thermodynamic derivative of the moles of the mixture respect to pressure
STOP (float): Relative error in moles of species [-]
STOP_ions (float): Relative error in moles of ionized species [-]
Example
[N0, dNi_T, dN_T, dNi_p, dN_p, STOP, STOP_ions] = equilibrium_gibbs_eos(self, pP, TP, mix1, guess_moles)
- equilibrium_gibbs_large(self, pP, TP, mix1, guess_moles)#
Obtain equilibrium composition [moles] for the given temperature [K] and pressure [bar]. The code stems from the minimization of the free energy of the system by using Lagrange multipliers combined with a Newton-Raphson method, upon condition that initial gas properties are defined by temperature and pressure.
This method is based on the method outlined in Gordon, S., & McBride, B. J. (1994). NASA reference publication, 1311.
- Parameters:
self (
struct
) – Data of the mixture, conditions, and databasespP (
float
) – Pressure [bar]TP (
float
) – Temperature [K]mix1 (
struct
) – Properties of the initial mixtureguess_moles (
float
) – Mixture composition [mol] of a previous computation
- Returns:
Tuple containing
N0 (float): Equilibrium composition [moles] for the given temperature [K] and pressure [bar]
dNi_T (float): Thermodynamic derivative of the moles of the species respect to temperature
dN_T (float): Thermodynamic derivative of the moles of the mixture respect to temperature
dNi_p (float): Thermodynamic derivative of the moles of the species respect to pressure
dN_p (float): Thermodynamic derivative of the moles of the mixture respect to pressure
ind (float): List of chemical species indices
STOP (float): Relative error in moles of species [-]
STOP_ions (float): Relative error in moles of ionized species [-]
Examples
N0 = equilibrium_gibbs_large(self, 1.01325, 3000, self.PS.strR{1}, [])
[N0, dNi_T, dN_T, dNi_p, dN_p, ind, STOP, STOP_ions] = equilibrium_gibbs_large(self, 1.01325, 3000, self.PS.strR{1}, [])
- equilibrium_helmholtz(self, vP, TP, mix1, guess_moles)#
Obtain equilibrium composition [moles] for the given temperature [K] and volume [m3]. The code stems from the minimization of the free energy of the system by using Lagrange multipliers combined with a Newton-Raphson method, upon condition that initial gas properties are defined by temperature and volume.
The algorithm implemented take advantage of the sparseness of the upper left submatrix obtaining a matrix J of size NE + NS - NG.
This method is based on the method outlined in Gordon, S., & McBride, B. J. (1994). NASA reference publication, 1311.
- Parameters:
self (
struct
) – Data of the mixture, conditions, and databasesvP (
float
) – Volume [m3]TP (
float
) – Temperature [K]mix1 (
struct
) – Properties of the initial mixtureguess_moles (
float
) – Mixture composition [mol] of a previous computation
- Returns:
Tuple containing
N0 (float): Equilibrium composition [moles] for the given temperature [K] and pressure [bar]
dNi_T (float): Thermodynamic derivative of the moles of the species respect to temperature
dN_T (float): Thermodynamic derivative of the moles of the mixture respect to temperature
dNi_p (float): Thermodynamic derivative of the moles of the species respect to pressure
dN_p (float): Thermodynamic derivative of the moles of the mixture respect to pressure
ind (float): List of chemical species indices
STOP (float): Relative error in moles of species [-]
STOP_ions (float): Relative error in moles of ionized species [-]
Examples
N0 = equilibrium_helmholtz(self, 0.0716, 3000, self.PS.strR{1}, [])
[N0, dNi_T, dN_T, dNi_p, dN_p, ind, STOP, STOP_ions] = equilibrium_helmholtz(self, 0.0716, 3000, self.PS.strR{1}, [])
- equilibrium_helmholtz_eos(self, vP, TP, mix1, guess_moles)#
Obtain equilibrium composition [moles] for the given temperature [K] and volume [m3]. The code stems from the minimization of the free energy of the system by using Lagrange multipliers combined with a Newton-Raphson method, upon condition that initial gas properties are defined by temperature and volume.
This method is based on the method outlined in Gordon, S., & McBride, B. J. (1994). NASA reference publication, 1311.
- Parameters:
self (
struct
) – Data of the mixture, conditions, and databasesvP (
float
) – Volume [m3]TP (
float
) – Temperature [K]mix1 (
struct
) – Properties of the initial mixtureguess_moles (
float
) – Mixture composition [mol] of a previous computation
- Returns:
Tuple containing
N0 (float): Equilibrium composition [moles] for the given temperature [K] and pressure [bar]
dNi_T (float): Thermodynamic derivative of the moles of the species respect to temperature
dN_T (float): Thermodynamic derivative of the moles of the mixture respect to temperature
dNi_p (float): Thermodynamic derivative of the moles of the species respect to pressure
dN_p (float): Thermodynamic derivative of the moles of the mixture respect to pressure
STOP (float): Relative error in moles of species [-]
STOP_ions (float): Relative error in moles of ionized species [-]
Example
[N0, dNi_T, dN_T, dNi_p, dN_p, STOP, STOP_ions] = equilibrium_helmholtz_eos(self, vP, TP, mix1, guess_moles)
- equilibrium_helmholtz_large(self, vP, TP, mix1, guess_moles)#
Obtain equilibrium composition [moles] for the given temperature [K] and volume [m3]. The code stems from the minimization of the free energy of the system by using Lagrange multipliers combined with a Newton-Raphson method, upon condition that initial gas properties are defined by temperature and volume.
This method is based on the method outlined in Gordon, S., & McBride, B. J. (1994). NASA reference publication, 1311.
- Parameters:
self (
struct
) – Data of the mixture, conditions, and databasesvP (
float
) – Volume [m3]TP (
float
) – Temperature [K]mix1 (
struct
) – Properties of the initial mixtureguess_moles (
float
) – Mixture composition [mol] of a previous computation
- Returns:
Tuple containing
N0 (float): Equilibrium composition [moles] for the given temperature [K] and pressure [bar]
dNi_T (float): Thermodynamic derivative of the moles of the species respect to temperature
dN_T (float): Thermodynamic derivative of the moles of the mixture respect to temperature
dNi_p (float): Thermodynamic derivative of the moles of the species respect to pressure
dN_p (float): Thermodynamic derivative of the moles of the mixture respect to pressure
ind (float): List of chemical species indices
STOP (float): Relative error in moles of species [-]
STOP_ions (float): Relative error in moles of ionized species [-]
Examples
N0 = equilibrium_helmholtz_large(self, 0.0716, 3000, self.PS.strR{1}, [])
[N0, dNi_T, dN_T, dNi_p, dN_p, ind, STOP, STOP_ions] = equilibrium_helmholtz_large(self, 0.0716, 3000, self.PS.strR{1}, [])
McBride, Bonnie J. Computer program for calculation of complex chemical equilibrium compositions and applications. Vol. 2. NASA Lewis Research Center, 1996.