Anda di halaman 1dari 31

# Pertemuan 9

-------------soal no 1-----

>> f1=inline('sqrt(1/f)+0.86*log(10^-4/3.7+2.51/10^5*sqrt(f))');

>> hargaf=fzero(f1,0.01)

hargaf =

0.0125

------soal no2--------

function [f]=hitflash(v)

## K=[3.09 1.65 0.72 0.39 0.21 0.175 0.093 0.065 0.036];

F=100;

f=(Z(1)*K(1)*F/(v*(K(1)-1)+F)+Z(2)*K(2)*F/(v*(K(2)-1)+F)+...

Z(3)*K(3)*F/(v*(K(3)-1)+F)+Z(4)*K(4)*F/(v*(K(4)-1)+F)+...

Z(5)*K(5)*F/(v*(K(5)-1)+F)+Z(6)*K(6)*F/(v*(K(6)-1)+F)+...

Z(7)*K(7)*F/(v*(K(7)-1)+F)+Z(8)*K(8)*F/(v*(K(8)-1)+F)+Z(9)*K(9)*F/(v*(K(9)-1)+F))-1;

>> hargav=fzero(@hitflash,50)

hargav =

88.6699
------soal no 3 ---------

>> roots(P1)

ans =

-4.3500

-2.8591

-2.8409

-1.4500

## >> P1=[1 11.50 47.49 83.0632+2.98*65 51.2327+7.705*65];

>> roots(P1)

ans =

-8.8729

-0.0211 + 4.9061i

-0.0211 - 4.9061i

-2.5848

## >> P1=[1 11.50 47.49 83.0632+2.98*66 51.2327+7.705*66];

>> roots(P1)

ans =
-8.9018

-0.0067 + 4.9322i

-0.0067 - 4.9322i

-2.5849

## --------no 4 cari konversi---------

function [f]=konvrxbnyk(x)

CA=40-30*x(1)-10*x(2);

CB=15-15*x(1);

CC=15*x(1)+10*x(2);

CD=10-10*x(2);

f(1)=(CC/(CA^2*CB))-5e-4;

f(2)=(CC/(CA*CD))-4e-2;

f=[f(1);f(2)];

## >> konversi=fsolve(@konvrxbnyk,[0.3 0.3])

Optimization terminated: first-order optimality is less than options.TolFun.

konversi =

0.1203 0.4786

## -----------soal 5 cari konsentrasi-------

function [f]=konsrxbnyk1(C)

k1=55.2;k2=30.2;

ch0=0.021;cm0=0.0105;

tau=0.5;

rh=k1*C(1)^0.5*C(2);

rm=k2*C(1)^0.5*C(3);

f(1)=C(1)-ch0+(rh+rm)*tau;

f(2)=C(2)-cm0+rh*tau;

f(3)=-C(3)+(rh-rm)*tau;

f=[f(1);f(2);f(3)];

konsentrasi =

Pertemuan 10

## -----------soal 1 persamaan reaksi-------------

>> A=[0 6 0 0; 1 10 0 2; 3 4 1 1; 1 0 1 0]

A=

0 6 0 0

1 10 0 2

3 4 1 1

1 0 1 0

>> B=[6;12;1;0]

B=

12

>> x=inv(A)*B

x=

-2.6667

1.0000

2.6667
2.3333

>> x=inv(A)*B

x=

-8/3

8/3

7/3

## --------soal 2 neraca massa--------

>> A=[1 1 0 0 0 0 0 0 0 0 0 0 0 0 0;

1 0 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0;

0.65 0 0 0 0 -1 0 0 0 0 0 0 0 0 0;

0.05 0 0 0 -1 0 0 0 0 0 0 0 0 0 0;

0 0 0 1 0 0 0 0 0 0 0 0 0 0 0;

0 0 0 0 0 1 0 0 0 -1 0 0 0 0 0;

0 0 0 0 1 0 0 0 -1 0 0 0 0 0 0;

0 0 0 0 0 0 1 0 0 0 -1 0 0 0 0;

0 0.3 0 0 0 0 0 1 0 0 0 0 -1 0 0;

0 0.65 0 0 0 0 0 0 0 1 0 -1 0 0 0;

0 0.05 0 0 0 0 0 0 1 0 0 0 0 -1 0;
0 0 0 0 0 0 0 0 0 0 1 0 0 0 -1;

## 0 0 0 0 0 0 0 0 0 0 0 0.03 0.03 0.03 -0.97;

-0.2 0 1 0 0 0 0 0 0 0 0 0 0 0 0;

0 0 0 -0.5 0 0 1 0 0 0 0 0 0 0 0];

