Text of the GNU GPL.
%% Copyright (C) 2001, James B. Rawlings and John G. Ekerdt %% %% This program is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public License as %% published by the Free Software Foundation; either version 2, or (at %% your option) any later version. %% %% This program is distributed in the hope that it will be useful, but %% WITHOUT ANY WARRANTY; without even the implied warranty of %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU %% General Public License for more details. %% %% You should have received a copy of the GNU General Public License %% along with this program; see the file COPYING. If not, write to %% the Free Software Foundation, 59 Temple Place - Suite 330, Boston, %% MA 02111-1307, USA. % % This program solves the ethane pyrolysis text example with NO inhibitions. % % It was last edited 1/2/2002 global k P R1 T %E in Joules, mass in grams, T in Kelvin, time in sec, volume in cm3 Components_1 = [' C2H6 = 1,',' NO = 2,',' C2H5 = 3,',' HNO = 4']; Components_2 = [' H = 5,',' C2H4 = 6,', ' H2 = 7,']; Ao = [1e14,3e14,3.4e12,1e12,1e13,1e12]'; Ea = [217600,165300,28500,0,200800,0]'; nu = [-1,-1,1,1,0,0,0 0,0,-1,0,1,1,0 -1,0,1,0,-1,0,1 0,-1,0,1,-1,0,0 0,1,0,-1,1,0,0 1,1,-1,-1,0,0,0]; R = 8.3144; %(J/gmole-K) R1 = 82.057; %cc-atm/gmole-K T = 1050; %K P = 1.0; % atm EXP = exp(-Ea/(R*T)); k = Ao.*EXP; y1f = 0.95; y2f = 0.05; C1f = y1f*P/(R1*T); %gmole/cm3 C2f = y2f*P/(R1*T); %gmole/cm3 Qf = 600.0; %cc/sec N1f = C1f*Qf; %gmole/sec N2f = C2f*Qf; Initial = [N1f,N2f,0,0,0,0,0]'; v = linspace(0, 1500, 200)'; opts = odeset ('AbsTol', sqrt (eps), 'RelTol', sqrt (eps)); [tsolver, solution] = ode15s(@rxrate,v,Initial,opts); answer = [v solution]; %Components_1 = [' C2H6 = 1,',' NO = 2,',' C2H5 = 3,',' HNO = 4']; %Components_2 = [' H = 5,',' C2H4 = 6,', ' H2 = 7,']; plot (answer(:,1),[answer(:,2),answer(:,7),answer(:,3)]); title ('Figure 4.22')
function dNdv = rxrate(v,x) global k P R1 T N1 = x(1); N2 = x(2); N3 = x(3); N4 = x(4); N5 = x(5); N6 = x(6); N7 = x(7); Ntot = N1 + N2 + N3 + N4 + N5 + N6 + N7; Ctot = P/(R1*T); C1 = (N1/Ntot)*Ctot; C2 = (N2/Ntot)*Ctot; C3 = (N3/Ntot)*Ctot; C4 = (N4/Ntot)*Ctot; C5 = (N5/Ntot)*Ctot; r1 = k(1)*C1*C2; r2 = k(2)*C3; r3 = k(3)*C1*C5; r4 = k(4)*C2*C5; r5 = k(5)*C4; r6 = k(6)*C3*C4; dNdv = zeros (7, 1); dNdv(1) = -r1 - r3 + r6; dNdv(2) = -r1 -r4 + r5 +r6; dNdv(3) = r1 -r2 + r3 -r6; dNdv(4) = r1 +r4 -r5 -r6; dNdv(5) = r2 -r3 -r4 + r5; dNdv(6) = r2; dNdv(7) = r3;