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.globalkvDABcafncolptorder%%% 2 A --> B, r = k c_A^order%%% transient behavior in a dispersed plug flow reactor% steady-state profile in a PFR% jbr, 10/20/01%%k=1/2;v=1/2;D=0.01;caf=1;length=1;ncolpt=50;order=2;[z,A,B,Q]=colloc(ncolpt-2,'left','right');%x0=ones(ncolpt,1);%[x, fval, info] = fsolve('pfrcol',x0);%infotsteps=linspace(0,2.5,11);% initial condition, zero conc. in tubey0=zeros(ncolpt,1);ydot0=zeros(ncolpt,1);[tout,y]=ode15i(@pfrtran,tsteps,y0,ydot0);table=[zy'];% %% % calculate the steady-state PFR for this problem% %% function res = pfr(t, x, xdot)% global order k v% ca = x;% dcadz = xdot;% Ra = -2*k*ca^order;% res = dcadz - Ra/v;% end%function% x0 =caf;% xdot0 = - pfr(x0,0,0);% [tout,x] = ode15i (@pfr, z, x0, xdot0);save-asciidispersedpfrtran.dattable;if(~strcmp(getenv('OMIT_PLOTS'),'true'))% PLOTTINGplot(table(:,1),table(:,2:12));% TITLEend% PLOTTING

pfrcol.m

1
2
3
4
5
6
7
8
9
10
11
12
13

functionres =pfrcol(x)globalvDABkcafncolptorder%% express the diff eq at every collocation point%first=A*x;Ra=-2*k*(x.^order);second=B*x;res=-v*first+D*second+Ra;% write over the first and last points with the% boundary conditionsres(1)=v*x(1)-D*first(1)-v*caf;res(ncolpt)=first(ncolpt);