>> B=[1000; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0 ];

>> x=inv(A)*B

x=

1000

-1000

650

-700

50

0
>> A=[-6 5 0 0 0 0 0 0 0 0;

1 -6 5 0 0 0 0 0 0 0;

0 1 -6 5 0 0 0 0 0 0;

0 0 1 -6 5 0 0 0 0 0;

0 0 0 1 -6 5 0 0 0 0;

0 0 0 0 1 -6 5 0 0 0;

0 0 0 0 0 1 -6 5 0 0;

0 0 0 0 0 0 1 -6 5 0;

0 0 0 0 0 0 0 1 -6 5;

0 0 0 0 0 0 0 0 1 -6];

## >> format long

>> inv(A)*B

ans =

0.009999999180800

0.001999999016960

0.000399998984192

0.000079998977638

0.000015998976328

0.000003198976066

0.000000638976013

0.000000126976003

0.000000024576001

0.000000004096000
Pertemuan 11

## ------------soal reaksi a->3b---------------

FA0=0.867

konversi=0.65

>> x=0:0.1:0.85;

>> x(10)=0.85;

>> rA=[0.0053 0.0052 0.0050 0.0045 0.0040 0.0033 0.0025 0.0018 0.00125 0.0010];

>> perrA=1./rA;

## >> perrAantara=interp1(x,perrA,[0.05 0.15 0.25 0.35 0.45 0.55 0.65]);

>> hargaintegral=(0.05/2)*(perrA(1)+2*perrAantara(1)+2*perrA(2)+2*perrAantara(2)+...

2*perrA(3)+2*perrAantara(3)+2*perrA(4)+2*perrAantara(4)+2*perrA(5)+2*perrAantara(5)+...

2*perrA(6)+2*perrAantara(6)+2*perrA(7)+perrAantara(7))

hargaintegral =

168.1344

>> Vpfr=0.867*hargaintegral

Vpfr =

145.7725

-rA=2.5CA^0.5 CB

## A=0.2 B=0.5 inert=0.30

V0=50

>> xA=0:0.1:0.7;

>> fxA=(1-0.2*xA).^(3/2)./((1-xA).^(1/2).*(2.5-2*xA));

>> CA0=0.2*5/(0.082*(273.15+55));

>> volumePFR1=(50*CA0/(2.5*CA0^(3/2)))*trapz(xA,fxA)

volumePFR1 =

50.4178

--------------SOAL 3--------------

function [ f ] = reakbanyakPFR(tau,C)

k1=55.2;k2=30.2;

rh=k1*C(1)^0.5*C(2);

rm=k2*C(1)^0.5*C(3);

f(1)=-(rh+rm);

f(2)=-rh;

f(3)=rh-rm;

f=[f(1);f(2);f(3)];

tau =

0.0500

0.1000

0.1500

0.2000

0.2500

0.3000

0.3500

0.4000

0.4500

0.5000

C=

0.0210 0.0105 0

## 0.0063 0.0010 0.0042

0.0056 0.0008 0.0039

## 0.0050 0.0007 0.0037

>> plot(tau,C)

>> plot(tau,C),legend('CM','CH','CK')

function [ f ] = reakbnykskliPFR(V,F)

k1=5;k2=2;k3=10;k4=5;

CT0=2;

FT=F(1)+F(2)+F(3)+F(4)+F(5)+F(6);

r1A=-k1*CT0^3*F(1)*F(2)^2/FT^3;

