Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
m 1 of 4
function reactor2(g)
% REACTOR2 Zero-dimensional kinetics: adiabatic, constant volume.
%
% This example illustrates how to use class 'Reactor' for
% zero-dimensional kinetics simulations. Here the parameters are
% set so that the reactor is adiabatic and constant volume.
%
clc;
help reactor2
if nargin == 1
gas = g;
else
gas = IdealGasMix('nheptane.xml');
end
nsp = nSpecies(gas);
phi = 0.3;
x = zeros(nsp,1);
x(inc7h16,1) = phi;
x(io2,1) = 11;
x(in2,1) = 41.36;
%set(gas,'Temperature',300.0,'Pressure',101325.0,'MoleFractions', x);
% from periodic_ctr.m
% create an upstream reservoir that will supply the reactor. The
% temperature, pressure, and composition of the upstream reservoir are
% set to those of the 'gas' object at the time the reservoir is
% created
upstream = Reservoir(gas);
% Now set the gas to the initial temperature of the reactor, and create
% the reactor object.
set(gas,'T',750.0,'P',3039750,'MoleFractions', x);
gas()
%IE_R= intEnergy_mass(gas);
H_R= enthalpy_mass(gas);
MW_Reactants = molecularWeights(gas);
H_RT_Reactants=enthalpies_RT(gas);
01/07/20 11:23 C:\Users\User\D...\reactor2_nheptane.m 2 of 4
OneAtm = 1.01325e5;
vdot = sccm * 1.0e-6/60.0 * ((OneAtm / pressure(gas)) * ( temperature(gas) /
273.15)); % m^3/s
mdot = density(gas) * vdot; % kg/s
mfc = MassFlowController;
install(mfc, upstream, r);
setMassFlowRate(mfc, mdot);
MassFraction_R=massFractions(r);
%N=2000;
%mdot= v0*1.18*N/120; % it gives a problem
%setInitialVolume(r,v0);
%setMassFlowRate(r,mdot);% it gives a problem
01/07/20 11:23 C:\Users\User\D...\reactor2_nheptane.m 3 of 4
t = 0;
dt = 1.0e-5;
t0 = cputime;
for n = 1:600
t = t + dt;
advance(network, t);
tim(n) = time(network);
temp(n) = temperature(r);
x(n,1:3) = moleFraction(gas,{'OH','H','H2'});
end
disp(['CPU time = ' num2str(cputime - t0)]);
gas()
pause
volume(r);
'volume',volume(r)
'pressure',pressure(r)
'temperature',temperature(r)
H_P=enthalpy_mass(gas);
Heat_Release= H_P - H_R;
'Heat_Release',Heat_Release
MW_Products = molecularWeights(gas);
H_RT_Products=enthalpies_RT(gas);
xlswrite('HRT_Prod,HRTReac,MW_Prod,MW_Reac.xlsx',[H_RT_Products,H_RT_Reactants,
MW_Products,MW_Reactants]);
%MassFraction_P=massFractions(r);
%moleFraction(gas,{'OH','H','H2'});
%MassFraction_P=massFraction(r,{'H2','H','O','O2','OH','H2O','HO2', ...
% 'H2O2','N','NH','NH2','NH3','NNH','NO','NO2','N2O','HNO','N2'});
%xlswrite('MassFraction_P.xlsx',[MassFraction_P]);
xlswrite('MoleFraction_P.xlsx',[MF_P]);
gas()
01/07/20 11:23 C:\Users\User\D...\reactor2_nheptane.m 4 of 4
clf;
subplot(2,2,1);
plot(tim,temp);
xlabel('Time (s)');
ylabel('Temperature (K)');
subplot(2,2,2)
plot(tim,x(:,1));
xlabel('Time (s)');
ylabel('OH Mole Fraction (K)');
subplot(2,2,3)
plot(tim,x(:,2));
xlabel('Time (s)');
ylabel('H Mole Fraction (K)');
subplot(2,2,4)
plot(tim,x(:,3));
xlabel('Time (s)');
ylabel('H2 Mole Fraction (K)');
clear all
cleanup