Overdriven and underdrive detonation waves#

 1% -------------------------------------------------------------------------
 2% EXAMPLE: DET_OVERDRIVEN_AND_UNDERDRIVEN
 3%
 4% Compute pre-shock and post-shock state for a planar underdriven to 
 5% overdriven detonation considering Chapman-Jouguet (CJ) theory for a
 6% stoichiometric CH4-air mixture at standard conditions (T = 300 K, p = 1 atm),
 7% and a set of overdrives contained in (1,10) [-].
 8%   
 9% See wiki or setListspecies method from ChemicalSystem class for predefined
10% sets of species
11%
12% @author: Alberto Cuadra Lara
13%                 
14% Last update October 06 2025
15% -------------------------------------------------------------------------
16
17% Import packages
18import combustiontoolbox.databases.NasaDatabase
19import combustiontoolbox.core.*
20import combustiontoolbox.shockdetonation.*
21
22% Get Nasa database
23DB = NasaDatabase();
24
25% Define chemical system
26system = ChemicalSystem(DB);
27
28% Initialize mixture
29mix = Mixture(system);
30
31% Define chemical state
32set(mix, {'CH4'}, 'fuel', 1);
33set(mix, {'N2', 'O2', 'Ar', 'CO2'}, 'oxidizer', [78.084, 20.9476, 0.9365, 0.0319] / 20.9476);
34
35% Define properties
36mixArray1_over = setProperties(mix, 'temperature', 300, 'pressure', 1.01325, 'equivalenceRatio', 1, 'driveFactor', 1:0.1:10);
37mixArray1_under = setProperties(mix, 'temperature', 300, 'pressure', 1.01325, 'equivalenceRatio', 1, 'driveFactor', 1:0.1:10);
38
39% Initialize solver
40solver1 = DetonationSolver('problemType', 'DET_OVERDRIVEN');
41solver2 = DetonationSolver('problemType', 'DET_UNDERDRIVEN');
42
43% Solve problem
44[mixArray1_over, mixArray2_over] = solver1.solveArray(mixArray1_over);
45[mixArray1_under, mixArray2_under] = solver2.solveArray(mixArray1_under);
46
47% Generate reports
48report(solver1, mixArray1_over, mixArray2_over);
49report(solver2, mixArray1_under, mixArray2_under);