Figure 6.36 (page 323):

Reactor temperature versus length for different feed temperatures.

Code for Figure 6.36

Text of the GNU GPL.

main.m

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

global  E km Tm Gamma beta Rg Pf Nf Ta Ac Tf
%%
%% o-xylene + 3 O_2  -->  phthalic anhydride + 3 H_2O
%%
%%
%% parameters adapted from Welsenaere and Froment, 1970.
%%
%%
%% jbr, 9/21/01
%% repaired by jbr, 1/2/10
%%
%% units: m, kg, kmol, sec
%%

R     = 1.25e-2; %tube radius, m
Ac    = pi*R*R;  % tube cross-section, m^2
Qrho  = 0.0026371; % Ac*4684/3600 mass flow, kg/sec, constant
Pf    = 1.01e2;    % feed pressure, kN/m^2, i.e. 1.0 atm
Mwf   = 0.98*(0.79*28+0.21*32)+0.02*106.17; % mol wt feed;
				% 98%air, 2% o-xylene, kg/kmol
Tf    = 625; % feed temperature, K
Rg    = 8.314;  % gas constant, kJ/(K kmol)
%Nf    = Qrho*Mwf;  bug here; repaired below; adjust km and delH as well
Nf    = Qrho/Mwf;  % molar flowrate, kmol/sec, also constant
E     = 13636.; % activation energy, K
Tm    = 625.; % mean temperature,  K
%km    = 1922.6;  % 1/sec % adjusted on 1/2/10
km    = 2.0822;  % 1/sec
Ta    = 625; % coolant temperature, K
Cp    = 0.992; % specific heat of mixture, kJ/kg K, assumed constant
%delH  = -1.361e3; % kJ/kmol  % adjusted on 1/2/10
delH  = -1.284e6; % -3.07e5*4.184 heat of reaction, kJ/kmol, assumed constant
U     = 0.373; % heat transfer coefficient, kJ/(m^2 sec K)
beta  = delH*Ac/(Qrho*Cp);  % heat of reaction parameter, 
Gamma = 2*pi*R*U/(Qrho*Cp); % heat transfer parameter, 
l     = 1.5; % length of tube, m


npts = 200;
z    = linspace(0,l,npts)';
yxfeed = [0.019];
Nxf  = yxfeed*Nf;
%Tfeed = [615 625 631 635];
% adjust the temperatures in the repaired file
Tfeed = [615 620 625 630];
nfeed = length(Tfeed);
yx = zeros(npts,nfeed);
T  = zeros(npts,nfeed);
for i = 1: nfeed
  Tf = Tfeed(i);
  x0 = [Nxf; Tf];
  opts = odeset ('AbsTol', sqrt (eps), 'RelTol', sqrt (eps));
  [tsolver, x] = ode15s (@pfr, z, x0,opts);
  yx(:,i) = x(:,1);
  T(:,i)  = x(:,2);
end
table = [z yx T];

subplot(2,1,1);
plot (z, yx);
title ('Figure 6.36')

subplot(2,1,2);
plot (z, T);
title ('Figure 6.36')

pfr.m

function rhs = pfr(t, x)
  global  E km Tm Gamma beta Rg Pf Nf Ta Ac Tf
  Nx = x(1);
  T  = x(2);
  Q  = Nf/(Pf/(Rg*T));
  cx = Nx/Q;
  k  = km*exp(-E*(1/T-1/Tm));
  rate = k*cx;
  rhs = [-rate*Ac; -beta*rate + Gamma*(Ta-T)];