Untitled

 avatar
unknown
plain_text
a month ago
1.8 kB
5
Indexable
% A-->B k1,k2,k3,k4
% R=k*V*c con V1, V2, V3, V4
% Determinare CA1, CA2, CA3, CA4 e CB1, CB2, CB3, CB4
% Condizioni stazionarie

global Qin CAin CBin V1 V2 V3 V4 Q13 Q43 k1 k2 k3 k4
Qin=10; %[L/h]
CAin=1; %[mol/L]
CBin=0; %[mol/L]

V1=25; %[L]
V2=75; %[L]
V3=100; %[L]
V4=25; %[L]

k1=0.05; %[h]
k2=0.1; %[h]
k3=0.5; %[h]
k4=0.1; %[h]

Q13=5; %[L/h]
Q43=3; %[L/h]

function fun=bilanci(C)

global Qin CAin CBin V1 V2 V3 V4 Q13 Q43 k1 k2 k3 k4

CA_1=C(1);
CA_2=C(2);
CA_3=C(3);
CA_4=C(4);
CB_1=C(5);
CB_2=C(6);
CB_3=C(7);
CB_4=C(8);


%Bilancio di massa 1
Q12=Qin-Q13;

%Bilancio di massa 2
Q23=Q12;

%Bilancio di massa 3
Q34=Q23+Q13+Q43;

%Bilancio di massa 4
Qfin=Q34-Q43;


%Bilanci reattore 1
fun(1)=Qin*CAin-Q12*C(1)-Q13*C(1)-k1*V1*C(1);
fun(2)=Qin*CBin-Q12*C(5)-Q13*C(5)+k1*V1*C(5);

%Bilanci reattore 2
fun(3)=Q12*C(1)-Q23*C(2)-k2*V2*C(2);
fun(4)=Q12*C(5)-Q23*C(6)+k2*V2*C(6);

%Bilanci reattore 3
fun(5)=Q23*C(2)+Q13*C(1)+Q43*C(4)-Q34*C(3)-k3*V3*C(3);
fun(6)=Q23*C(6)+Q13*C(5)+Q43*C(8)-Q34*C(7)+k3*V3*C(7);

%Bilanci reattore 4
fun(7)=Q34*C(3)-Q43*C(4)-Qfin*C(4)-k4*V4*C(4);
fun(8)=Q34*C(7)-Q43*C(8)-Qfin*C(8)+k4*V4*C(8);

end

C0=[0.89 0.8 0.5 0.3 0.01 0.34 0.66 0.8];
C_sol=fsolve(@bilanci, C0);

CA_1=C_sol(1);
CA_2=C_sol(2);
CA_3=C_sol(3);
CA_4=C_sol(4);
CB_1=C_sol(5);
CB_2=C_sol(6);
CB_3=C_sol(7);
CB_4=C_sol(8);


fprintf('Concentrazione CA1= %.10f mol/L\n', C_sol(1));
fprintf('Concentrazione CA2= %.10f mol/L\n', C_sol(2));
fprintf('Concentrazione CA3= %.10f mol/L\n', C_sol(3));
fprintf('Concentrazione CA4= %.10f mol/L\n', C_sol(4));
fprintf('Concentrazione CB1= %.10f mol/L\n', C_sol(5));
fprintf('Concentrazione CB2= %.10f mol/L\n', C_sol(6));
fprintf('Concentrazione CB3= %.10f mol/L\n', C_sol(7));
fprintf('Concentrazione CB4= %.10f mol/L\n', C_sol(8));


Leave a Comment