1% -------------------------------------------------------------------------
2% EXAMPLE: HP - Humid air
3%
4% Compute adiabatic temperature and equilibrium composition at constant
5% pressure (e.g., 1.01325 bar) for lean to rich CH4-ideal_air mixtures at
6% standard conditions, a set of 10 species considered, and excess of air
7% of 15%, and a set of relative humidity (0, 20, 40, 60, 80, 100) [%]
8%
9% LS == {'CO2', 'CO', 'H2O', 'H2', 'O2', 'N2', 'NO', 'OH', 'O', 'H'}
10%
11% See wiki or setListspecies method from ChemicalSystem class for more
12% predefined sets of species
13%
14% Results compared with [1]
15%
16% [1] Sánchez, Y. A. C., Piedrahita, C. A. R., & Serrano, E. G. F. (2014).
17% Influencia del aire húmedo en la combustión del metano. Scientia et
18% technica, 19(4), 364-370.
19%
20% @author: Alberto Cuadra Lara
21% Postdoctoral researcher - Group Fluid Mechanics
22% Universidad Carlos III de Madrid
23%
24% Last update Aug 05 2024
25% -------------------------------------------------------------------------
26
27% Import packages
28import combustiontoolbox.databases.NasaDatabase
29import combustiontoolbox.core.*
30import combustiontoolbox.equilibrium.*
31import combustiontoolbox.utils.display.*
32import combustiontoolbox.utils.findIndex
33import combustiontoolbox.utils.extensions.brewermap
34
35% User inputs
36airExcess = 15; % [%]
37humidityRelative = 0:20:100; % [%]
38T = [10:2:60] + 273.15; % [K]
39p = 1 * 1.01325; % [bar]
40
41% Get Nasa database
42DB = NasaDatabase();
43
44% Define chemical system
45system = ChemicalSystem(DB, {'CO2', 'CO', 'H2O', 'H2', 'O2', 'N2', 'NO', 'OH', 'O', 'H'});
46
47% Initialize mixture
48mix = Mixture(system);
49
50% Initialize solver
51solver = EquilibriumSolver('problemType', 'HP', 'FLAG_TIME', false);
52
53% Definitions
54stoichiometricMoles = 2; % stoichiometric number of moles of air per mole of fuel
55equivalenceRatio = 1 / (1 + airExcess / 100); % equivalence ratio [-]
56W_air = DB.species.Air.W; % [kg/mol]
57W_H2O = DB.species.H2O.W; % [kg/mol]
58moles_air = 4.76; % total number of moles of stoichiometric ideal dry air (79% N2 and 21% O2 in volume)
59
60% Miscellaneous
61FLAG_FIRST = true;
62config = PlotConfig();
63config.innerposition = [0.2 0.2 0.35 0.5]; % Set figure inner position [normalized]
64config.outerposition = [0.2 0.2 0.35 0.5]; % Set figure outer position [normalized]
65colors = brewermap(length(humidityRelative), 'Greys');
66ax1 = setFigure(config);
67ax2 = setFigure(config);
68ax3 = setFigure(config);
69
70for j = length(humidityRelative):-1:1
71 % Get specific humidity
72 W = humiditySpecific(T, p, humidityRelative(j));
73
74 % Get moles H2O
75 moles_H20 = W * moles_air * (W_air / W_H2O);
76
77 % Solve problem
78 for i = length(T):-1:1
79 % Initialize mixture
80 mix = Mixture(system);
81
82 % Define chemical state
83 set(mix, {'CH4'}, 'fuel', 1);
84 set(mix, {'N2', 'O2', 'H2O'}, 'oxidizer', stoichiometricMoles ./ equivalenceRatio .* [79/21, 1, moles_H20(i)]);
85
86 % Define properties
87 mix1 = setProperties(mix, 'temperature', T(i), 'pressure', p, 'equivalenceRatio', equivalenceRatio);
88 mix2 = setProperties(mix, 'temperature', T(i), 'pressure', p, 'equivalenceRatio', equivalenceRatio);
89
90 % Solve problem
91 solver.solveArray(mix2);
92
93 if FLAG_FIRST
94 index_CO2 = findIndex(system.listSpecies, 'CO2');
95 index_H2O = findIndex(system.listSpecies, 'H2O');
96 index_CH4 = findIndex(system.listSpecies, 'CH4');
97 FLAG_FIRST = false;
98 end
99
100 % Extract data
101 mR(i, j) = mix1.mi;
102 TR(i, j) = mix1.T;
103 Yi_R_CH4(i, j) = mix1.Yi(index_CH4);
104
105 mP(i, j) = mix2.mi;
106 TP(i, j) = mix2.T;
107 Yi_P_H2O(i, j) = mix2.Yi(index_H2O, :);
108 Xi_P_CO2(i, j) = mix2.Xi(index_CO2, :);
109
110 m_CH4(i, j) = mR(i, j) .* Yi_R_CH4(i, j);
111 m_H20(i, j) = mP(i, j) .* Yi_P_H2O(i, j);
112 end
113
114 % Plot results
115
116 % Adiabatic flame temperature vs. reactant's temperature
117 ax1 = plotFigure('T_R\ [\rm K]', TR(:, j), 'T_P\ [\rm K]', TP(:, j), 'ax', ax1, 'color', colors(j, :));
118 % Molar fraction of CO2 vs. reactant's temperature
119 ax2 = plotFigure('T_R\ [\rm K]', TR(:, j), 'X_{\rm CO_2}', Xi_P_CO2(:, j), 'ax', ax2, 'color', colors(j, :));
120 % Water content after the combustion process (kg H2O / kg fuel) vs. reactant's temperature
121 ax3 = plotFigure('T_R\ [\rm K]', TR(:, j), '\rm Water\ content\ [kg_{H_2O}/kg_{CH_4}]', m_H20(:, j)./m_CH4(:, j), 'ax', ax3, 'color', colors(j, :));
122end