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
- 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
- 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)
- equilibrium_dT(self, moles, T, A0, temp_NG, temp_NS, temp_NE, temp_ind, temp_ind_nswt, temp_ind_swt, temp_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 matrixtemp_NG (
float
) – Temporal total number of gaseous speciestemp_NS (
float
) – Temporal total number of speciestemp_NE (
float
) – Temporal total number of elementstemp_ind (
float
) – Temporal index of species in the final mixturetemp_ind_nswt (
float
) – Temporal index of gaseous species in the final mixturetemp_ind_swt (
float
) – Temporal index of condensed species in the final mixturetemp_ind_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
- equilibrium_dp(self, moles, A0, temp_NG, temp_NS, temp_NE, temp_ind, temp_ind_nswt, temp_ind_swt, temp_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 databasesmoles (
float
) – Equilibrium composition [moles]A0 (
float
) – Stoichiometric matrixtemp_NG (
float
) – Temporal total number of gaseous speciestemp_NS (
float
) – Temporal total number of speciestemp_NE (
float
) – Temporal total number of elementstemp_ind (
float
) – Temporal index of species in the final mixturetemp_ind_nswt (
float
) – Temporal index of gaseous species in the final mixturetemp_ind_swt (
float
) – Temporal index of condensed species in the final mixturetemp_ind_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
- 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.
This method is based on 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 [-]
- 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 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 [-]
- equilibrium_gibbs_reduced(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 two functions of states. e.g., temperature and pressure. The algorithm implemented take advantage of the sparseness of the upper left submatrix obtaining a matrix A of size NE + NS-NG + 1.
This method is based on 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 [-]
- 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.
This method is based on 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 [-]
- 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 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 [-]
- equilibrium_ions(self, pP, TP, mix1, guess_moles)#
Obtain equilibrium composition [moles] for the given temperature [K] and pressure [bar] considering ionization of the species. 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.
This method is based on 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 [-]
McBride, Bonnie J. Computer program for calculation of complex chemical equilibrium compositions and applications. Vol. 2. NASA Lewis Research Center, 1996.