Example_DET_UNDERDRIVEN.m#

 1% -------------------------------------------------------------------------
 2% EXAMPLE: DET_UNDERDRIVEN
 3%
 4% Compute pre-shock and post-shock state for a planar under-driven detonation
 5% considering Chapman-Jouguet (CJ) theory for a stoichiometric CH4-air
 6% mixture at standard conditions, a set of 24 species considered and a set
 7% of underdrives contained in (1,10) [-].
 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 setListspecies method from ChemicalSystem class for more
14% predefined sets of species
15%
16% @author: Alberto Cuadra Lara
17%          Postdoctoral researcher - Group Fluid Mechanics
18%          Universidad Carlos III de Madrid
19%
20% Last update July 25 2024
21% -------------------------------------------------------------------------
22
23% Import packages
24import combustiontoolbox.databases.NasaDatabase
25import combustiontoolbox.core.*
26import combustiontoolbox.shockdetonation.*
27import combustiontoolbox.utils.display.*
28
29% Get Nasa database
30DB = NasaDatabase();
31
32% Define chemical system
33system = ChemicalSystem(DB, 'soot formation');
34
35% Initialize mixture
36mix = Mixture(system);
37
38% Define chemical state
39set(mix, {'CH4'}, 'fuel', 1);
40set(mix, {'N2', 'O2', 'Ar', 'CO2'}, 'oxidizer', [78.084, 20.9476, 0.9365, 0.0319] / 20.9476);
41
42% Define properties
43mixArray1 = setProperties(mix, 'temperature', 300, 'pressure', 1.01325, 'equivalenceRatio', 1, 'driveFactor', 1:0.1:10);
44
45% Initialize solver
46solver = DetonationSolver('problemType', 'DET_UNDERDRIVEN');
47
48% Solve problem
49[mixArray1, mixArray2] = solver.solveArray(mixArray1);
50
51% Plot Hugoniot curve
52plotFigure('\rho_1 / \rho_2', [mixArray1.rho] ./ [mixArray2.rho], 'p_2 / p_1', [mixArray2.p] ./ [mixArray1.p], 'xScale', 'log', 'yScale', 'log');
53
54% Plot post-shock temperature
55plotFigure('driveFactor', mixArray1, 'T', mixArray2);
56
57% Plot molar fractions
58plotComposition(mixArray2(1), mixArray1, 'driveFactor', 'Xi', 'mintol', 1e-14, 'y_var', mixArray2);