matlab nonisothermalcstr

52
  Reator CSTR Não-Isotérmico Felix Farias http://felixfarias.googlepages.com/

Upload: f4uth4339

Post on 21-Jun-2015

302 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

Felix Farias

http://felixfarias.googlepages.com/

Page 2: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

Baseado no exemplo nonisothermal CSTR:

Process Modeling, Simulation and Control for Chemical Engineers.

Luyben, W.L. (1990)

Page 3: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

Uma reação exotérmica e irreversível é realizada em um reator CSTR

perfeitamente agitado. A reação é de primeira ordem e possui um calor de

reação dado por λ.

k

AB

Page 4: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

Para remover o calor da reação uma camisa de resfriamento é utilizada. Água

fria entra na camisa a uma vazão volumétrica FJ e com temperatura TJ0.

A massa das paredes metálicas é desprezível, sendo assim a inércia

térmica do metal não é considerada.

Page 5: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

Duas variáveis devem ser controladas no sistema:

● volume de líquido dentro do reator, através da vazão em uma válvula na

saída● temperatura do processo, através da vazão de entrada do fluido refrigerante.

Page 6: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

F0

CA0

T0

FC

A

TF

J

TJ0

FJ

TJ

control

control

T

V

Page 7: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

Assumindo uma temperatura uniforme da camisa, a transferência de calor entre a

temperatura do processo T e a a temperatura da água de resfriamento TJ e

coeficiente global U é dada por:

Q=U AH T−T f

Page 8: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

O Processo pode ser definido pelas seguintes Equações Diferenciais

Ordinárias:

Page 9: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

dVdt

=F 0−F

d V C A

dt=F 0 C A0−F C A−V k C A

Balanços de Massa:

Page 10: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

d V Tdt

=F0 T 0−F T−V k C A

CP

−U AH

C P

T−T J

d T J

dt=

F J T J0−T J

V J

U AH

J V J C J

T−T J

Balanços de Energia:

Page 11: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

k= e−E /RT

F=40−10 48−V

F J=49.9−KC 600−T

Equações Algébricas:

CINÉTICA

CONTROLE NIVEL

CONTROLE TEMPERATURA

Q=U AH T−T f TROCA TÉRMICA

Page 12: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

Dados:

%alimentacaoCA0=0.5;F0=40;T0=530;%fluido refrigeranteTJ0=530;

Page 13: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

Condições iniciais:

% variáveis independentes do sistemaV=48;CA=0.245;T=600;TJ=594.59;

Page 14: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

Condições iniciais:

% variaveis manipuladas em malha abertaFJ=49.9;F=40;

Page 15: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

Chamar o editor de textos do matlab:

% edit

Page 16: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

Criar função e salvar em arquivo .m do Matlab (com o mesmo nome):

function saida=cstr_fb

Page 17: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

% Condições iniciais CA=0.245; T=600; TJ=594.59; V=48; TIME=0; VC=V*CA; VT=V*T;

Page 18: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

% Valores dos parâmetros TJ0=530; F0=40; T0=530; CA0=0.5; KC=4; DELTA=0.01; TPRINT=0; linha=1;

Page 19: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

% LOOP principal

while(TIME<16.1)...end

Page 20: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

% Malha aberta FJ=49.9; F=40;

Page 21: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

% Equacoes algebricas:% Taxa de reação K=7.08E10*exp(-30000./(1.99*T));% Calor trocado entre reator e jaqueta Q=150.*250.*(T-TJ);

Page 22: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

% Equacoes diferenciais VDOT=F0-F;

VCDOT=F0*CA0-F*CA-V*K*CA;

dVdt

=F 0−F

d V C A

dt=F 0 C A0−F C A−V k C A

Page 23: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

% Equacoes diferenciais VTDOT=F0*T0-F*T+(30000.*V*K*CA-Q)/(0.75*50.);

TJDOT=FJ*(TJ0-TJ)/3.85+Q/240.;

d V Tdt

=F0 T 0−F T−V k C A

CP

−U AH

C P

T−T J

d T J

dt=

F J T J0−T J

V J

U AH

J V J C J

T−T J

Page 24: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

% integração por Euler: V = V+VDOT*DELTA; VC = VC+VCDOT*DELTA; VT = VT+VTDOT*DELTA; TJ = TJ+TJDOT*DELTA;

Page 25: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

% incremento do tempoTIME=TIME+DELTA;

% cálculo dos novos valores de CA e TCA=VC/V;T=VT/V;

Page 26: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

% armazenando resultados: if(TIME>=TPRINT) % disp([TIME,CA,T,V,F,TJ,FJ]); saida(linha,:) = [TIME CA T V F TJ FJ]; TPRINT = TPRINT + 0.5; linha=linha+1;

end

Page 27: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

% fim do LOOPend

Page 28: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

No prompt do Matlab podemos chamar nossa funcao entao e receber os resultados em uma variável x qualquer.

>> x=cstr_fb

Page 29: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

Construção da matriz de saídasaida(linha,:) = [TIME CA T V F TJ FJ];

tamanho da matriz x>> size(x)

