Afifa Nur Alya - Matrikulasi (1-27) PDF
Afifa Nur Alya - Matrikulasi (1-27) PDF
Afifa Nur Alya - Matrikulasi (1-27) PDF
Tf=500:50:1000;
Tc=zeros(1,length(Tf));
for i = 1:length(Tf)
Tc(i)=(5/9)*Tf(i)-32;
formatSpec='Tf is %4.2f degF or %8.3f degC\n';
fprintf(formatSpec,Tf(i),Tc(i));
end
Tc=500:50:1000;
Tf=zeros(1,length(Tc));
for i = 1:length(Tc)
Tf(i)=(9/5)*Tc(i)+32;
formatSpec='Tc is %4.2f degC or %8.3f degF\n';
fprintf(formatSpec,Tc(i),Tf(i));
end
2. Let p be a bank interest in percent per year. An initial amount of C has then grow to:
𝑝 𝑛
𝐹 = 𝐶 (1 + ) (1)
100
After n years. An equation to predict the future value of the current value of the money
is described in equation (1). If someone has money with the amount of Rp 100,000,000.00,
how long does it take to be a billionaire if the interest rate of the bank is 5%?
%Bunga Bank dalam n Tahun
%clear
%clc
%lama seseorang hingga menjadi milyarder jika bunga bank 5%
C=1e8;
n=1;
F=C;
p=0.5;
while F<1e9
F=C*(1+5/100)^n;
n=n+1;
end
3. To find a root of a 2nd-degree polynomial equation we can easily use the “ABC formula”
shown in equation (2). So, try to find the root(s) of equation (3), (4), (5), and (6).
a=1;
b=-2;
c=-15;
D=b^2-4*a*c;
if D>0
x1=1/(2*a)*(-b+(sqrt(D)));
x2=1/(2*a)*(-b-(sqrt(D)));
b. Persamaan (4)
%MENGHITUNG NILAI AKAR PERSAMAAN
close all
clear all
clc
a=6;
b=7;
c=1;
D=b^2-4*a*c;
if D>0
x1=1/(2*a)*(-b+(sqrt(D)));
x2=1/(2*a)*(-b-(sqrt(D)));
a=1;
b=-24;
c=144;
D=b^2-4*a*c;
if D>0
x1=1/(2*a)*(-b+(sqrt(D)));
x2=1/(2*a)*(-b-(sqrt(D)));
d. Persamaan (6)
%MENGHITUNG NILAI AKAR PERSAMAAN
close all
clear all
clc
a=7;
b=-5;
c=12;
D=b^2-4*a*c;
if D>0
x1=1/(2*a)*(-b+(sqrt(D)));
x2=1/(2*a)*(-b-(sqrt(D)));
4. In MATLAB, we able to plot data in a figure. In this problem, try to plot the data resulted
𝜋 3𝜋
from equation (7) between 4 ≤ 𝑥 ≤ .
2
𝑓 (𝑥 ) = 2𝑒 sin(𝑥) (7)
>> x=[pi/4:3*pi/2];
>> y=2*exp(sin(x))
y=
>> plot(x,y,'.-r');
Matriculation Session 2: Numerical Integration and
Differentiation
1. Approximation for first derivative
forward
df f ( x x) f ( x)
first order error
dx x
df f ( x 2x) 4 f ( x x) 3 f ( x)
second order error
dx 2x
backward
df f ( x) f ( x x)
first order error
dx x
df 3 f ( x) 4 f ( x x) f ( x 2x)
second order error
dx 2x
centered
df f ( x x) f ( x x)
centered
dx 2x
2. Approximation for second order derivative
d2 f f ( x x) 2 f ( x) f ( x x)
centered
dx 2
x 2
xspan=0:0.5:5;
N=length(xspan);
dx=0.1;
dydx(1)=1/(2*dx)*(-sofun5(0+2*dx)+4*sofun5(0+dx)-3*sofun5(0+dx));
dydx(N)=1/(2*dx)*(3*sofun5(5)-4*sofun5(5-dx)+sofun5(5-2*dx));
for i=2:N-1
xnow=xspan(i);
Yplus=sofun5(xnow+dx);
Yminus=sofun5(xnow-dx);
dydx(i)=1/(2*dx)*(Yplus-Yminus);
end
x=xspan;
Yexact=x.^2+0.5.*x;
%plotting ya
plot(xspan,dydx,'ob','Markersize',18)
hold on
plot (xspan,Yexact,'-r','Linewidth',2)
6. Taken from H.S Fogler, Elements of Chemical Reaction Engineering 5 th ed. , p. 253
The reaction of triphenyl methyl chlorid (trityl) (A) and methanol (B) discussed here is now
analyzed using differential method: A + B → C + D. The reaction is carried out in a batch reactor
and concentration of A as a function of time is presented below:
Time (min) 0 50 100 150 200 250 300
CA, mol/L 5e-2 3.8e-2 3.06e-2 2.56e-2 2.22e-2 1.95e-2 1.74e-2
Calculate the reaction rate as dCA/dt as a function of time. You can use polyfit, polyval for this
exercise.
clear all
clc
close all
%latihan no6
%tanggal 6 feb
t=[0:50:300];
dt=50;
CA=[5e-2 3.8e-2 3.06e-2 2.56e-2 2.22e-2 1.95e-2 1.74e-2];
dCAdt=zeros(length(CA),1);
dCAdt(1)=(-CA(3)+4*CA(2)-3*CA(1))/(2*dt);
dCAdt(7)=(3*CA(7)-4*CA(6)+CA(5))/(2*dt);
for i=2:6
dCAdt(i)=(CA(i+1)-CA(i-1))/(2*dt);
end
plot(t,-dCAdt);
X=1:0.1:3;
Y=exp(X)+sqrt(X);
area=trapz(X,Y)
area_exact=(exp(3)+2/3*3^(1.5))-(exp(1)+2/3*1^(1.5));
20.1790
area_exact =
20.1647
8. Taken from J.M Smith, H.C. Van Ness, M.M. Abbott, Introduction to Chem. Eng.
Thermodynamics 6th ed., p. 139
Calculate the standard heat of reaction of the methanol-synthesis reaction at 800°C:
𝐶𝑂(𝑔) + 2 𝐻2 (𝑔) → 𝐶𝐻3 𝑂𝐻(𝑔)
Standard Enthalpies of Formation at 298.15 K:
Chemical species 0 𝐽
∆𝐻𝑓,298 ( )
𝑚𝑜𝑙 𝑓𝑜𝑟𝑚𝑒𝑑
𝐶𝑂(𝑔) -110525
𝐶𝐻3 𝑂𝐻(𝑔) -200660
𝐶𝑝 𝐷
Heat capacities: = 𝐴 + 𝐵 ∙ 𝑇 + 𝐶 ∙ 𝑇 2 + 𝑇2
𝑅
A B C D
CH3OH 2.211 12.216e-3 -3.45e-6 0
H2 3.249 0.422e-3 0 0.083e5
CO 3.376 0.557e-3 0 -0.031e5
𝑇𝑓𝑖𝑛𝑎𝑙
0
∆𝐶𝑝
∆𝐻𝑟 = ∆𝐻𝑟298 +𝑅∙∫ 𝑑𝑇
298.15 𝑅
clear all
clc
close all
%latihan no8
%tanggal 6 feb
%data
Metanol=[2.211 12.216e-3 -3.45e-6 0];
H2=[3.249 0.422e-3 0 0.083e5];
CO=[3.376 0.557e-3 0 -0.031e5];
R=8.314;
Tspan=298.15:100:1073.15;
dT=1073.15-298.15;
deltaHfCO=-110525;
deltaHfMetanol=-200660;
CpMetanol=(Metanol(1)+(Metanol(2).*Tspan)+(Metanol(3)*(Tspan.^2))+(Metano
l(4)./(Tspan.^2)));
CpH2=(H2(1)+(H2(2).*Tspan)+(H2(3).*(Tspan.^2))+(H2(4)./(Tspan.^2)));
CpCO=(CO(1)+(CO(2).*Tspan)+(CO(3).*(Tspan.^2))+(CO(4)./(Tspan.^2)));
deltaCp=CpMetanol-(2.*CpH2)-CpCO;
deltaHr298=deltaHfMetanol-deltaHfCO;
deltaHr=deltaHr298+R.*deltaCp.*dT;
Hasil di command window sebagai berikut:
>> deltaHr
deltaHr =
1.0e+005 *
Pada Workspace:
F=2.*sin(sqrt(x))-x;
End
x=2;
%solver
x=fzero(@sofun9b,x);
F=exp(-0.5*x)*(4-x)-2;
end
T=300;
%solver
T=fzero(@sofun10,T);
pt=76; %cmHg
pa0=exp(14.95-(3764/T));
pb0=exp(16.07-(4497/T));
pc0=exp(16.27-(4934/T));
xa=ya*pt/pa0;
xb=yb*pt/pb0;
xc=yc*pt/pc0;
F=xa+xb+xc-1;
end
𝑐𝑎𝑙
Diketahui data-data: ∆𝐻𝑅0 = −2𝑒4 𝑔𝑚𝑜𝑙 , TF=400 K, P=20 atm, Tref=298 K, A=8e-6 atm, B=4500
K, CPA=7, CPB=8 dan CPC=12 cal/mol/K. Untuk simulasi, gunakan tebakan awal z=0,1
Pada main program (M-file pertama):
% main program no 11
clear all
clc
close all
%Data
dHr0=-20000; %cal/gmol
Tf=400; %K
P=20; %atm
Tref=298; %K
A=8e-6; %atm
B=4500; %K
CPA=7; %cal/mol/K
CPB=8; %cal/mol/K
CPC=12; %cal/mol/K
zbawah=0.1;
zatas=0.5;
%solver
zfinal=fsolve(@sofun11,zbawah,[],dHr0,Tf,P,Tref,A,B,CPA,CPB,CPC);
z=zfinal;
%recalculation
%Hitung K dulu
PA=(0.25*(1-z))/(1-0.5*z)*P;
PB=(0.75-0.5*z)/(1-0.5*z)*P;
PC=(0.25*z)/(1-0.5*z)*P;
K=PC/(PA*PB^2);
%Hitung T1
T1=B/(log(K/A));
dHrf=dHr0+(CPC-CPA-2*CPB)*(Tf-Tref);
T2=Tf-(0.25*z*dHrf)/(0.25*(1-z)*CPA+(0.75-0.5*z).*CPB+(0.25*z*CPC));
F=T2-T1;
%plot
fprintf('Konversi A adalah zfinal=%4.2f\n',zfinal)
%Hitung K dulu
PA=(0.25*(1-z))/(1-0.5*z)*P;
PB=(0.75-0.5*z)/(1-0.5*z)*P;
PC=(0.25*z)/(1-0.5*z)*P;
K=PC/(PA*PB^2);
%Hitung T1
T1=B/(log(K/A));
dHrf=dHr0+(CPC-CPA-2*CPB)*(Tf-Tref);
T2=Tf-(0.25*z*dHrf)/(0.25*(1-z)*CPA+(0.75-0.5*z).*CPB+(0.25*z*CPC));
F=T2-T1;
end
Pada workspace:
𝐹𝑣 𝑥𝑜𝑢𝑡 1
𝑉= ∫ 𝑑𝑥
𝐶𝐴0 𝑥𝑖𝑛 𝑘 (1 − 𝑥 )2
Dari neraca panas diperoleh:
𝐶𝐴0 ∙ ∆𝐻𝑟 ∙ 𝑥
𝑇 = 𝑇0 −
𝜌 ∙ 𝐶𝑝
%data
xspan=linspace(0,0.8,50);
CA0=5;
dHr=-15;
rho=1.1;
Cp=0.8;
Vdata=8000;
Fv=200;
A=3.12e8;
E=18600;
R=1.987;
T0guess=300;
%solver
T0final=fsolve(@sofun12,T0guess,[],xspan,CA0,dHr,rho,Cp,Vdata,Fv,A,E,R);
%recalculation
T=T0guess-CA0.*dHr.*xspan./(rho.*Cp);
k=A.*exp(-E./(R.*T));
Y=1./(k.*(1-xspan).^2);
Vhit=Fv./CA0.*trapz(xspan,Y);
F=Vhit-Vdata;
%Plot
fprintf('Suhu masuk untuk x=%4.2f adalah %4.2f\n',xspan(end),T0final);
T=T0-CA0.*dHr.*xspan./(rho.*Cp);
k=A.*exp(-E./(R.*T));
Y=1./(k.*(1-xspan).^2);
Vhit=Fv./CA0.*trapz(xspan,Y);
F=Vhit-Vdata;
end
Pada workspace:
m1
13.
XM = 0,9
XE = 0,1
m2
XM = 0,3
mM = 30 kg/s XE = 0,5
mE = 25 kg/s XP = 0,2
mP =10 kg/s
m3
XM = 0,1
XE = 0,2
XP = 0,7
Gambar diatas merupakan model sederhana dari kolom distilasi, feed terdiri dari Methane
(M), Ethane (E), dan Pentane (P). Feed tersebut akan dipisahkan pada 3 streams menurut
komoponennya.
Neraca massa:
Methane : 0,9 M1 + 0,3 M1 + 0,1 M1 = 30
Ethane : 0,1 M2 + 0,5 M2 + 0,2 M2 = 25
Pentane : 0 M3 + 0,2 M3 + 0,7 M3 =10
A =
>> C=[30;25;10]
C =
30
25
10
>> B=A\C
B =
17.8846
45.9615
1.1538
%data
De=1e-5;
k=2e-5;
R=2;
CAf=5e-4;
N=10; %Berarti total titik 11, N+1
dr=R/N;
A=zeros(N+1,N+1);
r=linspace(0,R,N+1);
%solver
A(1,1)=-3; A(1,2)=4; A(1,3)=-1;
for i=2:10
%Bayangkan i=2
A(i,i-1)=(1./dr.^2-1./(2.*dr.*r(i)));
A(i,i)=(-2./dr.^2-k./De);
A(i,i+1)=(1./dr.^2+1./(2.*dr.*r(i)));
end
A(11,11)=1;
C=[0;0;0;0;0;0;0;0;0;0;CAf];
B=A\C;
z
v
D, Le
%data
rho=1;
myu=0.01;
g=981;
za=600;
zf=200;
Dt=200;
D=3;
Le=40000;
N=21;
zspan=linspace(za,zf,N);
vguess=80;
vstore=zeros(length(zspan),1);
for i=1:length(zspan)
z=zspan(i)
v=fsolve(@sofun222no4,vguess,[],rho,D,myu,g,Le,z);
vstore(i,1)=v;
end
%solver
theta=-(Dt./D).^2.*trapz(zspan,1./vstore);
%print
fprintf('Waktu pengosongan tangki adalah %4.2f menit\n',theta./60)
%data
Nb=40000;
rhos=2;
R0=0.5;
W=100000;
lamda=100;
Cp=1;
kx=0.01;
Tdata=200;
T0guess=330;
rspan=linspace(0,0.5,41);
%solver
T0final=fsolve(@sofun226no6,T0guess,[],R0,rspan,Nb,rhos,W,lamda,Cp,kx,Tda
ta);
%print
fprintf('Suhu mula-mula campuran adalah %4.2f K\n',T0final)
m0=4/3.*pi.*R0.^3.*rhos.*Nb;
m=4/3.*pi.*rspan.^3.*rhos.*Nb;
T=T0+lamda.*(m0-m)/(W+m0).*Cp;
x=(m0-m)./W; %vektor
xs=exp(8.8053-3333./T);
Y=1./(xs-x);
Thit=rhos./kx.*trapz(rspan,Y);
F=Tdata-Thit;
end
cm ; Le = 40000 cm. Dt
z
v
D, Le
%data
rho=1;
myu=0.01;
g=981;
z=600;
D=3;
Le=40000;
vguess=200;
%solver
v=fsolve(@sofun17,vguess,[],rho,myu,g,z,D,Le);
%plot
clc
fprintf('Kecepatan aliran adalah %4.2f\n',v)
Q=pi./4.*D.^2.*v;
fprintf('Debit tangki adalah %4.2f\n',Q)
1 υ,Q
D, Le z2
z1
Faktor friksi, f didekati dengan persamaan empiris:
0,0596
𝑓=
𝑅𝑒 0,215
Dengan
𝜌𝜐𝐷
𝑅𝑒 =
𝜇
Debit aliran dihitung dengan persamaan:
𝜋 2
𝑄= 𝐷 𝜐
4
Telah diketahui harga-harga:
Ρ = 1 g/cm3 ; µ = 0,01 g/cm.det ; g = 981 cm/det2 ; z1 = 300 cm ; z2 = 800 cm ; D = 4 cm ; dan
Le = 20000 cm.
Pada main program (M-file pertama):
clear all
clc
close all
%Hal 115 no 1
%data
rho=1;
myu=0.01;
g=981;
z1=300;
z2=800;
D=4;
Le=20000;
vguess=200;
%solver
v=fsolve(@sofun18,vguess,[],rho,myu,g,z1,z2,D,Le);
%print
clc
fprintf('Kecepatan aliran dalam pipa adalah %4.2f\n',v)
Q=pi./4.*D.^2.*v;
fprintf('Debit tangki adalah %4.2f\n',Q)
TF, XF
SO2=7.8% xin Xout
W kg katalis
TF, XF TF, XF
O2=10.8% Tin
SO2=7.8%
Tout
SO2=7.8%
N2=81.4% n n TF, XF
F gmol N2 TF, XF
SO2=7.8%
/jam
SO2=7.8%
R gmol N2/jam
n n
Tout, xout
Kecepatan reaksi mengikuti persamaan:
𝑝𝑆𝑂3
𝐾1 . 𝑝𝑂2 . 𝑝𝑆𝑂3 (1 −
1/2 )
𝑔𝑚𝑜𝑙 𝑆𝑂2 𝑝𝑆𝑂3 𝑝𝑂2 𝐾𝑝
𝑟( )=
𝑗𝑎𝑚 𝑥 𝑘𝑔 𝑘𝑎𝑡𝑎𝑙𝑖𝑠 22,414(1 + 𝐾2. 𝑝𝑆𝑂2 + 𝐾3 . 𝑝𝑆𝑂3 )2
Dengan:
5473
𝐾1=𝑒𝑥𝑝 (121,6 − )
𝑇
8619
𝐾2=𝑒𝑥𝑝 (−9,953 + )
𝑇
52596
𝐾3=𝑒𝑥𝑝 (−71,745 + )
𝑇
11300
𝐾𝑃=𝑒𝑥𝑝 (−10,68 + )
𝑇
Ingin dicari harga (R/F) yang memberikan W minimum.
Diketahui data-data: XF = 0; xout = 0.64; TF = 660 K; (X = Konversi SO2)
Diperoleh dari neraca massa SO2 dalam reaktor:
𝑅 𝑥𝑜𝑢𝑡 1
𝑊 = 137,3 (1 + ) ∫ 𝑑𝑥
𝐹 𝑥𝑖𝑛 𝑟
Diperoleh dari neraca massa SO2 dan neraca massa N2 pada pencampuran:
𝑅
𝑋𝐹 + (𝐹 ) 𝑥𝑜𝑢𝑡
𝑥𝑖𝑛 =
𝑅
1+ ( )
𝐹
Dari neraca panas:
T = TF + 241,7.(x – XF)
Sedangkan persamaan – persamaan stoikiometris menghasilkan:
1−𝑥
𝑝𝑆𝑂2 =
12,82 − 0.5𝑥
1,3846 − 0,5𝑥
𝑝𝑂2 =
12,82 − 0.5𝑥
𝑥
𝑝𝑆𝑂3 =
12,82 − 0.5𝑥
%data
xf=0;
Xout=0.64;
Tf=660;
N=40;
RFmin=0.1;
RFmax=12.5;
%solver
RFoptimum=fminbnd(@myfun19,RFmin,RFmax,[],xf,Xout,Tf,N);
%print
fprintf('Nilai RF optimum adalah %4.2f\n',RFoptimum)
k1=exp(12.16-(5474./T));
k2=exp(-9.953+(8619./T));
k3=exp(-71.745+(52596./T));
kp=exp(-10.68+(11300./T));
r=k1.*Po2.*Pso2.*(1-
(Pso3./(Pso2.*Po2.^0.5.*kp)))./(22.414.*(1+k2.*Pso2+k3.*Pso3).^2);
yspan=1./r;
RFoptimum=137.3.*(1+RF).*trapz(xspan,yspan);
end
%Data
IC=0.4; %initial condition (y) atau saat x=0.5 maka nilai y=0.4
xspan=0.5:0.1:1.5; %bersifat independent(yg berubah ubah
%Solver
[x,y]=ode15s(@sofun20,xspan,IC,[]);
z=0
z z+Δz Ts
Dari neraca massa:
𝑑𝑥 𝜋. 𝐷 2 . 𝑃 𝑘 0,9. (1 − 𝑥) 0,9. 𝑥 2 𝑃 1
= ( ) . (( )−( ) . . )
𝑑𝑧 3,6. 𝐹0 . 𝑅 𝑇 1 + 0,9. 𝑥 1 + 0,9. 𝑥 𝑅. 𝑇 𝐾
Dari neraca panas:
𝑑𝑥
𝑑𝑇 0,9. 𝐹0 . (−∆𝐻𝑅 ). − 𝑈. 𝜋. 𝐷. (𝑇 − 𝑇𝑆 )
= 𝑑𝑧
𝑑𝑧 𝐹0 . (0,9. (1 − 𝑥 ). 𝐶𝑝𝐴 + 0,9. 𝑥. (𝐶𝑝𝐵 + 𝐶𝑝𝐶 ) + 0,1. 𝐶𝑝𝐼
Dengan keadaan batas:
Z= 0; x = 0; T = T0
Dengan data U = 0,085 cal/cm2.det.K; F0 = 10 gmol/detik; x0 = 0; P = 7 atm; D = 35 cm; L =
3000 cm; CpA, CpB, CpC dan CpI masing – masing 20, 10, 15 dan 10 cal/gmol.K; ΔHR =-35000
cal/gmol; R = 82 (cm3.atm/gmol.K); A = 10000 detik-1; (E/R) = 6500K; α = -12,3; β = 4400 K; Tref
= 273K; T0 = 470 K; Ts = 421 K
Pada main program (M-file pertama):
clear all
clc
close all
%main program hal 135 (soal) tp langsung hal 138 (ringkasan persamaan)
%Data
delHr0=-35e3;
CpA=20;
CpB=10;
CpC=15;
CpI=10;
Tref=273;
Ar=1e4;
R=82;
E=6500.*R;
alfa=-12.3;
beta=4400;
P=7;
Di=35;
F0=10;
U=0.0085;
Ts=421;
T0=470;
L=3e3;
zspan=linspace(0,L,50);
IC=[0 T0];
%Solver
[z,y]=ode15s(@sofun21,zspan,IC,[],delHr0,CpA,CpB,CpC,CpI,Tref,Ar,E,R,alfa
,beta,P,Di,F0,U,Ts)
%Recalculatiom
x=y(:,1); %konversi
T=y(:,2); %suhu
%plotting or print
subplot(2,1,1)
plot(z,x,'b','LineWidth',2)
grid on
subplot(2,1,2)
plot(z,T,'r','LineWidth',2)
grid on
delHr=delHr0+(CpB+CpC-CpA).*(T-Tref);
k=Ar.*exp(-E./(R.*T)); %Ar=A=
K=exp(alfa+beta./T);
A=0.9.*(1-x)./(1+0.9.*x);
B=(0.9.*x./(1+0.9.*x)).^2.*P./R./T.*1./K;
dxdz=pi.*Di.^2.*P.*k./(3.6.*F0.*R.*T).*(A-B); %Di=D=Diameter
C=0.9.*F0.*(-delHr).*dxdz-U.*pi.*Di.*(T-Ts);
D=F0.*(0.9.*(1-x).*CpA+0.9.*x.*(CpB+CpC)+0.1.*CpI);
dTdz=C./D;
dYdz=[dxdz;dTdz];
end
Hasil plot:
22. Buku WBS dan AP hal 196
Difusi dalam padatan mengontrol
Karena slab tipis dan luas permukaannya relative sangat besar, maka difusi solute dalam
padatan berlangsung satu arah (tegak lurus permukaan yang luas)
padatan
Cairan Cairan
Cf Cf
x x+Δx
x=0 x=1
Difusi solute dalam padatan dianggap mengikuti hukum Fick yang berbentuk:
𝑠𝑜𝑙𝑢𝑡
𝑔 𝜕𝐶𝐴
𝑁𝐴 ( 𝑤𝑎𝑘𝑡𝑢) = −𝐷𝑒
𝑙𝑢𝑎𝑠 𝜕𝑥
for i=2:N
d2CAd2x(i)=1./dx.^2.*(CA(i+1)-2.*CA(i)+CA(i-1));
dCAdt(i)=De.*d2CAd2x(i);
end
%Data
Cf=0.004;
H=0.4;
De=1e-5;
N=40;
L=0.04;
xspan=linspace(0,L,N+1);
dx=L./N;
CAin=0.08;
tspan=0:1:20;
IC=CAin.*ones(N,1);
%solver
[t,CA]=ode15s(@sofun22,tspan,IC,[],Cf,H,dx,De,N);
%recalculation
CA(:,1)=1./3.*(4.*CA(:,2)-CA(:,3));
CA(:,N+1)=Cf./H;
%plotting
%plot (xspan,CA)
imagesc(xspan,tspan,CA)
colormap jet
colorbar
Hasil plotting:
23. Buku WBS dan AP hal 258
Ingin dicari distribusi suhu pada slab luas tak berhingga pada keadaan unsteady. Suhu slab
mula – mula Tin. Mulai suatu saat salah satu permukaan slab (x=0) diberi flux sebesar q,
sedang permukaan yang lain (x=L) dikontakkan dengan cairan bersuhu tetap T. Koefesien
perpindahan panas antara permukaan slab dengan cairan = h.
Diketahui: ρ = 2 g/cm3; k = 0,01 cal/det/cm/0C; c = 0,5 cal/g/0C; h = 0,008 cal/detik/cm2/0C; q
= 2 cal/detik/cm2; Tin = 200 0C; Tf = 100 0C; tebal slab L = 2 cm.
Persamaan Diferensial
𝜕2𝑇 𝜌 𝑐 𝜕𝑇
2
=
𝜕𝑥 𝑘 𝜕𝑡
Pada subroutine (M-file pertama)
function dTdt=sofun23(t,T,N,q,dx,k,Tf,beta,alfa)
dTdt=zeros(N,1);
T(1)=1./3.*(2.*q.*dx./k-T(3)+4.*T(2));
T(N+1)=(Tf+4.*beta.*T(N)-beta.*T(N-1))./(1+3.*beta);
for i=2:N
d2Td2x(i)=1./dx.^2.*(T(i+1)-2.*T(i)+T(i-1));
dTdt(i)=alfa.*d2Td2x(i);
end
%data
N=40;
q=2;
L=2;
dx=L./N;
k=0.01;
h=0.008;
Tf=100;
rho=2;
cp=0.5;
beta=k./(2.*h.*dx);
alfa=k./rho./cp;
tspan=0:0.1:200;
xspan=0:dx:L;
Tin=200;
IC=Tin.*ones(1,N);
%solver
[t,T]=ode15s(@sofun23,tspan,IC,[],N,q,dx,k,Tf,beta,alfa);
%recalculation
T(:,1)=1./3.*(2.*q.*dx./k-T(:,3)+4.*T(:,2));
T(:,N+1)=(Tf+4.*beta.*T(:,N)-beta.*T(:,N-1))./(1+3.*beta);
%plotting
imagesc(xspan,tspan,T)
colormap jet
colorbar
Hasil plotting
dTdt=zeros(N,1);
for i=2:N
d2Tdr2(i)=1./dr.^2.*(T(i+1)-2.*T(i)+T(i-1)); %center 2nd order
dTdr(i)=1./(2.*dr).*(T(i+1)-T(i-1)); %center 1st order
dTdt(i)=alfa.*(d2Tdr2(i)+2./r(i).*dTdr(i)); %dari persamaan
diferensial
end
Pada main program (M-file kedua)
clear all
clc
close all
%main program hal 265
%data
rho=1.75;
k=0.01;
cp=2.25;
h=0.008;
q=2;
Tf=300;
L=2;
N=10;
R=5;
dr=R./N;
beta=k./(2.*h.*dr);
alfa=k./rho./cp;
r=linspace(0,R,N+1);
tspan=0:1:500;
xspan=0:dr:L;
Tin=500;
IC=Tin.*ones(1,N);
%solver
[t
T]=ode15s(@sofun24,tspan,IC,[],rho,k,cp,h,q,Tin,Tf,L,N,dr,R,r,alfa,beta)
%plotting
sumbux=r;
sumbuy=tspan;
imagesc(sumbux,sumbuy,T)
colormap jet
colorbar
Hasil plotting
25. An undergraduated student is conducting a labwork to study the phase equilibrium of
binary mixture: n-pentane (component 1) and acetone (component 2). Phase equilibrium
data were obtained from the literature data of Lo et al. ln J. Chem. Eng.
x1 0.021 0.134 0.292 0.503 0.728 0.953
y1 0.108 0.475 0.614 0.648 0.739 0.906
0
T ( C) 49.15 39.58 34.35 33.35 31.93 33.89
sat
P1 1.560 1.146 0.960 0.903 0.880 0.954
P2sat 0.803 0.551 0.453 0.421 0.410 0.445
The equilibrium model used the Gibbs Excess Energy Equilibrium Model as follows:
𝐺2 𝑦1 .𝑃
= 𝑥1 𝑙𝑛𝛾1 + 𝑥2 𝑙𝑛𝛾2 with 𝛾1 =
𝑅𝑇 𝑥1 𝑃1𝑠𝑎𝑡
Afterwards, the student wants to do a parameter estimation to the Gibbs Excess Energy
Model with various models, namely:
One Parameters Margules
𝐺𝐸
= 𝐴. 𝑥1 . 𝑥2
𝑅𝑇
Two Parameters Margules
𝐺𝐸
= 𝑥1 . 𝑥2 . (𝐴21 . 𝑥1 + 𝐴12 . 𝑥2 )
𝑅𝑇
Van Laar
𝐺𝐸 𝐴12 . 𝐴21 . (𝑥1 . 𝑥2 )
=
𝑅 𝑇 (𝑥1 . 𝐴12 + 𝑥2 . 𝐴22 )
Calculate the parameter values of each model by doing the fitting process (minimizing SSE)
to the experimental data!
a. Metode One Parameter Margules
Pada subroutine:
function Fobj=sofun25(P,x1,x2,GERTexp)
A=P;
GERTcalc=A.*x1.*x2; %One paraameter Margules
residual=GERTcalc-GERTexp;
Fobj=sum(residual.^2); %ini SSE yang ingin diminimasi
End
%Data
x1=[0.021 0.134 0.292 0.503 0.728 0.953];
y1=[0.108 0.475 0.614 0.678 0.739 0.906];
T=[49.15 39.58 34.35 33.35 31.93 33.89];
P1sat=[1.560 1.146 0.960 0.903 0.880 0.954];
P2sat=[0.803 0.551 0.453 0.421 0.410 0.445];
Pt=1; % 1 bar
x2=1-x1;
y2=1-y1;
GERTexp=x1.*log(gamma1)+x2.*log(gamma2);
%Recalculation
A=Popt
GERTcalc=A.*x1.*x2; %one parameter margules
%Plotting
plot(x1,GERTexp,'bs','MarkerSize',14)
hold on
plot(x1,GERTcalc,'b','LineWidth',2)
Hasil plotting
b. Metode Two Parameter Margules
Pada subroutine
function Fobj=sofun26(P,x1,x2,GERTexp)
A12=P(1);
A21=P(2);
GERTcalc=x1.*x2.*(A21.*x1+A12.*x2); %two paraameter Margules
residual=GERTcalc-GERTexp;
Fobj=sum(residual.^2); %ini SSE yang ingin diminimasi
End
%Data
x1=[0.021 0.134 0.292 0.503 0.728 0.953];
y1=[0.108 0.475 0.614 0.678 0.739 0.906];
T=[49.15 39.58 34.35 33.35 31.93 33.89];
P1sat=[1.560 1.146 0.960 0.903 0.880 0.954];
P2sat=[0.803 0.551 0.453 0.421 0.410 0.445];
Pt=1; % 1 bar
x2=1-x1;
y2=1-y1;
GERTexp=x1.*log(gamma1)+x2.*log(gamma2);
%Recalculation
A12=Popt(1);
A21=Popt(2);
GERTcalc=x1.*x2.*(A21.*x1+A12.*x2); %Two paraameter Margules
%Plotting
plot(x1,GERTexp,'bs','MarkerSize',14)
hold on
plot(x1,GERTcalc,'b','LineWidth',2)
Hasil plotting
%Data
x1=[0.021 0.134 0.292 0.503 0.728 0.953];
y1=[0.108 0.475 0.614 0.678 0.739 0.906];
T=[49.15 39.58 34.35 33.35 31.93 33.89];
P1sat=[1.560 1.146 0.960 0.903 0.880 0.954];
P2sat=[0.803 0.551 0.453 0.421 0.410 0.445];
Pt=1; % 1 bar
x2=1-x1;
y2=1-y1;
GERTexp=x1.*log(gamma1)+x2.*log(gamma2);
%Recalculation
A12=Popt(1);
A21=Popt(2);
GERTcalc=(A12.*A21.*(x1.*x2))./(x1.*A12+x2.*A21); %Van Laar
%Plotting
plot(x1,GERTexp,'bs','MarkerSize',14)
hold on
plot(x1,GERTcalc,'b','LineWidth',2)
Hasil plotting
residual=kcalc-kdata;
Fobj=sum(residual.^2);
end
Pguess=[8 1];
%solver
[Popt,SSEout]=fminsearch(@sofun27,Pguess,[],kdata,c)
%recalculation
kmax=Popt(1);
cs=Popt(2);
kcalc=(kmax.*c.^2)./(cs+c.^2);
%plotting
plot(c,kdata,'bo','MarkerSize',16)
hold on
plot(c,kdata,'LineWidth',2)
Hasil plotting
27. Buku WBS dan AP hal 183-192
Reaksi gas-cair
A (gas) + B (larutan) hasil larutan
Dijalankan dalam tangki berpengaduk yang bekerja secara batch. Mula mula tangki diisi
larutan B sebanyak V liter dengan konsumsi CB0 gmol/liter. Mulai suatu saat, gas A murni
dengan tekanan PA digelembungkan dari dasar tangki. Terjadi dua proses yang berlangsung
seri, yaitu transfer massa A dari fasa gas ke fasa cairan (pelarut) dan reaksi fasa cair antara A
terlarut dengan B terlarut. Kecepatan transfer massa A dari gas ke cairan mengikuti
persamaan:
NA = kca (C*A-CA)
Hubungan kesetimbangan uap-cair mengikuti persamaan:
PA = HA.CA HA = Tetapan Henry
Kecepatan reaksi fasa cair antara A dan B dapat didekati dengan persamaan:
ra = kr.CA.CB
Dari transfer massa dan reaksi kimia mengontrol (mixed regime):
𝑑𝐶𝐴
= 𝑘𝑐 𝑎. (𝐶𝐴∗ − 𝐶𝐴 ) − 𝑘𝑟 . 𝐶𝐴 . 𝐶𝐵
𝑑𝑡
𝑑𝐶𝐵
= −𝑘𝑟 . 𝐶𝐴 𝐶𝐵
𝑑𝑡
Missal suatu percobaan dengan C A0 = 0 gmol/liter; CB0 = 2 gmol/liter; PA=5; dan HA=20
menghasilkan data CB pada berbagai waktu sebagai berikut:
t,menit 0 5 10 15 20 25 30 35 40
CB,gmol/L 2,0 1,80 1,58 1,36 1,15 0,95 0,76 0,59 0,44
Ingin dicari harga kca dan kr berdasar data percobaan tersebut, dan akan dibandingkan harga
CB pada berbagai waktu hasil perhitungan kca dank r yang diperoleh dengan CB hasil
percobaan.
IC=[CA0 CB0];
[t C]=ode15s(@myode28,tdata,IC,[],PA,HA,kca,kr);
Cbhit=C(:,2);
res=Cbdata'-Cbhit;
Fobj=sum(res.^2);
end
CA=C(1);
CB=C(2);
CAstar=PA./HA;
dCAdt=kca.*(CAstar-CA)-kr.*CA.*CB;
dCBdt=-kr.*CA.*CB;
dCdt=[dCAdt;dCBdt];
end
%Data
tdata=0:5:40;
Cbdata=[2 1.8 1.58 1.36 1.15 0.95 0.76 0.59 0.44];
CA0=0;
CB0=2;
PA=5;
HA=20;
Pguess=[0.1 0.1] %kca kr
%Solver
[Popt,SSEout]=fminsearch(@myres28,Pguess,[],tdata,Cbdata,CA0,CB0,PA,HA)
%Recalculation
kca=Popt(1);
kr=Popt(2);
IC=[CA0 CB0];
[t C]=ode15s(@myode28,tdata,IC,[],PA,HA,kca,kr);
Cbhit=C(:,2);
%Plotting
plot(tdata,Cbdata,'bo','MarkerSize',16)
hold on
plot(tdata,Cbhit,'LineWidth',2)
Hasil plotting: