© Giuseppe Pesenti – Strumentazione e Controllo di Impianti Chimici – Politecnico di Milano
Esempio Ese 09 – Dinamica e Controllo di due serbatoi
Strumentazione e Controllo di Impianti Chimici Tutor: Giuseppe Pesenti
clear all
Aserb1=30; % m^2 Aserb2=50; % m^2 r1=1.2; % s/m^2 h_0=[3;3]; % m
Fi_0=9.4; % m^3/s Kc=30; % m^2/s h2_sp=6.6; % m
F0bias=Fi_0; % m^3/s tauI=10; % s
handleopen=@(t,h)serbatoi_openloop(t,h,r1,Aserb1,Aserb2,Fi_0);
[tout,hout]=ode45(handleopen,[0 10*60],h_0,odeset('RelTol',1e-8));
figure(1) subplot(1,3,1) plot(tout,hout)
handleclosed=@(t,h)serbatoi_closedloop(t,h,r1,Aserb1,Aserb2,Fi_0,F0bias,Kc,h2_sp );
[tout2,hout2]=ode45(handleclosed,[0 10*60],h_0,odeset('RelTol',1e-8));
subplot(1,3,2) plot(tout2,hout2) hold on
plot(tout2,ones(1,length(tout2))*h2_sp,'k') legend('h1','h2','h2 sp')
xlabel('t [s]')
title('Altezza del livello di liquido [m] - Closed loop P')
handleOutputPI=@(t,h,flag)outputPI(t,h,flag,h2_sp);
opzPI=odeset('RelTol',1e-8,'OutputFcn',handleOutputPI,'Refine',1);
handlePI=@(t,h)serbatoi_PI(t,h,r1,Aserb1,Aserb2,Fi_0,F0bias,Kc,h2_sp,tauI);
[tout3,hout3]=ode45(handlePI,[0 10*60],h_0,opzPI);
subplot(1,3,3) plot(tout3,hout3) hold on
plot(tout3,ones(1,length(tout3))*h2_sp,'k') legend('h1','h2','h2 sp')
xlabel('t [s]')
title('Altezza del livello di liquido [m] - Closed loop PI')
© Giuseppe Pesenti – Strumentazione e Controllo di Impianti Chimici – Politecnico di Milano
function dhdt=serbatoi_openloop(t,h,r1,Aserb1,Aserb2,Fi_0)if t<5*60
Fi=Fi_0; % m^3/s else
Fi=2*Fi_0; % m^3/s end
F1=(h(1)-h(2))/r1; % m^3/s F0=1.43*h(2); % m^3/s
dhdt=zeros(2,1);
dhdt(1)=1/Aserb1*(Fi-F1); % m/s dhdt(2)=1/Aserb2*(F1-F0); % m/s
end
function dhdt=serbatoi_closedloop(t,h,r1,Aserb1,Aserb2,Fi_0,F0bias,Kc,h2_sp)
if t<5*60
Fi=Fi_0; % m^3/s else
Fi=2*Fi_0; % m^3/s end
F1=(h(1)-h(2))/r1; % m^3/s
epsi=h(2)-h2_sp; % m
F0=F0bias+Kc*epsi; % m^3/s F0=max(F0,0);
dhdt=zeros(2,1);
dhdt(1)=1/Aserb1*(Fi-F1); % m/s dhdt(2)=1/Aserb2*(F1-F0); % m/s end
© Giuseppe Pesenti – Strumentazione e Controllo di Impianti Chimici – Politecnico di Milano
function dhdt=serbatoi_PI(t,h,r1,Aserb1,Aserb2,Fi_0,F0bias,Kc,h2_sp,tauI) global integrale toldif t<5*60
Fi=Fi_0; % m^3/s else
Fi=2*Fi_0; % m^3/s end
F1=(h(1)-h(2))/r1; % m^3/s epsi=h(2)-h2_sp; % m
if isempty(integrale) integraleusaegetta=0;
else
integraleusaegetta=integrale+epsi*(t-told);
end
F0=F0bias+Kc*epsi+Kc/tauI*integraleusaegetta; % m^3/s F0=max(F0,0);
dhdt=zeros(2,1);
dhdt(1)=1/Aserb1*(Fi-F1); % m/s dhdt(2)=1/Aserb2*(F1-F0); % m/s
end
function finire = outputPI(tstep,hstep,flag,h2sp) global integrale told epsiold
finire=0;
if strcmp(flag,'init') integrale=0;
told=0;
epsiold=0;
elseif strcmp(flag,'') deltat=tstep-told;
epsistep=hstep(2)-h2sp;
integrale=integrale+(epsistep+epsiold)/2*deltat;
told=tstep;
epsiold=epsistep;
elseif strcmp(flag,'done') disp('')
end end
© Giuseppe Pesenti – Strumentazione e Controllo di Impianti Chimici – Politecnico di Milano
0 100 200 300 400 500 600
0 10 20 30 40
0 100 200 300 400 500 600
t [s]
0 5 10 15 20 25 30
Altezza del livello di liquido [m] - Closed loop P
h1 h2 h2 sp
0 100 200 300 400 500 600
t [s]
0 5 10 15 20 25 30
Altezza del livello di liquido [m] - Closed loop PI
h1 h2 h2 sp