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.globalk1K1k2K2RTPNBf% Example in material balance chapter.% Data are:% NBf = 60e3 mol/hr% R = 0.08205 lit atm/mol K% T = 1033 K% P = 1 atm% k1 = 7e5 lit/mol hr% k2 = 4e5 lit/mol hr% K1 = 0.31% K2 = 0.48% Reactor volume: 0 to 1600 litNBf=60e3;R=0.08205;T=1033;P=1;k1=7e5;k2=4e5;K1=0.31;K2=0.48;x0=[0;0];vout=linspace(0,1600,50)';opts=odeset('AbsTol',sqrt(eps),'RelTol',sqrt(eps));[tsolver,x]=ode15s(@benzene_pyrol_rhs,vout,x0,opts);conv=(2*x(:,1)+x(:,2))/NBf;yB=(NBf-2*x(:,1)-x(:,2))/NBf;yD=(x(:,1)-x(:,2))/NBf;yT=(x(:,2))/NBf;yH=(x(:,1)+x(:,2))/NBf;data=[voutconvyByDyTyH];aux_data=[403.25.50403.25.50;403.250.00.0.50];savebenz_pyrol.datdataaux_data;if(~strcmp(getenv('OMIT_PLOTS'),'true'))% PLOTTINGsubplot(2,1,1);plot(data(:,1),data(:,2));% TITLEsubplot(2,1,2);plot(data(:,1),data(:,3:6));% TITLEend% PLOTTING