ou>> [NL,NC]=size(x)

Page 30: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

Construção da matriz de saídasaida(linha,:) = [TIME CA T V F TJ FJ];

valores iniciais das variáveis independentes:

>> x(1,:)

valores finais das variáveis independentes:>> x(NL,:)

Page 31: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

Construção da matriz de saídasaida(linha,:) = [TIME CA T V F TJ FJ];

gráfico da matriz x (sete colunas):>> plot(x)

Page 32: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

Construção da matriz de saídasaida(linha,:) = [TIME CA T V F TJ FJ];

gráfico de CA:>> CA = x(:,2);>> plot(CA)

ou simplesmente:>> plot(x(:,2))

Page 33: Matlab Nonisothermalcstr

   

Reator CSTR Não- I sotérmico

Construção da matriz de saídasaida(linha,:) = [TIME CA T V F TJ FJ];

gráfico de CA versus TIME:>> CA = x(:,2);>> TIME = x(:,1);>> plot(TIME,CA)

ou simplesmente:>> plot(x(:,1),x(:,2))

Page 34: Matlab Nonisothermalcstr

   

Malha Aber ta

% Malha aberta: FJ=49.9; F=40;

Page 35: Matlab Nonisothermalcstr

   

Cont ro lador Proporc iona l

% Controlador proporcional: KC=1.;

FJ = 49.9-KC*(537.161-T); F = 40.-10.*(48.-V);

Page 36: Matlab Nonisothermalcstr

   

Cont ro lador Proporc iona l

% Controlador proporcional: KC=1.;

FJ = 49.9-KC*(537.161-T); if (TIME>5) FJ = 49.9-KC*(570.-T); end

F = 40.-10.*(48.-V);

Page 37: Matlab Nonisothermalcstr

   

Cont ro lador P ID

% Condições iniciais CA=0.474; T=537.16; TJ=536.6;

Page 38: Matlab Nonisothermalcstr

   

Cont ro lador P ID

% Valores dos parâmetros ERRORINT=0; ERROOLD=0; TRESET=0;

Page 39: Matlab Nonisothermalcstr

   

Cont ro lador P ID

% Controlador PID:% Constantes do controlador: KP=10.; % 10 KI=0.02; %0.02 KD=0.2; %0.1

Page 40: Matlab Nonisothermalcstr

   

Cont ro lador P ID

SETPOINT=537.161; if (TIME>0.5) SETPOINT=540; end

ERRO=SETPOINT-T; ERRORINT=ERRORINT+ERRO; ERRODEV=(ERRO-ERROOLD)/DELTA; ERROOLD=ERRO;

Page 41: Matlab Nonisothermalcstr

   

Cont ro lador P ID

FJ = 49.9-KP*(ERRO+KI*ERRORINT+KD*ERRODEV);

TRESET=TRESET+DELTA; if (TRESET>1/(KI+0.00001)) ERRORINT=0; TRESET=0; end

Page 42: Matlab Nonisothermalcstr

   

Apêndice

Page 43: Matlab Nonisothermalcstr

   

Funções Persona l i zadas

Formato geral:

function [r1,r2,...]=nome_funcao(p1,p2,...)código que usa p1, p2,...guarda resultados nas variáveis de saídap1 = ...p2 = ......end

Page 44: Matlab Nonisothermalcstr

   

Funções Persona l i zadas

Exemplo: uma função fatorial simples

function ans=fatorial(x)f=1;if (x>1) f=x*fatorial(x-1);endans=f;end

Page 45: Matlab Nonisothermalcstr

   

Funções Persona l i zadasExemplo: fatorial de uma matriz

function ans=mfatorial(x)if (min(min(x))<0) error('A matriz nao pode conter elementos negativos');

end[a,b]=size(x);f=max(x,ones(a,b));if(sum(sum(f-1))>0) f=f.*mfatorial(f-1);end;ans=f;end

Page 46: Matlab Nonisothermalcstr

   

Cont ro le de F luxo

O comando de decisão IF:

if (condição) bloco de comandoselse bloco de comandosend

Page 47: Matlab Nonisothermalcstr

   

Cont ro le de F luxo

O comando de decisão IF:

if (x>0) y=1;else y=0;end

Page 48: Matlab Nonisothermalcstr

   

Cont ro le de F luxo

O comando de loop WHILE:

while (condição) bloco de comandosend

Page 49: Matlab Nonisothermalcstr

   

Cont ro le de F luxo

O comando de loop WHILE:

t=1.1;while (t<10) t=t*t;end

Page 50: Matlab Nonisothermalcstr

   

Cont ro le de F luxo

O comando de loop FOR:

for variável = expressão bloco de comandosend

Page 51: Matlab Nonisothermalcstr

   

Cont ro le de F luxo

O comando de loop FOR:

for t = 1:1:10 y(t)=0.2*t^2;end

Page 52: Matlab Nonisothermalcstr

   

Referênc ias

http://www.mathworks.com/access/helpdesk/help/techdoc/

http://www.octave.org/

http://www.math.ubc.ca/~feldman/demos/demo1.html