0% found this document useful (0 votes)
243 views

Scilab Programs MSO

1. The document contains calculations for flash vapor-liquid equilibrium (VLE) for a 5-component system (Pentane, Hexane, Cyclohexane, Methanol, Benzene) at various temperatures and pressures. 2. Three cases are presented: constant temperature and pressure, constant temperature with varying vapor fraction, and constant temperature with a specified split fraction. 3. The calculations involve determining vapor pressure as a function of temperature using Antoine equations, calculating relative volatilities, and iteratively solving for pressure or temperature using overall component phase equilibrium equations. Output parameters like vapor and liquid phase compositions are displayed.

Uploaded by

PranavMehta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
243 views

Scilab Programs MSO

1. The document contains calculations for flash vapor-liquid equilibrium (VLE) for a 5-component system (Pentane, Hexane, Cyclohexane, Methanol, Benzene) at various temperatures and pressures. 2. Three cases are presented: constant temperature and pressure, constant temperature with varying vapor fraction, and constant temperature with a specified split fraction. 3. The calculations involve determining vapor pressure as a function of temperature using Antoine equations, calculating relative volatilities, and iteratively solving for pressure or temperature using overall component phase equilibrium equations. Output parameters like vapor and liquid phase compositions are displayed.

Uploaded by

PranavMehta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 20

MSO PRACTICAL 1

FLASH CALCULATIONS

Nishant Nagle

SAP:60011130027

BE CHEM A-1

Case 1:T &P fixed


//Declaring the Parameters
T=400
//100 kmols of
feed// b=100
//moles of the components in the inlet//
Pe=10;H=30;CycloH=20;M=20;B=20
A1=3.97786;A2=4.00139;A3=3.93002;A4=5.20277;A5=3.98523
B1=1064.84;B2=1170.875;B3=1182.774;B4=1580.08;B5=1184.24
C1=-41.36;C2=-48.833;C3=-52.532;C4=-33.65;C5=-55.578
X1=0.1;X2=0.3;X3=0.2;X4=0.2;X5=0.2
P=5 //Pressure at which VLE Calculated in KPa
zai2=0.45
//Vapor Pressure of different components//
P1sat=10^(A1-(B1/(T+C1)));
P2sat=10^(A2-(B2/(T+C2)));
P3sat=10^(A3-(B3/(T+C3)));
P4sat=10^(A4-(B4/(T+C4)));
P5sat=10^(A5-(B5/(T+C5)));
printf(' P1sat P2sat P3sat P4sat.......P5sat T\n');
printf('%5.4f....%5.4f....%5.4f....%5.4f....%5.4f\n',P1sat,P2sat,P3sat,P4sat,P5sat);
//key component is hexane //
//Relative volatilities of each
component// alpha1=P1sat/P2sat;
alpha2=P2sat/P2sat;
alpha3=P3sat/P2sat;
alpha4=P4sat/P2sat;
alpha5=P5sat/P2sat;
Alphaaverage=(X1*P1sat/P)+(X2*P2sat/P)+(X3*P3sat/P)+(X4*P4sat/P)+(X5*P5sat/P);
printf('Alphaaverage\n');
printf('%5.4f\n',Alphaaverage); printf('alpha1...alpha2...alpha3..alpha4...alpha5..\n');
printf('%5.4f...%5.4f...%5.4f...%5.4f...%5.4f\n',alpha1,alpha2,alpha3,alpha4,alpha5);

//Recoveries of non key components// zai1=(alpha1*zai2)/(1+


