Академический Документы
Профессиональный Документы
Культура Документы
Exercise 3A
clear all
clc
x1=input('x1=');
x2=input('x2=');
tol=input('toleransi=');
z1=0.017857;
z2=0.464286;
z3=0.107143;
z4=0.410714;
k1a=1/1*exp(9.2806-(2789.51/(x1-52.36)));
k2a=1/1*exp(9.3935-(3096.52/(x1-53.67)));
k3a=1/1*exp(9.3993-(3279.47/(x1-59.95)));
k4a=1/1*exp(9.5188-(3366.99/(x1-59.04)));
k1b=1/1*exp(9.2806-(2789.51/(x2-52.36)));
k2b=1/1*exp(9.3935-(3096.52/(x2-53.67)));
k3b=1/1*exp(9.3993-(3279.47/(x2-59.95)));
k4b=1/1*exp(9.5188-(3366.99/(x2-59.04)));
f1=(z1*k1a+z2*k2a+z3*k3a+z4*k4a)-1;
f2=(z1*k1b+z2*k2b+z3*k3b+z4*k4b)-1;
e=1;
ite=0;
while e>=tol;
x3=x2-(f2*(x2-x1)/(f2-f1));
f3=(z1*1/1*exp(9.2806-(2789.51/(x3-52.36))))+(z2*1/1*exp(9.3935-
(3096.52/(x3-53.67))))+(z3*1/1*exp(9.3993-(3279.47/(x3-
59.95))))+(z4*1/1*exp(9.5188-(3366.99/(x3-59.04))))-1;
ite=ite+1;
e=abs(f3);
if abs(f1)>abs(f2);
x1=x2;
f1=f2;
x2=x3;
f2=f3;
else
x1=x1;
f1=f1;
x2=x3;
f2=f3;
end
end
disp(['x3=',num2str(x3)]);
disp(['tol=',num2str(tol)]);
disp(['ite=',num2str(ite)]);
disp(['e=',num2str(e)]);
Answer:
Bubble point for 1 bar pressure
suhu trial kesatu = 200
suhu trial kedua = 400
toleransi = 0.0001
bubble point untuk tekanan dalam 1 bar = 394.3825
jumlah iterasi = 4
error = 4.0912e-005
Exercise 3b
clear all;
clc;
x1=input('x1=');
x2=input('x2=');
tol=input('toleransi=');
z1=0.017857;
z2=0.464286;
z3=0.107143;
z4=0.410714;
k1a=1/5*exp(9.2806-(2789.51/(x1-52.36)));
k2a=1/5*exp(9.3935-(3096.52/(x1-53.67)));
k3a=1/5*exp(9.3993-(3279.47/(x1-59.95)));
k4a=1/5*exp(9.5188-(3366.99/(x1-59.04)));
k1b=1/5*exp(9.2806-(2789.51/(x2-52.36)));
k2b=1/5*exp(9.3935-(3096.52/(x2-53.67)));
k3b=1/5*exp(9.3993-(3279.47/(x2-59.95)));
k4b=1/5*exp(9.5188-(3366.99/(x2-59.04)));
f1=(z1*k1a+z2*k2a+z3*k3a+z4*k4a)-1;
f2=(z1*k1b+z2*k2b+z3*k3b+z4*k4b)-1;
e=1;
ite=0;
while e>=tol;
x3=x2-(f2*(x2-x1)/(f2-f1));
f3=(z1*1/5*exp(9.2806-(2789.51/(x3-52.36))))+(z2*1/5*exp(9.3935-
(3096.52/(x3-53.67))))+(z3*1/5*exp(9.3993-(3279.47/(x3-
59.95))))+(z4*1/5*exp(9.5188-(3366.99/(x3-59.04))))-1;
ite=ite+1;
e=abs(f3);
if abs(f1)>abs(f2);
x1=x2;
f1=f2;
x2=x3;
f2=f3;
else
x1=x1;
f1=f1;
x2=x3;
f2=f3;
end
end
disp(['x3=',num2str(x3)]);
disp(['tol=',num2str(tol)]);
disp(['ite=',num2str(ite)]);
disp(['e=',num2str(e)]);
Answer:
Bubble point for 5 bar pressure
suhu trial kesatu = 200
suhu trial kedua = 400
toleransi = 0.0001
bubble point untuk tekanan dalam 1 bar = 464.8658
jumlah iterasi = 8
error = 5.3597e-005
Exercise 3c
clc;
clear all;
T=313;
f=[1 26 6 23];
n=1+26+6+23;
x=f/n;
A=[9.2806 9.3935 9.3993 9.5188];
B=[2789.51 3096.52 3279.47 3366.99];
C=[-52.36 -53.67 -59.95 -59.04];
P=((x(1)*(exp(A(1)-(B(1)/(T+C(1))))))+(x(2)*(exp(A(2)-
(B(2)/(T+C(2))))))+(x(3)*(exp(A(3)-(B(3)/(T+C(3))))))+(x(4)*(exp(A(4)-
(B(4)/(T+C(4)))))));
disp(['Pressure for Total condensation at 313 Kelvin temperature =
',num2str(P)]);
Answer:
Pressure for Total condensation at 313 Kelvin temperature = 0.05348
Exercise 3d
clear all
clc
x1=input('x1=');
x2=input('x2=');
tol=input('toleransi=');
z1=0.017857;
z2=0.464286;
z3=0.107143;
z4=0.410714;
k1a=1/1*exp(9.2806-(2789.51/(400-52.36)));
k2a=1/1*exp(9.3935-(3096.52/(400-53.67)));
k3a=1/1*exp(9.3993-(3279.47/(400-59.95)));
k4a=1/1*exp(9.5188-(3366.99/(400-59.04)));
f1=(z1*(k1a-1)/(x1*(k1a-1)+1))+(z2*(k2a-1)/(x1*(k2a-1)+1))+(z3*(k3a-
1)/(x1*(k3a-1)+1))+(z4*(k4a-1)/(x1*(k4a-1)+1));
f2=(z1*(k1a-1)/(x2*(k1a-1)+1))+(z2*(k2a-1)/(x2*(k2a-1)+1))+(z3*(k3a-
1)/(x2*(k3a-1)+1))+(z4*(k4a-1)/(x2*(k4a-1)+1));
e=1;
ite=0;
while e>=tol;
x3=x2-(f2*(x2-x1)/(f2-f1));
f3=(z1*(k1a-1)/(x3*(k1a-1)+1))+(z2*(k2a-1)/(x3*(k2a-1)+1))+(z3*(k3a-
1)/(x3*(k3a-1)+1))+(z4*(k4a-1)/(x3*(k4a-1)+1));
ite=ite+1;
e=abs(f3);
if abs(f1)>abs(f2);
x1=x2;
f1=f2;
x2=x3;
f2=f3;
else
x1=x1;
f1=f1;
x2=x3;
f2=f3;
end
end
disp(['x3=',num2str(x3)]);
disp(['tol=',num2str(tol)]);
disp(['ite=',num2str(ite)]);
disp(['e=',num2str(e)]);
disp(['Total liquid will be condesed in percent = ',num2str(percent)]);
Answer
How much liquid will be condesed, if the pressure and temperature at 1 bar and 400 Kelvin
V/F trial kesatu = 0
V/F trial kedua = 1
toleransi = 0.0001
V/F = 0.84593
toleransi = 0.0001
jumlah iterasi = 2
error = 9.3461e-006
Exercise 7
clc;
clear all;
%penyelesaian dengan metode Newton umum
%untuk sebanyak n persamaan
disp('compare interaction parameter between wilson equation with table
4.12');
A=[13.8228 11.9647];
B=[4628.96 3984.93];
C=[-20.524 -39.734];
P=1.01325;
T=353.4;
R=8.3145;
P1sat=exp(A(1)-B(1)/(T+C(1)));
P2sat=exp(A(2)-B(2)/(T+C(2)));
g1=P/P1sat;
g2=P/P2sat;
n=input('jumlah persamaan = ');
for i=1:n;
x(i)=input(['nilai x',num2str(i),' = ']);
end
tol=input('nilai toleransi = ');
e=1;
ite=0;
while max(e)>=tol;
f(1)=[(-log(0.69+0.31*x(1)))+(0.31*x(1)/(0.69+0.31*x(1)))-
(0.31*x(2)/(0.31+0.69*x(1)))-(log(g1))];
f(2)=[(-log(0.31+0.69*x(2)))-
(0.69*x(1)/(0.69+0.31*x(1)))+(0.69*x(2)/(0.31+0.69*x(1)))-(log(g2))];
df(1,:)=[-
961/10000*x(1)/(69/100+31/100*x(1))^2+2139/10000*x(2)/(31/100+69/100*x(1))
^2 -31/100/(31/100+69/100*x(1))];
df(2,:)=[-
69/100/(69/100+31/100*x(1))+2139/10000*x(1)/(69/100+31/100*x(1))^2-
4761/10000*x(2)/(31/100+69/100*x(1))^2 -
69/100/(31/100+69/100*x(2))+69/100/(31/100+69/100*x(1))];
F=ones(n:1);
x0=ones(n:1);
j=ones(n:n);
for i=1:n;
F(i,1)=f(i);
x0(i,1)=x(i);
j(i,:)=df(i,:);
end
j1=inv(j);
x=x0-j1*F;
for i=1:n;
e(i,1)=abs((x(i,1)-x0(i,1))/x0(i,1));
end
ite=ite+1;
for i=1:n;
x(i)=x(i,1);
end
x0=x;
end
for h=1:n;
disp(['nilai x',num2str(h),' = ',num2str(x(h,1))]);
end
for h=1:n;
disp(['nilai error',num2str(h),' = ',num2str(e(h,1))]);
end
disp(['jumlah iterasi = ',num2str(ite)]);
Answer:
compare interaction parameter between wilson equation with table 4.12
jumlah persamaan = 2
nilai x1 = 0.5
nilai x2 = 0.5
nilai toleransi = 0.0001
nilai x1 = 0.34154
nilai x2 = 0.46649
nilai error1 = 3.3744e-007
nilai error2 = 1.392e-007
jumlah iterasi = 4
interaction parameter using table 4.12
nilai A12 = 0.066317
nilai A21 = 0.73447
Exercise 8
clc;
clear all;
disp('system 2-butanol(1)/water(2)');
disp('Metode Secant to solve problem number 8 using Bubble point for 1 atm
pressure')
disp('g12-g22 : g1');
disp('g21-g11 : g2');
disp('alpha12 : a');
P=1.01325;
R=8.3145;
x1=input('nilai x1 = ');
x2=1-x1;
disp(['nilai x2 = ',num2str(x2)]);
A=[9.9614 11.9647];
B=[2664.0939 3984.9273];
C=[-104.881 -39.734];
g1=1034.3;
g2=10098.5;
a=0.4118;
t1=input('suhu trial kesatu = ');
t2=input('suhu trial kedua = ');
tole=input('toleransi = ');
v1=((x1*exp((x2^2)*(g2/(R*t1)*((exp(-a*g2/(R*t1))/(x1+x2*exp(-
a*g2/(R*t1))))^2)+(g1/(R*t1)*exp(-a*g1/(R*t1))/(x2+x1*exp(-
a*g1/(R*t1)))^2)))*exp(A(1)-
B(1)/(t1+C(1))))/P)+((x2*exp((x1^2)*(g1/(R*t1)*((exp(-
a*g1/(R*t1))/(x2+x1*exp(-a*g1/(R*t1))))^2)+(g2/(R*t1)*exp(-
a*g2/(R*t1))/(x1+x2*exp(-a*g2/(R*t1)))^2)))*exp(A(2)-B(2)/(t1+C(2))))/P)-1;
v2=((x1*exp((x2^2)*(g2/(R*t2)*((exp(-a*g2/(R*t2))/(x1+x2*exp(-
a*g2/(R*t2))))^2)+(g1/(R*t2)*exp(-a*g1/(R*t2))/(x2+x1*exp(-
a*g1/(R*t2)))^2)))*exp(A(1)-
B(1)/(t2+C(1))))/P)+((x2*exp((x1^2)*(g1/(R*t2)*((exp(-
a*g1/(R*t2))/(x2+x1*exp(-a*g1/(R*t2))))^2)+(g2/(R*t2)*exp(-
a*g2/(R*t2))/(x1+x2*exp(-a*g2/(R*t2)))^2)))*exp(A(2)-B(2)/(t2+C(2))))/P)-1;
err=1;
itera=0;
while err>=tole;
t3=t2-(v2*(t2-t1)/(v2-v1));
v3=((x1*exp((x2^2)*(g2/(R*t3)*((exp(-a*g2/(R*t3))/(x1+x2*exp(-
a*g2/(R*t3))))^2)+(g1/(R*t3)*exp(-a*g1/(R*t3))/(x2+x1*exp(-
a*g1/(R*t3)))^2)))*exp(A(1)-
B(1)/(t3+C(1))))/P)+((x2*exp((x1^2)*(g1/(R*t3)*((exp(-
a*g1/(R*t3))/(x2+x1*exp(-a*g1/(R*t3))))^2)+(g2/(R*t3)*exp(-
a*g2/(R*t3))/(x1+x2*exp(-a*g2/(R*t3)))^2)))*exp(A(2)-B(2)/(t3+C(2))))/P)-
1;
err=abs(v3);
itera=itera+1;
if abs(v1)>abs(v2)
t1=t2;
v1=v2;
t2=t3;
v2=v3;
else
t1=t1;
v1=v1;
t2=t3;
v2=v3;
end
end
disp(['temperature untuk tekanan dalam 1 atm = ',num2str(t3)]);
disp(['toleransi = ',num2str(tole)]);
disp(['jumlah iterasi = ',num2str(itera)]);
disp(['error = ',num2str(err)]);
for xx1=0:0.01:1
xx2=1-xx1;
g=exp((xx2^2)*(g2/(R*t3)*((exp(-a*g2/(R*t3))/(xx1+xx2*exp(-
a*g2/(R*t3))))^2)+(g1/(R*t3)*exp(-a*g1/(R*t3))/(xx2+xx1*exp(-
a*g1/(R*t3)))^2)));
p1sat=exp(A(1)-B(1)/(t3+C(1)));
y1=xx1*g*p1sat/P;
end
x=[0:0.01:1]
y=[0 0.1921 0.3031 0.3662 0.4009 0.4183 0.4252 0.4260 0.4231 0.4182 0.4123
0.4060 0.3997 0.3936 0.3879 0.3827 0.3779 0.3737 0.3700 0.3667 0.3639 0.3615
0.3596 0.3580 0.3568 0.3560 0.3554 0.3551 0.3551 0.3554 0.3559 0.3567 0.3576
0.3587 0.3600 0.3615 0.3632 0.3650 0.3669 0.3690 0.3713 0.3736 0.3761 0.3786
0.3813 0.3841 0.3870 0.3899 0.3930 0.3962 0.3994 0.4027 0.4061 0.4095 0.4131
0.4167 0.4204 0.4241 0.4279 0.4318 0.4357 0.4397 0.4437 0.4479 0.4520 0.4563
0.4605 0.4649 0.4693 0.4737 0.4782 0.4828 0.4874 0.4921 0.4968 0.5016 0.5065
0.5114 0.5163 0.5213 0.5264 0.5315 0.5367 0.5419 0.5472 0.5526 0.5580 0.5635
0.5690 0.5746 0.5803 0.5860 0.5918 0.5977 0.6036 0.6096 0.6157 0.6218 0.6280
0.6343 0.6407]
plot(x,y);
xlabel('x1');
ylabel('y1');
title('x-y plot for the system 2-butanol(1)/water(2)');
grid on
Answer:
system 2-butanol(1)/water(2)
Metode Secant to solve problem number 8 using Bubble point for 1 atm pressure
g12-g22 : g1
g21-g11 : g2
alpha12 : a
nilai x1 = 1
nilai x2 = 0
suhu trial kesatu = 300
suhu trial kedua = 500
toleransi = 0.0001
temperature untuk tekanan dalam 1 atm = 372.6767
toleransi = 0.0001
jumlah iterasi = 23
error = 4.0597e-006
x=
Columns 1 through 10
Columns 11 through 20
0.1000 0.1100 0.1200 0.1300 0.1400 0.1500 0.1600 0.1700 0.1800 0.1900
Columns 21 through 30
0.2000 0.2100 0.2200 0.2300 0.2400 0.2500 0.2600 0.2700 0.2800 0.2900
Columns 31 through 40
0.3000 0.3100 0.3200 0.3300 0.3400 0.3500 0.3600 0.3700 0.3800 0.3900
Columns 41 through 50
0.4000 0.4100 0.4200 0.4300 0.4400 0.4500 0.4600 0.4700 0.4800 0.4900
Columns 51 through 60
0.5000 0.5100 0.5200 0.5300 0.5400 0.5500 0.5600 0.5700 0.5800 0.5900
Columns 61 through 70
0.6000 0.6100 0.6200 0.6300 0.6400 0.6500 0.6600 0.6700 0.6800 0.6900
Columns 71 through 80
0.7000 0.7100 0.7200 0.7300 0.7400 0.7500 0.7600 0.7700 0.7800 0.7900
Columns 81 through 90
0.8000 0.8100 0.8200 0.8300 0.8400 0.8500 0.8600 0.8700 0.8800 0.8900
0.9000 0.9100 0.9200 0.9300 0.9400 0.9500 0.9600 0.9700 0.9800 0.9900
Column 101
1.0000
y=
Columns 1 through 10
Columns 11 through 20
0.4123 0.4060 0.3997 0.3936 0.3879 0.3827 0.3779 0.3737 0.3700 0.3667
Columns 21 through 30
0.3639 0.3615 0.3596 0.3580 0.3568 0.3560 0.3554 0.3551 0.3551 0.3554
Columns 31 through 40
0.3559 0.3567 0.3576 0.3587 0.3600 0.3615 0.3632 0.3650 0.3669 0.3690
Columns 41 through 50
0.3713 0.3736 0.3761 0.3786 0.3813 0.3841 0.3870 0.3899 0.3930 0.3962
Columns 51 through 60
0.3994 0.4027 0.4061 0.4095 0.4131 0.4167 0.4204 0.4241 0.4279 0.4318
Columns 61 through 70
0.4357 0.4397 0.4437 0.4479 0.4520 0.4563 0.4605 0.4649 0.4693 0.4737
Columns 71 through 80
0.4782 0.4828 0.4874 0.4921 0.4968 0.5016 0.5065 0.5114 0.5163 0.5213
Columns 81 through 90
0.5264 0.5315 0.5367 0.5419 0.5472 0.5526 0.5580 0.5635 0.5690 0.5746
0.5803 0.5860 0.5918 0.5977 0.6036 0.6096 0.6157 0.6218 0.6280 0.6343
Column 101
0.6407
Gambar 1: x-y plot untuk sistem 2-butanol dan water dari persamaan NRTL pada 1 atm