r2A=-k2*CT0^2*F(1)*F(2)/FT^2;

r3B=-k3*CT0^3*F(3)^2*F(2)/FT^3;

r4C=-k4*CT0^(5/3)*F(3)*F(1)^(2/3)/FT^(5/3);

rA=r1A+r2A+2/3*r4C;

rB=1.25*r1A+0.75*r2A+r3B;

rC=-r1A+2*r3B+r4C;

rD=-1.5*r1A-1.5*r2A-r4C;

rE=-r2A/2-(5/6)*r4C;

rF=-2*r3B;

f(1)=rA;

f(2)=rB;

f(3)=rC;
f(4)=rD;

f(5)=rE;

f(6)=rF;

f=[f(1);f(2);f(3);f(4);f(5);f(6)];

## >> [V f]=ode45(@reakbnykskliPFR,[0:10],[10 10 0 0 0 0])

V=

10

f=

10.0000 10.0000 0 0 0 0

## 6.2635 6.1864 1.6235 5.6048 0.9568 0.1994

4.6998 4.7900 1.5729 7.9503 1.6395 0.4484

## 1.5041 2.4001 0.6038 12.7438 3.4830 0.9261

>> plot(V,f)

>> plot(V,f),legend('CA','CB','CC','CD','CE','CF')
Pertemuan 12

## >> Cp=[41.29 45.50 48 51.31 55.61 60.30 65.26];

>> pol=polyfit(T,Cp,2)

pol =

## -0.0000 0.0648 16.7954

>> Ta=linspace(525,810,10);

>> hargaQ=trapz(Ta,polyval(pol,Ta))

hargaQ =

1.5938e+004

## ------------------------------soal 2 dinamika fluida-----------------------

function fv=kecepatanalir(v)

% data

## rho=1; miu=0.01; g=981;

z1=300; z2=800;

D=4; Le=20000;

% masuk ke rumus

Q=pi/4*D^2*v;

Hm=3718.5-2.3496*Q+7.847e-4*Q^2-9.5812e-8*Q^3;

Nre=rho*v*D/miu;

f=0.0596/Nre^0.215;

fv=z2-z1+f*Le*v^2/(2*g*D)-Hm;

>> V=fzero(@kecepatanalir,200)

V=

227.6324

## ----------------------------soal 3 pengisian tangki-----------------------

function [v]=aplikasi21(z)

## global rho miu D Dt1 Dt2 Le g z11 z21 v

v0=0.4*sqrt(2*g*z)

v=fsolve(@aplikasi23,v0,[],z)

function [fv]=aplikasi23(v,z)

## global rho miu D Dt1 Dt2 Le g z11 z21

Q=pi/4*D^2*v;

Re=rho*v*D/miu;

f=0.0596./Re.^0.215;

Hm=3718.5-2.3496*Q+7.847e-4*Q.^2-9.5812e-8*Q.^3;

z1=z11-(Dt2/Dt1)^2*(z-z21);

fv=z-z1+Le*f.*v.^2/(2*g*D)-Hm;

## rho=1; miu=0.01; g=981;

z11=500; z21=600;

Dt1=350; Dt2=300;

D=4; Le=20000;

%za=600; zf=1000;

z=linspace(600,1000,10);

aplikasi21(z);

fz=1./v

hargaintegral=trapz(z,fz)

waktu=(Dt2/D)^2*hargaintegral/60

>> tpengisiantangki

v0 =

## 433.9954 449.7822 465.0333 479.8000 494.1255 508.0472 521.5975 534.8046 547.6933

560.2856
Optimization terminated: first-order optimality is less than options.TolFun.

v=

## 272.0543 264.4354 256.3705 247.8449 238.8612 229.4479 219.6676 209.6211 199.4424

189.2842

fz =

0.0037 0.0038 0.0039 0.0040 0.0042 0.0044 0.0046 0.0048 0.0050 0.0053

hargaintegral =

1.7368

waktu =

162.8253
Pertemuan 13

-------------------------------------no 1-----------------------------

function [f]=latihanUTS1(x,y)

