Sei sulla pagina 1di 4

01/07/20 11:23 C:\Users\User\D...\reactor2_nheptane.

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);

% set the initial conditions

% find nheptane, nitrogen, and oxygen indices


inc7h16 = speciesIndex(gas,'nC7H16');
io2 = speciesIndex(gas,'O2');
in2 = speciesIndex(gas,'N2');

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

% create a reactor, and insert the gas


r = IdealGasReactor(gas);

% Set its volume to 10 cm^3


V0= 3.33e-5;
setInitialVolume(r,V0);

% We need to have heat loss to see the oscillations. Create a


% reservoir to represent the environment, and initialize its
% temperature to the reactor temperature.
env = Reservoir(gas);

% Create a heat-conducting wall between the reactor and the


% environment. Set its area, and its overall heat transfer
% coefficient. Larger U causes the reactor to be closer to isothermal.
% If U is too small, the gas ignites, and the temperature spikes and
% stays high.
w = Wall;
install(w, r, env);
setArea(w, 1.0);
setHeatTransferCoeff(w, 0.02);

% Connect the upstream reservoir to the reactor with a mass flow


% controller (constant mdot). Set the mass flow rate to 1.25 sccm.
sccm = 1.25;

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);

% now create a downstream reservoir to exhaust into.


downstream = Reservoir(gas);

% connect the reactor to the downstream reservoir with a valve, and


% set the coefficient sufficiently large to keep the reactor pressure
% close to the downstream pressure of 60 Torr.
v = Valve;
install(v, r, downstream);
setValveCoeff(v, 1.0e-9);

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

% create a reactor network and insert the reactor


network = ReactorNet({r});

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)

%Heatr_Release= intEnergy_mass(gas) - IE_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'});

MF_P = moleFraction(gas,{'H2','H','O','O2','OH','H2O','HO2', ...


'H2O2','N','NH','NH2','NH3','NNH','NO','NO2','N2O','HNO','N2'});

%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

Potrebbero piacerti anche