Example_TV.m#

 1% -------------------------------------------------------------------------
 2% EXAMPLE: TV
 3%
 4% Compute equilibrium composition at defined temperature (e.g., 3000 K) and
 5% defined specific volume (1 m3/kg) for lean to rich CH4-air mixtures at
 6% standard conditions, a set of 24 species considered and a set of
 7% equivalence ratios (phi) contained in (0.5, 5) [-]
 8%   
 9% Soot formation == {'CO2','CO','H2O','H2','O2','N2','Ar','Cbgrb',...
10%                    'C2','C2H4','CH','CH3','CH4','CN','H',...
11%                    'HCN','HCO','N','NH','NH2','NH3','NO','O','OH'}
12%   
13% See wiki or list_species() for more predefined sets of species
14%  
15% @author: Alberto Cuadra Lara
16%          Postdoctoral researcher - Group Fluid Mechanics
17%          Universidad Carlos III de Madrid
18%                 
19% Last update April 02 2024
20% -------------------------------------------------------------------------
21
22% Import packages
23import combustiontoolbox.databases.NasaDatabase
24import combustiontoolbox.core.*
25import combustiontoolbox.equilibrium.*
26import combustiontoolbox.utils.display.*
27
28% Get Nasa database
29DB = NasaDatabase();
30
31% Define chemical system
32system = ChemicalSystem(DB, 'soot formation');
33
34% Initialize mixture
35mix = Mixture(system);
36
37% Define chemical state
38set(mix, {'CH4'}, 'fuel', 1);
39set(mix, {'N2', 'O2', 'Ar', 'CO2'}, 'oxidizer', [78.084, 20.9476, 0.9365, 0.0319] / 20.9476);
40
41% Define properties
42mixArray = setProperties(mix, 'temperature', 3000, 'volume', 1, 'equivalenceRatio', 0.5:0.01:5);
43
44% Initialize solver
45solver = EquilibriumSolver('problemType', 'TV');
46
47% Solve problem
48solver.solveArray(mixArray);
49
50% Plot molar fractions
51plotComposition(mixArray(1), mixArray, 'equivalenceRatio', 'Xi', 'mintol', 1e-14);