f(1)=(y(1)*y(2))+1;

f(2)=(y(1)*y(2))-1;

f=[f(1);f(2)];

## >> [x,y]=ode45(@latihanUTS1,[0:0.1:0.2],[0 0])

x=

0.1000

0.2000

y=

0 0

0.0997 -0.1003

0.1973 -0.2027

----------------------------------no 2--------------------------------

function f=latihanUTS2(x,y)

f(1)=y(2);

f(2)=y(3);
f(3)=(-(1-x^3)*y(3)-y(1)*y(2))/y(1)^2;

f=[f(1);f(2);f(3)];

x=

0.1000

0.2000

0.3000

0.4000

0.5000

y=

## 1.2176 1.1646 0.6657

---------------------------no 3--------------------------------

function ft=fungsireaktorbatch(x)

global CA0 k tp

tr=x/(k*CA0*(1-x));
ts=tr+tp;

ft=CA0*x/ts;

global CA0 k tp

## CA0=2; k=0.025; tp=45;

x0=0.01; xn=0.99;

xmin=fminbnd(@fungsireaktorbatch,x0,xn)

>> xopt=fminbnd(@fungsireaktorbatch,x0,xn)

xopt =

0.0101

## 1.5912 1.3095 0.3235

Pertemuan 14

----------------------------no 1----------------------

## %program diambil buku Komputasi Numerik

%Suaraga

clear;help fdlinier;

%definisi fungsi

p=inline('-2/x');

q=inline('2');

r=inline('x');

%nilai beta

N=9;

## %definisi vektor solusi

a=zeros(N,1);

b=zeros(N,1);

c=zeros(N,1);

d=zeros(N,1);

l=zeros(N,1);

u=zeros(N,1);

z=zeros(N,1);

w=zeros(N+2,1);

%iterasi dimulai

h=(b0-a0)/(N+1);

x=a0+h;

a(1)=2+h^2*q(x);
b(1)=-1+(h/2)*p(x);

d(1)=-h^2*(x)+(1+(h/2)*p(x))*alpha;

for i=2:(N-1)

x=a0+i*h;

a(i)=2+h^2*q(x);

b(i)=-1+(h/2)*p(x);

c(i)=-1-(h/2)*p(x);

d(i)=-h^2*r(x);

end

x=b0-h;

a(N)=2+h^2*q(x);

c(N)=-1-(h/2)*p(x);

d(N)=-h^2*r(x)+(1-(h/2)*p(x))*beta;

l(1)=a(1);

u(1)=b(1)/l(1);

for i=2:(N-1)

l(i)=a(i)-c(i)*u(i-1);

u(i)=b(i)/l(i);

end

l(N)=a(N)-c(N)*u(N-1);

z(1)=d(1)/l(1);

for i=2:N

z(i)=(d(i)-c(i)*z(i-1))/l(i);

end

w(1)=alpha;

w(N+2)=beta;

w(N+1)=z(N);
for i=N:-1:2

w(i)=z(i-1)-u(i-1)*w(i+1);

end

disp('step x w');

for i=1:N+2

x=a0+(i-1)*h;

end

>> bebas

## Use the Help browser Search tab to search the documentation, or

type "help help" for help command options, such as help for methods.

step x w

0 1.00 0.40000000

1 1.10 0.35118592

2 1.20 0.32702927

3 1.30 0.32370340

4 1.40 0.33893573

5 1.50 0.37153054

6 1.60 0.42107971

7 1.70 0.48778458

8 1.80 0.57234707
9 1.90 0.67590535

10 2.00 0.80000000

--------------------------no 2-----------------------

## %program diambil buku Komputasi Numerik

%Suaraga

clear;help fdlinier;

%definisi fungsi

p=inline('-2/x');

q=inline('2/x^2');

r=inline('sin(log(x))/x^2');

%nilai beta

N=9;

## %definisi vektor solusi

a=zeros(N,1);

b=zeros(N,1);

c=zeros(N,1);

d=zeros(N,1);

l=zeros(N,1);

u=zeros(N,1);

