Vous êtes sur la page 1sur 16

Dise no e Ingeniera de Procesos

Dr. Martn Rivera Toledo


Tarea 2:
Aplicaci on del enfoque moduar secuencial,
simulaci on a traves de Aspen-Plus y MATLAB
Francisco Jose Guerra Mill an
Adelwart Struck Garza
Felipe Suberbie Rocha
Mexico D.F., 18 de septiembre de 2008.
Tarea 2:
Aplicaci on del enfoque moduar secuencial, simulaci on a
traves de Aspen-Plus y MATLAB
Problema 1. Desarrolle en MATLAB la simulacion en regimen permanente
del proceso de la Figura 1 con el enfoque modular secuencial y reporte:
a. La composicion de todas las corrientes y el n umero de iteraciones necesa-
rias para alcanzar la convergencia con los metodos de sustitucion sucesiva,
Wegstein, Broyden y la rutina de fsolve de MATLAB.
b. Como se veran afectados los resultados si se sustituye el CSTR por un
PFR?
Utilizando el codigo de MATLAB que se muestra en el Apendice A se obtienen
los resultados de la Tabla 1. Al sustituir el CSTR por un PFR, la corriente S5
tiene un mayor ujo molar tanto de A como de B. Por otra parte, en la corriente
S7 disminuye el ujo molar de ambas especies.
Problema 2. Simule el proceso de la Figura 2 de la planta de separacion de
Propano-Propileno en Aspen-Plus y reporte en una tabla las condiciones de ope-
racion de cada equipo para satisfacer las especicaciones de los productos.
Con ayuda de Aspen-Plus se construyo el diagrama de la Figura 3. Los resul-
tados de las corrientes se muestran en las Tablas 2 a 5. Las corrientes S26 y S28
(Tabla 5) cumplen con las especicaciones de dise no. La corriente S26 contiene
un 99 % de Propileno y la corriente S28 un 95 % de Propano.
F. J. Guerra, A. Struck, F. Suberbie 1
Universidad Iberoamericana Dise no e Ingeniera de Procesos, Oto no 2008
Figura 1: Esquema para el Problema 1.
Figura 2: Esquema para el Problema 2.
F. J. Guerra, A. Struck, F. Suberbie 2
Universidad Iberoamericana Dise no e Ingeniera de Procesos, Oto no 2008
T
a
b
l
a
1
:
T
a
b
l
a
d
e
R
e
s
u
l
t
a
d
o
s
p
a
r
a
e
l
P
r
o
b
l
e
m
a
1
.
M
e
t
o
d
o
I
t
e
r
a
c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LAB utilizados.
%% Dise\~no e Ingenier\ia de Procesos
% Dr. Mart\in Rivera Toledo
% Oto\~no 2008
%
% Francisco Jos\e Guerra
% Adelwart Struck
% Felipe Suberbie
% 11.09.08
%% Inicio del archivo DIPT2P1.m
function DIPT2P1
clc; clear all;
global S1 k1 k2 theta Kflash alphadiv
global iter
%% Corriente de Corte
S1 = [0.9 0.1]; % lbmol/s
%% Flash
P = 2; % atm
T = 735; % R
Pa_sat = 10^(4.665-3438/T);
Pb_sat = 10^(4.421-2816/T);
Kflash = [Pa_sat/P Pb_sat/P];
%% CSTR
k1 = 0.08; % s-1
k2 = 0.03; % s-1
theta = 15; % s
%% Divisor
alphadiv = 0.5;
%% OptimSet
iter = 0;
tol = 1e-6; % tolerancia
F. J. Guerra, A. Struck, F. Suberbie 9
Universidad Iberoamericana Dise no e Ingeniera de Procesos, Oto no 2008
maxiter = 1000; % m\aximo n\umero de iteraciones
S2 = [S1]; % conjunto de corrientes de corte
x = [0.9 0.1]; % CSTR
%x = [0.9 0.6]; % PFR
%% M\etodos
[xs,iter,error] = broyden2(@T2P1,x,tol,maxiter)
%[xs,iter,error] = sucesiva(@T2P1,x,tol,maxiter)
%[xs,iter,error] = wegstein(@T2P1,x,tol,maxiter)
%options = optimset(display,iter);
%[xs,fun,flag] = fsolve(@T2P1,x,options)
%% Modular Secuencial
S2 = xs(1:length(S1));
[S3] = cstr(S2,k1,k2,theta);
%[S3] = pfr(S2,k1,k2,theta);
[S4,S7] = flash(S3,Kflash);
[S5,S6] = divider2(S4,alphadiv);
[S2] = mixer2(S1,S6);
%% Iter
iter
ss = [S1,S2,S3,S4,S5,S6,S7]
%% Inicio del archivo T2P1.m
function S2r = T2P1(S2)
global S1 k1 k2 theta Kflash alphadiv
global iter
S3 = S2(1:length(S1));
[S3] = cstr(S2,k1,k2,theta)
%[S3] = pfr(S2,k1,k2,theta);
[S4,S7] = flash(S3,Kflash);
[S5,S6] = divider2(S4,alphadiv);
[S2r] = mixer2(S1,S6);
xs = [S2r];
%xs = xs - S2; % Para Broyden, Newton, fsolve y Quasi-Newton
%% Fin del archivo T2P1.m
F. J. Guerra, A. Struck, F. Suberbie 10
Universidad Iberoamericana Dise no e Ingeniera de Procesos, Oto no 2008
%% Inicio del archivo cstr.m
function S = cstr(F,k1cstr,k2cstr,thetacstr)
global F k1cstr k2cstr thetacstr Fa0 Fb0
global iter
options = optimset(display,iter);
Fa0 = F(1);
Fb0 = F(2);
x0 = [Fa0 Fb0];
[x,fun,flag] = fsolve(@cstrrev,x0,options);
Fa=x(1); Fb=x(2);
S = [Fa Fb];
function fx = cstrrev(x)
global F k1cstr k2cstr thetacstr Fa0 Fb0
global iter
Fa=x(1); Fb=x(2);
% reaction rates
fx(1) = Fa0 - Fa*(1 + k1cstr*thetacstr) + k2cstr*Fb*thetacstr;
fx(2) = Fb0 - Fb*(1 + k2cstr*thetacstr) + k1cstr*Fa*thetacstr;
% function S = cstr(F,k1,k2,theta)
% Fa0 = F(1);
% Fb0 = F(2);
% Fo = [Fa0; Fb0];
% A = [1+k1*theta, -k2*theta;-k1*theta, 1+k2*theta];
% F1 = inv(A)*Fo;
% Fa = F1(1); Fb = F1(2);
% S = [Fa Fb];
% function S = cstr(F,k1,k2,theta)
% Fa0 = F(1);
% Fb0 = F(2);
% Fa = ((Fa0+Fb0)*k2*theta+Fa0)/((k1+k2)*theta+1);
% Fb = ((Fa0+Fb0)*k1*theta+Fb0)/((k1+k2)*theta+1);
% S = [Fa Fb];
%% Fin del archivo cstr.m
%% Inicio del archivo divider2.m
F. J. Guerra, A. Struck, F. Suberbie 11
Universidad Iberoamericana Dise no e Ingeniera de Procesos, Oto no 2008
% Rutina para un divisor de corrientes
function [S1,S2] = divider2(F,alpha)
%global iter
S1 = F.*alpha;
S2 = F-S1;
%% Fin del archivo divider2.m
%% Inicio del archivo flash.m
% Archivo para resolver un flash isot\ermico con el m\etodo de Newton
% [vfk,error,kSl,Sv]=flash([500 600 900],[2.523 1.57 0.032915])
function [Li,Vi]=flash(F,K)
%global iter
% function [vfk,error,k,Li,Vi]=flash(F,K)
z = F/sum(F); % fracciones de las especies de alimentaci\on
vfk = 0.5; % valor inicial para la relaci\on V/F
tol = 1e-6; % tolerancia
tau = 100; % m\aximo n\umero de iteraciones
%
error = 1.0; % inicializaci\on del error
k = 0; % contrador del n\umero de iteraciones
%
while (error > tol && k < tau)
f = 0; df = 0; % inicializando las funciones para la suma
for i = 1:length(K)
f = f + z(i)*(1 - K(i) )/(1 + vfk*(K(i)-1) );
df = df + z(i)*(1-K(i))^2/(1+vfk*(K(i)-1))^2;
end
vfk1 = vfk - f/df; % expresi\on de convergencia para el m\etodo de Newton
error = abs((vfk1-vfk)/vfk1); % c\alculo del error
k = k+1; % incremento del n\umero de iteraciones
vfk = vfk1; % reasignaci\on de vf^k con vf^(k+1)
end
if vfk < 0 || vfk > 1,
fprintf(=== NO CONVERGE EL FLASH V/F = %10.5 \n, vfk)
else
end
V = vfk.*sum(F);
F. J. Guerra, A. Struck, F. Suberbie 12
Universidad Iberoamericana Dise no e Ingeniera de Procesos, Oto no 2008
L = sum(F)-V;
xi = z./(1+vfk.*(K-1));
yi = K.*xi;
Vi = V*yi;
Li = L*xi;
%% Fin del archivo flash.m
%% Inicio del archivo mixer2.m
% Rutina para un mezclador de corrientes
function S = mixer2(F1,F2)
%global iter
S = F1+F2;
%% Fin del archivo mixer2.m
%% Inicio del archivo pfr.m
function S = pfr(F,k1,k2,theta)
global F k1 k2 theta Fa0 Fb0
global iter
Fa0 = F(1);
Fb0 = F(2);
tint = [0, theta]; % intervalo de integraci\on
Cf = [Fa0 Fb0];
[F0,x] = ode15s(@pfrrev,tint,Cf); % Cf = condici\on de frontera
Fa = x(:,1); Fb = x(:,2);
S = [Fa(end) Fb(end)];
% inicia la rutuna del pfr
% ======================
function fx = pfrrev(theta,x)
% ======================
global F k1 k2 theta Fa0 Fb0
global iter
Fa = x(1); Fb = x(2); % reasignaci\on
fx(1) = -k1*Fa + k2*(Fa0+Fb0 - Fa);
fx(2) = -(k1*Fa + k2)*Fa + k2*(Fa0+Fb0);
fx = fx;
F. J. Guerra, A. Struck, F. Suberbie 13
Universidad Iberoamericana Dise no e Ingeniera de Procesos, Oto no 2008
%% Fin del archivo pfr.m
%% Inicio M\etodos
%% inicio del archivo broyden2.m
% martin rivera toledo
% Septiembre de 2007
% codigo para obtener las raices de un conjunto de ecuaciones
% algebraicas no lineales a traves del metodo de broyden
% descrito en el libro de Westerberg, Winter, Motard & Hutchison(1979)
% process flowsheeting, cambridge university press, pp. 64-65
% function [xk,it,error]=broyden2(fun,xk,tol,max1)
% input - fun rutina donde se encuentran declaradas las variables
% - xk estimado inicial para la raiz
% - tolerancia
% - maximo numero de iteraciones
% output - xk raiz solucion si error <= tol
% - it numero total de iteraciones
% - error relativo para xk & xk1
%----------------------------------------------------
function [xk,it,error]=broyden2(fun,xk,tol,max1)
%----------------------------------------------------
n=length(xk); % numero de elementos del vector xk
ek=zeros(n,1); it=0; % inicializacion de vector de funciones e
Hk1=eye(n); % iteraciones y matriz identidad
ek=feval(fun,xk); ek=ek; xk=xk;
error = norm(ek*ek);
for i=1:max1
if (error>tol)
dxk1 = -Hk1*ek;
xk1 = xk + dxk1;
ek1 = feval(fun,xk1); ek1=ek1;
dek1 = ek1 - ek;
vk1 = xk1 - xk;
denH = vk1*Hk1*dek1;
Hk2 = Hk1 - ( Hk1*dek1-dxk1 )*(vk1*Hk1)/denH;
error = abs((norm(xk1)-norm(xk))/norm(xk1));
it = it + 1
Hk1 = Hk2;
xk = xk1;
ek = ek1;
else
break
end
fprintf(iteracion:%3i error=%10.5e\n,it,error)
F. J. Guerra, A. Struck, F. Suberbie 14
Universidad Iberoamericana Dise no e Ingeniera de Procesos, Oto no 2008
end
xk=xk;
%% fin del archivo broyden2.m
%% inicio del archivo sucesiva.m
% algoritmo para calculo de las raices de un sistema de ecuaciones
% algebraico no lineal por el metodo de sustitucion sucesiva
function [P,iter,relerr]=sucesiva(G,P,delta,max1)
% input -G es el sistema de ecuaciones algebraicas en el archivo de nombre G.m
% -P es el estimado inicial para la busqueda de la solucion
% -delta es el limite de error
% -max1 es el numero maximo de iteraciones
% output -P es la aproximacion a la solucion para el sistema de ecuaciones
% -iter es el numero de iteraciones requerido para alcanzar la
% convergencia
N=length(P); % calculo del numero de elementos del vector
for k=1:max1
X=P; % X es la k-esima aproximacion a la solucion
for j=1:N
A=feval(G,X);% asignacion de g(x)con x(k+1)
X(j)=A(j);
end
err=abs(norm(X-P));
relerr=err/(norm(X)+eps);
P=X;
iter=k;
if(err<delta)|(relerr<delta)
break
end
fprintf(iteracion:%3i error=%10.5e\n,iter,relerr)
end
%% fin del archivo sucesiva.m
%% start of wegstein.m file
% this function was written by w. fred ramirez
% and it was modified by martin rivera toledo
% universidad iberoamericana ciudad de mexico
% september 2007
%
%
%WEGSTEIN Find a zero of a nonlinear equation of one variable
% using the wegstein algorithm. Func is the name of an
% M-file that contains a real-valued function of a
% single real variable, and x is the initial guess.
% Note that a bad formulation of the problem may cause
% divergence.
F. J. Guerra, A. Struck, F. Suberbie 15
Universidad Iberoamericana Dise no e Ingeniera de Procesos, Oto no 2008
% An optional third argument sets the tolerance for the
% convergence. The presence of an optional fourth
% argument specifies the maximum iteration number.
function [x3,iter,error] = wegstein(Func,x,tol,max)
global iter
%
% pre-processing, set default tolerance and maximum iteration
% number.
%
if nargin<3, tol=1e-7; max=1000; end
if nargin==3, max=1000; end
t=[1:max+1];
%
% initialization
%
x1 = x;
x2 = feval(Func,x1);
%
% start wegstein algorithm
%
for i=1:max
g2=feval(Func,x2); g1=feval(Func,x1);
for j=1:length(x)
x3(j) =(x1(j)*g2(j)-x2(j)*g1(j))...
/(x1(j)-x2(j)-g1(j)+g2(j));
end
error = abs(norm(x3)-norm(x2));
relerr=error/(norm(x3)+eps);
if(error<tol)|(relerr<tol)
break;
end
iter = i;
t = [1:iter+1];
fprintf(iteracion:%3i error=%10.5e\n,iter,relerr)
x1 = x2;
x2 = x3;
fprintf(iteracion:%3i error=%10.5e\n,iter,relerr)
end
%% end of wegstein.m file
%% Fin M\etodos
%% Fin del archivo DIPT2P1.m
F. J. Guerra, A. Struck, F. Suberbie 16

Vous aimerez peut-être aussi