Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
45 views2 pages

01/07/20 11:24 C:/Users/User/Desktop/Ma... /reactor2.m 1 of 2

This document describes a function called reactor2 that simulates a zero-dimensional adiabatic constant volume reactor using a Reactor class. The function initializes conditions, runs the simulation over time, records temperature and mole fractions, and plots the results.

Uploaded by

farouk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views2 pages

01/07/20 11:24 C:/Users/User/Desktop/Ma... /reactor2.m 1 of 2

This document describes a function called reactor2 that simulates a zero-dimensional adiabatic constant volume reactor using a Reactor class. The function initializes conditions, runs the simulation over time, records temperature and mole fractions, and plots the results.

Uploaded by

farouk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

01/07/20 11:24 C:\Users\User\Desktop\Ma...\reactor2.

m 1 of 2

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.
%

help reactor2

if nargin == 1
gas = g;
else
gas = GRI30;
end

nsp = nSpecies(gas);

% set the initial conditions


set(gas,'T',1001.0,'P',oneatm,'X','H2:2,O2:1,N2:4');
gas()
% create a reactor, and insert the gas
r = IdealGasReactor(gas);

% create a reactor network and insert the reactor


network = ReactorNet({r});

t = 0;
dt = 1.0e-5;
t0 = cputime;
for n = 1:100
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()

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)');
01/07/20 11:24 C:\Users\User\Desktop\Ma...\reactor2.m 2 of 2

subplot(2,2,4)
plot(tim,x(:,3));
xlabel('Time (s)');
ylabel('H2 Mole Fraction (K)');
clear all
cleanup

You might also like