z=zeros(N,1);

w=zeros(N+2,1);
%iterasi dimulai

h=(b0-a0)/(N+1);

x=a0+h;

a(1)=2+h^2*q(x);

b(1)=-1+(h/2)*p(x);

d(1)=-h^2*(x)+(1+(h/2)*p(x))*alpha;

for i=2:(N-1)

x=a0+i*h;

a(i)=2+h^2*q(x);

b(i)=-1+(h/2)*p(x);

c(i)=-1-(h/2)*p(x);

d(i)=-h^2*r(x);

end

x=b0-h;

a(N)=2+h^2*q(x);

c(N)=-1-(h/2)*p(x);

d(N)=-h^2*r(x)+(1-(h/2)*p(x))*beta;

l(1)=a(1);

u(1)=b(1)/l(1);

for i=2:(N-1)

l(i)=a(i)-c(i)*u(i-1);

u(i)=b(i)/l(i);

end

l(N)=a(N)-c(N)*u(N-1);

z(1)=d(1)/l(1);

for i=2:N

z(i)=(d(i)-c(i)*z(i-1))/l(i);
end

w(1)=alpha;

w(N+2)=beta;

w(N+1)=z(N);

for i=N:-1:2

w(i)=z(i-1)-u(i-1)*w(i+1);

end

disp('step x w');

for i=1:N+2

x=a0+(i-1)*h;

end

>> odebc

## Use the Help browser Search tab to search the documentation, or

type "help help" for help command options, such as help for methods.

step x w

0 1.00 1.00000000

1 1.10 1.08375167

2 1.20 1.18004854

3 1.30 1.27782160

4 1.40 1.37709415
5 1.50 1.47781773

6 1.60 1.57990954

7 1.70 1.68327257

8 1.80 1.78780643

9 1.90 1.89341315

10 2.00 2.00000000

---------------------------no 3-----------------------

global vp T

%data-data

## vp=[1 5 10 20 40 60 100 200 400 760]; %tekanan uap

T=[-36.7 -19.6 -11.5 -2.6 7.6 15.4 26.1 42.2 60.6 80.1]; %temperatur

## Ko=[10 2000 273];

%optimasi

K=fminsearch(@fungsiantoine,Ko)

%evaluasi parameter

z=10.^(K(1)-(K(2)./(T+K(3))));

%menampilkan hasil

plot(T,z,'k-',T,vp,'Ko','linewidth',2)

set(gca,'fontsize',14)

xlabel('T(C)')

ylabel('vp(mmHg)')
function [ ff ] = fungsiantoine( K )

## %fungsi untuk menyelesaikan optimasi banyak variabel

global vp T

%perhitungan minimasi

f=log10(vp)-K(1)+K(2)./(T+K(3));

ff=sum(f.*f);

>> parpersantoine

K=

## 5.7673 677.0928 153.8852

-----------------no 4--------------

## global xin xout

xin=0;

xout=0.64;

%perhitungan

[T0,Wmin]=fminsearch(@fungsimenghitungkatalis,600)

function W=fungsimenghitungkatalis(Tf)
%fungsi untuk menghitung berat katalis

## %distribusi nilai konversi

x=linspace(xin,xout,100);

T=Tf+241.7*(x);

## %perhitungan tekanan parsial

pSO2=(1-x)./(12.82-0.5*x);

pO2=(1.3846-0.5*x)./(12.82-0.5*x);

pSO3=x./(12.82-0.5*x);

## %perhitungan kecepatan reaksi

k1=exp(12.16-5473./T);

K2=exp(-9.953+8619./T);

K3=exp(-71.745+52596./T);

Kp=exp(-10.68+11300./T);

Ra=k1.*pO2.*pSO2.*(1-pSO3./(pSO2.*sqrt(pO2).*Kp))./...

(22.414*(1+K2.*pSO2+K3.*pSO3).^2);

Ra1=1./Ra;

%perhitungan katalis

area=trapz(x,Ra1);

W=137.3*area;

T0 =

739.2187
Wmin =

3.0022e+003