(zai2*(alpha1-1))); zai2=(alpha2*zai2)/(1+(zai2*(alpha2-1)));
zai3=(alpha3*zai2)/(1+(zai2*(alpha3-1))); zai4=(alpha4*zai2)/(1+
(zai2*(alpha4-1))); zai5=(alpha5*zai2)/(1+(zai2*(alpha5-1)));
printf('zai1...zai2...zai3...zai4...zai5..\n'); printf('%5.4f...%5.4f...%5.4f...
%5.4f...%5.4f\n',zai1,zai2,zai3,zai4,zai5);
//vapor fractions//
vk1=zai1*Pe;
vk2=zai2*H;
vk3=zai3*CycloH;
vk4=zai4*M;
vk5=zai5*B;
//Liquid fractions//
lk1=(Pe-vk1);
lk2=(H-vk2);
lk3=(CycloH-vk3);
lk4=(M-vk4);
lk5=(B-vk5);
printf('vk1..vk2..vk3..vk4..vk5.\n'); printf('%5.4f...%5.4f...%5.4f...
%5.4f...%5.4f\n',vk1,vk2,vk3,vk4,vk5);
printf('lk1..lk2...lk3...lk4...lk5..\n'); printf('%5.4f...%5.4f...%5.4f...%5.4f...
%5.4f..\n',lk1,lk2,lk3,lk4,lk5);
//Total liquid molar flowrate//
L=lk1+lk2+lk3+lk4+lk5;
printf('L..\n');
printf('%5.4f..\n',L);
//Molefractions of the components in the liquid
phase// xk1=lk1/L;
xk2=lk2/L;
xk3=lk3/L;
xk4=lk4/L;
xk5=lk5/L;
printf('xk1..xk2..xk3..xk4..xk5\n');
printf('%5.4f..%5.4f...%5.4f...%5.4f...%5.4f\n',xk1,xk2,xk3,xk4,xk5);
x1=xk1*alpha1;
x2=xk2*alpha2;
x3=xk3*alpha3;
x4=xk4*alpha4;
x5=xk5*alpha5;
Alphaavg=x1+x2+x3+x4+x5;
printf('Alphaavg\n');
printf('%5.4f\n',Alphaavg); percenterror=(100*(((Alphaavg-
Alphaaverage)/Alphaavg))); printf('percenterror\n');
printf('%5.4f\n',percenterror);
for zai2=0.1:0.001:1
if Alphaavg~=Alphaaverage then
continue
printf('%5.4f',zai2);
else
end
end

Case 2: T and Vap fraction given


clear;
function P1sat=antoine1(T); P1sat=10^(3.97786-
(1064.84/(T+(-41.136))));
endfunction
function P2sat=antoine2(T);
P2sat=10^(4.00139-(1170.875/(T+(-48.833))));
endfunction
function P3sat=antoine3(T);
P3sat=10^(3.93002-(1182.774/(T+(-52.532))));
endfunction
function P4sat=antoine4(T);
P4sat=10^(5.20277-(1580.08/(T+(-33.65))));
endfunction
function P5sat=antoine5(T); P5sat=10^(3.98523-
(1184.24/(T+(-55.578))));
endfunction
T1=355;
F=1; z1=0.1;
z2=0.3;
z3=0.2;
z4=0.2;
z5=0.2;
phi=0.7;

P(1)=1.46198;
P1satT1=antoine1(T1);
P2satT1=antoine2(T1);
P3satT1=antoine3(T1);
P4satT1=antoine4(T1);
P5satT1=antoine5(T1);
alpha12=P1satT1/P2satT1;
alpha22=P2satT1/P2satT1;
alpha32=P3satT1/P2satT1;
alpha42=P4satT1/P2satT1;
alpha52=P5satT1/P2satT1;
j=1;
while(P(j)>1)
theta=(P2satT1/P(j))*(phi/(1-phi));
zai2=theta/(1+theta);
zai1=(antoine1(T1)*zai2/antoine2(T1))/(1+(((antoine1(T1)/antoine2(T1))-1)*zai2));
zai3=(antoine3(T1)*zai2/antoine2(T1))/(1+(((antoine3(T1)/antoine2(T1))-1)*zai2));
zai4=(antoine4(T1)*zai2/antoine2(T1))/(1+(((antoine4(T1)/antoine2(T1))-1)*zai2));
zai5=(antoine5(T1)*zai2/antoine2(T1))/(1+(((antoine5(T1)/antoine2(T1))-1)*zai2));
l1=(1-zai1)*z1*F;
l2=(1-(zai2))*z2*F; l3=(1-
zai3)*z3*F; l4=(1-
zai4)*z4*F; l5=(1-
zai5)*z5*F; x1=(l1)/
(l1+l2+l3+l4+l5); x2=(l2)/
(l1+l2+l3+l4+l5); x3=(l3)/
(l1+l2+l3+l4+l5); x4=(l4)/
(l1+l2+l3+l4+l5); x5=(l5)/
(l1+l2+l3+l4+l5);
alphaavg=(alpha12*(x1))+(alpha22*(x2))+(alpha32*x3)+(alpha42*(x4))+(alpha52*(x5));
P(j+1)=P1satT1*alphaavg/alpha12;
err=P(j+1)-P(j);
printf('The error is:');
printf('\n%10.8f',err); if
err<=0.01 then
printf('\n\n');
printf('The pressure(in bar) is:');
printf('\n%10.8f',P(j+1));
printf('\n\nPksat alphak zaik lk xk');
printf('\n\n');
txout=[P1satT1 alpha12 zai1 l1 x1;P2satT1 alpha22 zai2 l2 x2;P3satT1 alpha32 zai3 l3 x3;P4satT1 alpha42
zai4 l4 x4;P5satT1 alpha52 zai5 l5 x5];
printf('%10.8f %10.8f %10.8f %10.8f %10.8f\n%10.8f %10.8f %10.8f %10.8f %10.8f\n%10.8f %10.8f %10.8f %10.8f
%10.8f\n%10.8f %10.8f %10.8f %10.8f %10.8f\n%10.8f %10.8f %10.8f %10.8f %10.8f',
txout(1,1),txout(1,2),txout(1,3),txout(1,4),txout(1,5),txout(2,1),txout(2,2),txout(2,3),txout(2,4),txout(2,5),txout(3,1),txo
ut(3,2),txout(3,3),txout(3,4),txout(3,5),txout(4,1),txout(4,2),txout(4,3),txout(4,4),txout(4,5),txout(5,1),txout(5,2),txout(5
.3),txout(5,4),txout(5,5));
break;
else
P(j)=P(j+1);
end
end

Case 3: T and split frc given


clc;
disp('Flash operation for 5 components 1-Pentane; 2-Hexane; 3-Cyclohexane; 4- Methanol; 5-Benzene when
temperature and split fraction are given');
T=input('Enter the value of operating temperature in K = ');
Xi(1)=input('Enter the value of split fraction of component 1 = ');
//1-Pentane; 2-Hexane; 3-Cyclohexane; 4- Methanol; 5-
Benzene; mol(1)=input('Enter the mol % given for component
1 = '); mol(2)=input('Enter the mol % given for component 2 =
'); mol(3)=input('Enter the mol % given for component 3 = ');
mol(4)=input('Enter the mol % given for component 4 = ');
mol(5)=input('Enter the mol % given for component 5 = ');
a(1)=3.97786;b(1)=1064.84;c(1)=-41.136;Tbp(1)=309.22;
a(2)=4.00139;b(2)=1170.875;c(2)=-48.833;Tbp(2)=341.88;
a(3)=3.93002;b(3)=1182.774;c(3)=-52.532;Tbp(3)=353.93;
a(4)=5.20277;b(4)=1580.080;c(4)=-33.650;Tbp(4)=337.69;
a(5)=3.98523;b(5)=1184.24;c(5)=-55.578;Tbp(5)=353.24;
for i=1:5,
f(i)=mol(i);
Psat(i)=10^(a(i)-(b(i)/(T+c(i))));
end
disp('alphakh');
for i=1:5,
alphakh(i)=Psat(i)/Psat(1);
end
for i=1:5,
Xi(i)=(alphakh(i)*Xi(1))/(1+(alphakh(i)-1)*Xi(1));
lk(i)=(1-Xi(i))*f(i);
vk(i)=Xi(i)*f(i);
end
for i=1:5,
xk(i)=lk(i)/(lk(1)+lk(2)+lk(3)+lk(4)+lk(5));
yk(i)=vk(i)/(vk(1)+vk(2)+vk(3)+vk(4)+vk(5));
alphaprod(i)=xk(i)*alphakh(i);
end
disp('comp a b c Psat alphakh Xi lk vk xk yk');
for i=1:5,
tout=[ i a(i) b(i) c(i) Psat(i) alphakh(i) Xi(i) lk(i) vk(i) xk(i) yk(i)];
printf('%2d %10.5f %10.3f %10.3f %10.6f %10.4f %10.6f %10.6f %10.6f %10.6f
%10.6f\n',tout);
end
alphaavg=alphaprod(1)+alphaprod(2)+alphaprod(3)+alphaprod(4)+alphaprod(5);
disp('alphaavg = ');
printf('%10.6f\n',alphaavg);
P=sum(xk.*Psat);
printf('Pressure is %f ',P);

Results:
printf('End of Bubble Point Pressure Calculations\n\n');
printf('Bubble Point Temperature Calculations\n\n');
printf('P = %2.1f\n\n',P(1));
T1=T1sat(P(1)); T2=T2sat(P(1)); T3=T3sat(P(1)); T4=T4sat(P(1)); T5=T5sat(P(1));
printf('T1 = %5.4f T2 = %5.4f T3 = %5.4f T4 = %5.4f T5 = %5.4f\n',T1,T2,T3,T4,T5);
T(2)=(x1(1)*T1)+(x2(1)*T2)+(x3(1)*T3)+(x4(1)*T4)+(x5(1)*T5);
printf('T = %5.4f\n',T(2));
printf('Interation No. T P1sat P2sat P3sat P4sat P5sat A1 A2A3A4 A5 Aavg P2sat
T\n');
for i=2:7
P1=P1sat(T(i)); P2=P2sat(T(i)); P3=P3sat(T(i)); P4=P4sat(T(i)); P5=P5sat(T(i));
A1=P1/P2; A2=P2/P2; A3=P3/P2; A4=P4/P2; A5=P5/P2;
Aavg=(x1(1)*A1)+(x2(1)*A2)+(x3(1)*A3)+(x4(1)*A4)+(x5(1)*A5);
P2new=P(1)/Aavg;
T(i+1)=T2sat(P2new);
printf(' %2.1f %5.4f %5.4f %5.4f %5.4f %5.4f %5.4f %5.4f %5.4f %5.4f %5.4f %5.4f %5.4f
%5.4f %5.4f\n',i-1,T(i),P1,P2,P3,P4,P5,A1,A2,A3,A4,A5,Aavg,P2new,T(i+1));
end
printf('\n');
y1=(x1(1)*P1)/P(1); y2=(x2(1)*P2)/P(1); y3=(x3(1)*P3)/P(1); y4=(x4(1)*P4)/P(1); y5=(x5(1)*P5)/P(1);
printf('Y1 = %5.4f Y2 = %5.4f Y3 = %5.4f Y4 = %5.4f Y5 = %5.4f\n',y1,y2,y3,y4,y5);
printf('End of Bubble Point Temperature Calculations\n\n');
printf('Dew Point Pressure Calculations\n\n');
y1(1)=0.1; y2(1)=0.3; y3(1)=0.2; y4(1)=0.2; y5(1)=0.2;
printf('T = %5.4f\n\n',T(1));
P1=P1sat(T(1)); P2=P2sat(T(1)); P3=P3sat(T(1)); P4=P4sat(T(1)); P5=P5sat(T(1));
printf('P1sat=%5.4f P2sat=%5.4f P3sat=%5.4f...P4sat=%5.4f P5sat=%5.4f\n',P1,P2,P3,P4,P5);

printf('X1=%5.4f X2=%5.4f X3=%5.4f X4=%5.4f X5=%5.4f\n',x1,x2,x3,x4,x5);


printf('End of Dew Pressure Calculation\n');
printf('Dew Point Temperature Calculations\n\n');
printf('P = %2.1f\n\n',P(1));
T1=T1sat(P(1)); T2=T2sat(P(1)); T3=T3sat(P(1)); T4=T4sat(P(1)); T5=T5sat(P(1));
printf('T1 = %5.4f T2 = %5.4f T3 = %5.4f T4 = %5.4f T5 = %5.4f\n',T1,T2,T3,T4,T5);
y1(1)=0.1; y2(1)=0.3; y3(1)=0.2; y4(1)=0.2; y5(1)=0.2;
T(2)=(y1(1)*T1)+(y2(1)*T2)+(y3(1)*T3)+(y4(1)*T4)+(y5(1)*T5);
printf('T = %5.4f\n',T(2));
printf('Interation No. T P1sat P2sat P3sat P4sat P5sat A1 A2 A3 A4 A5 Aavg P2sat
T\n');
for i=2:7
P1=P1sat(T(i)); P2=P2sat(T(i)); P3=P3sat(T(i)); P4=P4sat(T(i)); P5=P5sat(T(i));
A1=P1/P2; A2=P2/P2; A3=P3/P2; A4=P4/P2; A5=P5/P2;
YA=(y1(1)/A1)+(y2(1)/A2)+(y3(1)/A3)+(y4(1)/A4)+(y5(1)/A5);
Pn=P(1)*YA;
T(i+1)=T2sat(Pn);
printf(' %2.1f %5.4f %5.4f %5.4f %5.4f %5.4f %5.4f %5.4f %5.4f %5.4f %5.4f %5.4f %5.4f
%5.4f %5.4f\n',i-1,T(i),P1,P2,P3,P4,P5,A1,A2,A3,A4,A5,Aavg,Pn,T(i+1));
end
printf('\n');
x1=y1(1)*P(1)/P1; x2=y2(1)*P(1)/P2; x3=y3(1)*P(1)/P3; x4=y4(1)*P(1)/P4; x5=y5(1)*P(1)/P5;
printf('X1 = %5.4f X2 = %5.4f X3 = %5.4f X4 = %5.4f X5 = %5.4f\n',x1,x2,x3,x4,x5);
printf('End of Dew Point Temperature Calculations\n\n');
Results:
MSO PRACTICAL 3

MULTICOMPONENT DISTILLATION CALCULATIONS

Nishant Nagle

SAP:60011130027

BE CHEM A-1

/ Min no of stages
Elk=0.99;
Ehk=0.005;
Feed_k=[20;30;50];
alpha=[6.209;2.662;1]
Nmin=log((Elk/(1-Elk))*((1-Ehk)/Ehk))/log(alpha(1));
printf('Min no of stages is %f\n',Nmin);

/ Min reflux ratio


function ans=func(x) ans=((6.209*0.2)/(6.209-x))+((2.662*0.3)/
(2.662-x))+((1*0.5)/(1-x))
endfunction
[lambda]=fsolve(2,func);
Etoluene=(2.662^Nmin)*0.005/(1+0.005*((2.662^Nmin)-1));
/ Molar fractions in distillate
E=[Elk;Etoluene;Ehk];
D=Feed_k.*E;
xD=Feed_k.*E/sum(Feed_k.*E);
/ Molar fractions in bottoms
E=[1-Elk;1-Etoluene;1-Ehk];
B=Feed_k.*E;
xB=Feed_k.*E/sum(Feed_k.*E);
/ 2nd Underwood equation for calculating Vmin
Vmin=sum(alpha.*D ./(alpha-lambda));
Khk=0.405;
Lmin=lambda*Vmin*Khk;
Dmin=Vmin-Lmin;
Rmin=(Lmin/Dmin);
R=1.3*Rmin //Actual reflux ratio
printf('Min reflux rataio is %f\n',Rmin);

//No of ideal stages by Gilliland's


correlation function ans=func2(x)
ans=((x-Nmin)/(x+1))-1+exp((1+54.4*(R-Rmin)/(R+1))/(11+117.2*(R-Rmin)/(R+1))*((R-Rmin)/(R+1)-1)/((R-
Rmin)/((R+1)^0.5)))
endfunction
[N]=fsolve(10,func2);
printf('No of ideal stages is %f\n',N);

//No of stages in rectifying and stripping sections


NRbyNS=((Feed_k(3)/Feed_k(1))*((B(1)/B(3))^2)*(sum(B)/sum(D)))^0.206;
NS=N/(1+NRbyNS);
NR=N-NS;
printf('No of stages in rectifying and stripping sections are %f and %f respectively\n',NR,NS);

// Bubble point calculations for


distillate P=750; //pressure
xk=xD;
T=0;
A=[15.9008;16.0137;16.1156];
B=[2788.51;3096.52;3395.57];
C=[-52.34;-53.67;-59.44];
Tn=300; // Initial assumption for Temp

while(abs(Tn-T)>1)
T=Tn; Pk=exp(A-(B./
(T+C)));

/ Assume benzene to be key


component alpha=Pk./Pk(1);
alpha_avg=sum(alpha.*xk);
Pn=P/alpha_avg; Tn=(B(1)/(A(1)-
log(Pn)))-C(1);
end
printf('Temp of overhead condensate is %f degC\n',Tn);

/ Dew point calculations for overhead vapour

P=750;
//pressure
yk=xD;
T=0;
A=[15.9008;16.0137;16.1156];
B=[2788.51;3096.52;3395.57];
C=[-52.34;-53.67;-59.44];
Tn=300; // Initial assumption for Temp

while(abs(Tn-T)>1)
T=Tn; Pk=exp(A-(B./
(T+C)));

/ Assume benzene to be key


component alpha=Pk./Pk(1);
ybyalpha=sum(yk./alpha);
Pn=P*ybyalpha Tn=(B(1)/(A(1)-
log(Pn)))-C(1);
end
printf('Temp of overhead vapour is %f degC\n',Tn);

/ Bubble point calculation for bottoms


P=750;
//pressure
xk=xB;
T=0;
A=[15.9008;16.0137;16.1156];
B=[2788.51;3096.52;3395.57];
C=[-52.34;-53.67;-59.44];
Tn=300; // Initial assumption for Temp

while(abs(Tn-T)>1)
T=Tn; Pk=exp(A-(B./
(T+C)));

// Assume benzene to be key component


alpha=Pk./Pk(1);
alpha_avg=sum(alpha.*xk);
Pn=P/alpha_avg; Tn=(B(1)/(A(1)-
log(Pn)))-C(1);
end
printf('Temp of bottom product is %f degC\n',Tn);

//Dew point calculations for reboiloer return


vapour P=750; //pressure
yk=xB;
T=0;
A=[15.9008;16.0137;16.1156];
B=[2788.51;3096.52;3395.57];
C=[-52.34;-53.67;-59.44];
Tn=300; // Initial assumption for Temp

while(abs(Tn-T)>1)
T=Tn;
Pk=exp(A-(B./(T+C)));

// Assume benzene to be key component


alpha=Pk./Pk(1);
ybyalpha=sum(yk./alpha);
Pn=P*ybyalpha Tn=(B(1)/(A(1)-
log(Pn)))-C(1);
end
printf('Temp of reboiler vapour is %f degC\n',Tn);

Results:
MSO PRACTICAL 4

BUBBLE & DEW PT CALCULATIONS WITH NON IDEALITY


Nishant Nagle

SAP:60011130027

BE CHEM A-1

clear;
x1(1)=0.5;
x2(1)=0.5;
y1(1)=0.5;
y2(1)=0.5;
T(1)=input('Enter the value of Temperature in K ');
P(1)=input('Enter the value of Pressure in kPa ');
printf('\n');
function Ac=A(T)
Ac=2.771-0.00523*T;
endfunction
function G1=gam1(x2)
G1=exp(Ac*(x2^2));
endfunction
function G2=gam2(x1)
G2=exp(Ac*(x1^2));
endfunction
function P1=P1sat(T) P1=exp(16.59158-
(3643.31/(T-33.424)));
endfunction
function P2=P2sat(T) P2=exp(14.25326-
(2665.54/(T-53.424)));
endfunction
function T1=T1sat(P) T1=33.424+(3643.31/
(16.59158-log(P)));
endfunction
function T2=T2sat(P) T2=53.424+(2665.54/
(14.25326-log(P)));
endfunction
printf('Bubble Point Pressure calculations:\n\n');
P1=P1sat(T(1));
P2=P2sat(T(1));
Ac=A(T(1));
G1=gam1(x2(1));
G2=gam2(x1(1));
Pt=G1*x1(1)*P1+G2*x2(1)*P2;
y1(2)=G1*x1(1)*P1/Pt;
y2(2)=G2*x2(1)*P2/Pt;
printf('T = %6.5f\n',T(1));
printf('P1sat = %6.5f\n',P1);
printf('P2sat = %6.5f\n',P2);
printf('x1 = %6.5f\n',x1(1));
printf('x2 = %6.5f\n',x2(1));
printf('A = %6.5f\n',Ac);
printf('Gamma 1 = %6.5f\n',G1);
printf('Gamma 2 = %6.5f\n',G2);
printf('Pt = %6.5f\n',Pt); printf('y1
= %6.5f\n',y1(2)); printf('y2 =
%6.5f\n\n',y2(2));
printf('End of Bubble Point Pressure calculations\n\n');
printf('Bubble Point Temperature calculations\n\n');
printf('P = %6.5f\n\n',P(1));
T1=T1sat(P(1));
T2=T2sat(P(1));
printf('T1sat = %6.5f\n',T1);
printf('T2sat = %6.5f\n\n',T2);
T(2)=x1(1)*T1+x2(1)*T2;
printf('Assumed T = %6.5f\n\n',T(2));
printf('Iteration No. T(ass) P1sat P2sat A Gamma 1 Gamma 2 Alpha P1sat(calc) T(cal)
P2sat(calc) x1 x2 y1 y2\n');
for i=2:11
P1=P1sat(T(i));
P2=P2sat(T(i));
Ac=A(T(i));
G1=gam1(x2(1));
G2=gam2(x1(1));
alpha=P1/P2;
P1new=P(1)/((x1(1)*G1)+(x2(1)*G2/alpha));
P(i+1)=P1new;
T(i+1)=T1sat(P(i+1));
P2new=P2sat(T(i+1));
y1(i)=x1(1)*G1*P1new/P(1);
y2(i)=x2(1)*G2*P2new/P(1);
printf(' %1.0f %6.5f %6.5f %6.5f %6.5f %6.5f %6.5f %6.5f %6.5f %6.5f %6.5f %2.1f %2.1f
%6.5f %6.5f\n',i-1,T(i),P1,P2,Ac,G1,G2,alpha,P1new,T(i+1),P2new,x1(1),x2(1),y1(i),y2(i));
end
printf('\nEnd of Bubble Point Temperature calculations\n\n');
printf('Dew Point Pressure calculations\n\n');
P1=P1sat(T(1));
P2=P2sat(T(1));
Ac=A(T(1));
G1(1)=1;
G2(1)=1;
printf('T = %6.5f\n\n',T(1));
printf('P1sat = %6.5f\n',P1);
printf('P2sat = %6.5f\n\n',P2);
printf('Iteration No. A y1 y2 Gamma 1(ass) Gamma 2(ass) Pt x1(calc) x2(calc) Gamma 1(calc)
Gamma 2(calc)\n');
for i=1:20
Pt=1/((y1(1)/(G1(i)*P1))+(y2(1)/(G2(i)*P2)));
x1(i)=y1(1)*Pt/(G1(i)*P1);
x2(i)=y2(1)*Pt/(G2(i)*P2);
G1(i+1)=gam1(x2(i));
G2(i+1)=gam2(x1(i));
printf(' %1.0f %6.5f %2.1f %2.1f %6.5f %6.5f %6.5f %6.5f %6.5f %6.5f
%6.5f\n',i,Ac,y1(1),y2(1),G1(i),G2(i),Pt,x1(i),x2(i),G1(i+1),G2(i+1));
end
printf('\nEnd of Dew Point Pressure Calculations\n\n');
printf('Dew Point Temperature Calculations\n\n');
y1(2)=0.5;
y2(2)=0.5;
printf('P = %6.5f\n\n',P(1));
T1=T1sat(P(1));
T2=T2sat(P(1));
printf('T1sat = %6.5f\n',T1);
printf('T2sat = %6.5f\n\n',T2);
T(2)=y1(1)*T1+y2(1)*T2;
G1(2)=1;
G2(2)=1;
printf('Assumed T = %6.5f\n\n',T(2));
printf('Iteration No. y1 y2 T(ass) P1sat P2sat A Gamma 1 Gamma 2 x1 x2 Gamma 1
Gamma 2 Alpha P1sat(calc) T(calc)\n');
for i=2:13
P1=P1sat(T(i));
P2=P2sat(T(i)); Ac=A(T(i));
x1(i)=y1(2)*P(1)/(G1(i)*P1);
x2(i)=1-x1(i);
G1(i+1)=gam1(x2(i));
G2(i+1)=gam2(x1(i));
alpha=P1/P2;
P1new=P(1)/((x1(i)*G1(i+1))+(x2(i)*G2(i+1)/alpha));
T(i+1)=T1sat(P1new);
printf(' %1.0f %2.1f %2.1f %6.5f %6.5f %6.5f %6.5f %6.5f %6.5f %6.5f %6.5f %6.5f %6.5f %6.5f %6.5f
%6.5f\n',i-1,y1(1),y2(1),T(i),P1,P2,Ac,G1(i),G2(i),x1(i),x2(i),G1(i+1),G2(i+1),alpha,P1new,T(i+1)); end

Result:

a
. .
Q2:L=∗ ( − + − + − )

∗ .
Result:
Q 9.1
Graph:

Contour:
9.2
Graph:

Contour:

You might also like