cantera/samples/matlab/ignite3.m
Ray Speth 2528df0f75 Reorganized source tree structure
These changes make it unnecessary to copy header files around during
the build process, which tends to confuse IDEs and debuggers. The
headers which comprise Cantera's external C++ interface are now in
the 'include' directory.

All of the samples and demos are now in the 'samples' subdirectory.
2012-02-12 02:27:14 +00:00

40 lines
973 B
Matlab
Executable file

function ignite3(gas)
% IGNITE3 Solves the same ignition problem as 'ignite', except
% that the volume is held fixed, and function conuv is used
% instead of reactor.
%
help ignite3
if nargin == 0 | ~isa(gas,'GasMix')
gas = idealgasmix('gri30.xml');
end
mw = molecularWeights(gas);
nsp = nSpecies(gas);
set(gas,'T',1001.0,'P',oneatm,'X','H2:2,O2:1,N2:4');
y0 = [temperature(gas)
massFractions(gas)];
tel = [0 0.001];
options = odeset('RelTol',1.e-5,'AbsTol',1.e-12,'Stats','on');
t0 = cputime;
out = ode15s(@conuv,tel,y0,options,gas,mw);
disp(['CPU time = ' num2str(cputime - t0)]);
if nargout == 0
% plot the temperature and OH mass fractions.
figure(1);
plot(out.x,out.y(1,:));
xlabel('time');
ylabel('Temperature');
title(['Final T = ' num2str(out.y(1,end)) ' K']);
figure(2);
ioh = speciesIndex(gas,'OH');
plot(out.x,out.y(1+ioh,:));
xlabel('time');
ylabel('Mass Fraction');
title('OH Mass Fraction');
end