*** empty log message ***
This commit is contained in:
parent
dc205f4b01
commit
1a1d55be0b
3 changed files with 347 additions and 0 deletions
89
Cantera/matlab/cantera/examples/flame.m
Normal file
89
Cantera/matlab/cantera/examples/flame.m
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
function f = flame(gas, left, flow, right)
|
||||
% FLAME - create a flame object.
|
||||
%
|
||||
% gas -- object representing the gas. This object will be used to
|
||||
% compute all required thermodynamic, kinetic, and transport
|
||||
% properties. The state of this object should be set
|
||||
% to an estimate of the gas state emerging from the
|
||||
% burner before calling StagnationFlame.
|
||||
%
|
||||
% left -- object representing the burner, which must be
|
||||
% created using function Inlet.
|
||||
%
|
||||
% flow -- object representing the flow, created with
|
||||
% function AxisymmetricFlow.
|
||||
%
|
||||
% right -- object representing the surface.
|
||||
%
|
||||
|
||||
% Check input parameters
|
||||
if nargin ~= 4
|
||||
error('wrong number of input arguments.');
|
||||
end
|
||||
|
||||
if ~isIdealGas(gas)
|
||||
error('gas object must represent an ideal gas mixture.');
|
||||
end
|
||||
if ~isInlet(left)
|
||||
error('burner object of wrong type.');
|
||||
end
|
||||
if ~isFlow(flow)
|
||||
error('flow object of wrong type.');
|
||||
end
|
||||
|
||||
flametype = 0
|
||||
if isSurface(right)
|
||||
flametype = 1
|
||||
elseif isInlet(right)
|
||||
flametype = 3
|
||||
end
|
||||
|
||||
|
||||
% create the container object
|
||||
f = Stack([left flow right]);
|
||||
|
||||
% set default initial profiles.
|
||||
rho0 = density(gas);
|
||||
|
||||
% find the adiabatic flame temperature and corresponding
|
||||
% equilibrium composition
|
||||
equilibrate(gas, 'HP');
|
||||
teq = temperature(gas);
|
||||
yeq = massFractions(gas);
|
||||
rhoeq = density(gas);
|
||||
|
||||
z1 = 0.5;
|
||||
mdot0 = massFlux(left);
|
||||
mdot1 = massFlux(right);
|
||||
t0 = temperature(left);
|
||||
if flametype == 0
|
||||
t1 = teq;
|
||||
else
|
||||
t1 = temperature(right);
|
||||
end
|
||||
zz = z(flow);
|
||||
dz = zz(end) - zz(1);
|
||||
setProfile(f, 2, {'u', 'V'}, [0.0 1.0
|
||||
mdot0/rho0 -mdot1/rho0
|
||||
0.0 0.0]);
|
||||
setProfile(f, 2, 'T', [0.0 z1 1.0; t0 2000.0 t1]);
|
||||
|
||||
for n = 1:nSpecies(gas)
|
||||
nm = speciesName(gas,n);
|
||||
if strcmp(nm,'H') | strcmp(nm,'OH') | strcmp(nm,'O') | ...
|
||||
strcmp(nm,'HO2')
|
||||
yint = 3.0*yeq(n);
|
||||
else
|
||||
yint = yeq(n);
|
||||
end
|
||||
if flametype == 3
|
||||
y1 = massFraction(right, n);
|
||||
else
|
||||
y1 = yeq(n);
|
||||
end
|
||||
setProfile(f, 2, nm, [0 z1 1
|
||||
massFraction(left, n) yint y1]);
|
||||
end
|
||||
|
||||
% set minimal grid refinement criteria
|
||||
setRefineCriteria(f, 2, 10.0, 0.8, 0.8);
|
||||
127
Cantera/matlab/cantera/examples/flame1.m
Normal file
127
Cantera/matlab/cantera/examples/flame1.m
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% A burner-stabilized flat flame
|
||||
%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
t0 = cputime; % record the starting time
|
||||
|
||||
|
||||
% parameter values
|
||||
p = 0.05*oneatm; % pressure
|
||||
tburner = 373.0; % burner temperature
|
||||
mdot = 0.04; % kg/m^2/s
|
||||
|
||||
rxnmech = 'h2o2.xml'; % reaction mechanism file
|
||||
transport = 'Mix'; % transport model
|
||||
comp = 'H2:1.8, O2:1, AR:7'; % premixed gas composition
|
||||
|
||||
initial_grid = [0.0 0.02 0.04 0.06 0.08 0.1 ...
|
||||
0.15 0.2 0.49 0.5]; % m
|
||||
|
||||
tol_ss = [1.0e-5 1.0e-12]; % [rtol atol] for steady-state
|
||||
% problem
|
||||
tol_ts = [1.0e-3 1.0e-4]; % [rtol atol] for time stepping
|
||||
|
||||
loglevel = 1; % amount of diagnostic output (0
|
||||
% to 5)
|
||||
|
||||
refine_grid = 1; % 1 to enable refinement, 0 to
|
||||
% disable
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%% create the gas object %%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% This object will be used to evaluate all thermodynamic, kinetic,
|
||||
% and transport properties
|
||||
%
|
||||
gas = IdealGasMix(rxnmech, transport);
|
||||
|
||||
% set its state to that of the unburned gas at the burner
|
||||
set(gas,'T', tburner, 'P', p, 'X', comp);
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%% create the flow object %%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
f = AxisymmetricFlow(gas,'flow');
|
||||
|
||||
set(f, 'P', p, 'grid', initial_grid);
|
||||
set(f, 'tol', tol_ss, 'tol-time', tol_ts);
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%% create the burner %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% The burner is an Inlet object. The temperature, mass flux,
|
||||
% and composition (relative molar) may be specified.
|
||||
%
|
||||
burner = Inlet('burner');
|
||||
set(burner, 'T', tburner, 'MassFlux', mdot, 'X', comp);
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%%%% create the outlet %%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% The type of flame is determined by the object that terminates
|
||||
% the domain. An Outlet object imposes zero gradient boundary
|
||||
% conditions for the temperature and mass fractions, and zero
|
||||
% radial velocity and radial pressure gradient.
|
||||
%
|
||||
s = Outlet('out');
|
||||
|
||||
|
||||
%%%%%%%%%%%%% create the flame object %%%%%%%%%%%%
|
||||
%
|
||||
% Once the component parts have been created, they can be assembled
|
||||
% to create the flame object.
|
||||
%
|
||||
fl = flame(gas, burner, f, s);
|
||||
|
||||
% if the starting solution is to be read from a previously-saved
|
||||
% solution, uncomment this line and edit the file name and solution id.
|
||||
%restore(fl,'h2flame2.xml', 'energy')
|
||||
|
||||
|
||||
solve(fl, loglevel, refine_grid);
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%% enable the energy equation %%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% The energy equation will now be solved to compute the
|
||||
% temperature profile. We also tighten the grid refinement
|
||||
% criteria to get an accurate final solution.
|
||||
%
|
||||
|
||||
enableEnergy(f);
|
||||
setRefineCriteria(fl, 2, 200.0, 0.05, 0.1);
|
||||
solve(fl, 1, 1);
|
||||
saveSoln(fl,'h2fl.xml','energy',['solution with energy' ...
|
||||
' equation']);
|
||||
|
||||
|
||||
%%%%%%%%%% show statistics %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
writeStats(fl);
|
||||
elapsed = cputime - t0;
|
||||
e = sprintf('Elapsed CPU time: %10.4g',elapsed);
|
||||
disp(e);
|
||||
|
||||
|
||||
%%%%%%%%%% make plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
figure(1);
|
||||
subplot(2,2,1);
|
||||
plotSolution(fl, 'flow', 'T');
|
||||
title('Temperature [K]');
|
||||
subplot(2,2,2);
|
||||
plotSolution(fl, 'flow', 'u');
|
||||
title('Axial Velocity [m/s]');
|
||||
subplot(2,2,3);
|
||||
plotSolution(fl, 'flow', 'H2O');
|
||||
title('H2O Mass Fraction');
|
||||
subplot(2,2,4);
|
||||
plotSolution(fl, 'flow', 'O2');
|
||||
title('O2 Mass Fraction');
|
||||
|
||||
|
||||
131
Cantera/matlab/cantera/examples/flame2.m
Normal file
131
Cantera/matlab/cantera/examples/flame2.m
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% A burner-stabilized flat flame
|
||||
%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
t0 = cputime; % record the starting time
|
||||
|
||||
|
||||
% parameter values
|
||||
p = 0.05*oneatm; % pressure
|
||||
tburner = 373.0; % burner temperature
|
||||
mdot = 0.04; % kg/m^2/s
|
||||
|
||||
rxnmech = 'gri30.xml'; % reaction mechanism file
|
||||
transport = 'Mix'; % transport model
|
||||
comp = 'O2:0.21, N2:0.78, AR:0.01'; % premixed gas composition
|
||||
comp2 = 'C2H2:1'; % premixed gas composition
|
||||
|
||||
initial_grid = [0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2]; % m
|
||||
|
||||
tol_ss = [1.0e-7 1.0e-12]; % [rtol atol] for steady-state
|
||||
% problem
|
||||
tol_ts = [1.0e-3 1.0e-4]; % [rtol atol] for time stepping
|
||||
|
||||
loglevel = 1; % amount of diagnostic output (0
|
||||
% to 5)
|
||||
|
||||
refine_grid = 1; % 1 to enable refinement, 0 to
|
||||
% disable
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%% create the gas object %%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% This object will be used to evaluate all thermodynamic, kinetic,
|
||||
% and transport properties
|
||||
%
|
||||
gas = IdealGasMix(rxnmech, transport);
|
||||
|
||||
% set its state to that of the unburned gas at the burner
|
||||
set(gas,'T', tburner, 'P', p, 'X', comp);
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%% create the flow object %%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
f = AxisymmetricFlow(gas,'flow');
|
||||
|
||||
set(f, 'P', p, 'grid', initial_grid);
|
||||
set(f, 'tol', tol_ss, 'tol-time', tol_ts);
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%% create the burner %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% The burner is an Inlet object. The temperature, mass flux,
|
||||
% and composition (relative molar) may be specified.
|
||||
%
|
||||
burner = Inlet('burner');
|
||||
set(burner, 'T', tburner, 'MassFlux', mdot, 'X', comp);
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%%%% create the outlet %%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% The type of flame is determined by the object that terminates
|
||||
% the domain. An Outlet object imposes zero gradient boundary
|
||||
% conditions for the temperature and mass fractions, and zero
|
||||
% radial velocity and radial pressure gradient.
|
||||
%
|
||||
s = Inlet('right');
|
||||
set(s, 'T', tburner, 'MassFlux', 0.04, 'X', comp2);
|
||||
|
||||
%%%%%%%%%%%%% create the flame object %%%%%%%%%%%%
|
||||
%
|
||||
% Once the component parts have been created, they can be assembled
|
||||
% to create the flame object.
|
||||
%
|
||||
fl = flame(gas, burner, f, s);
|
||||
|
||||
% if the starting solution is to be read from a previously-saved
|
||||
% solution, uncomment this line and edit the file name and solution id.
|
||||
%restore(fl,'h2flame2.xml', 'energy')
|
||||
|
||||
|
||||
resid(fl, 'flow')
|
||||
solve(fl, 1, 1);
|
||||
|
||||
|
||||
%%%%%%%%%%%% enable the energy equation %%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% The energy equation will now be solved to compute the
|
||||
% temperature profile. We also tighten the grid refinement
|
||||
% criteria to get an accurate final solution.
|
||||
%
|
||||
|
||||
enableEnergy(f);
|
||||
resid(fl, 'flow')
|
||||
setRefineCriteria(fl, 2, 200.0, 0.1, 0.1);
|
||||
solve(fl, 1, 1);
|
||||
saveSoln(fl,'h2fl.xml','energy',['solution with energy' ...
|
||||
' equation']);
|
||||
|
||||
|
||||
%%%%%%%%%% show statistics %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
writeStats(fl);
|
||||
elapsed = cputime - t0;
|
||||
e = sprintf('Elapsed CPU time: %10.4g',elapsed);
|
||||
disp(e);
|
||||
|
||||
|
||||
%%%%%%%%%% make plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
figure(1);
|
||||
subplot(2,2,1);
|
||||
plotSolution(fl, 'flow', 'T');
|
||||
title('Temperature [K]');
|
||||
subplot(2,2,2);
|
||||
plotSolution(fl, 'flow', 'H2O');
|
||||
title('Axial Velocity [m/s]');
|
||||
subplot(2,2,3);
|
||||
plotSolution(fl, 'flow', 'O2');
|
||||
title('O2 Mass Fraction');
|
||||
subplot(2,2,4);
|
||||
plotSolution(fl, 'flow', 'H2');
|
||||
title('H2 Mass Fraction');
|
||||
%subplot(2,2,4);
|
||||
%plotSolution(fl, 'flow', 'V');
|
||||
%title('V');
|
||||
|
||||
|
||||
Loading…
Add table
Reference in a new issue