0% found this document useful (0 votes)
58 views4 pages

CLC Clear: //soal No 1 A //tekanan Dalam MMHG

The document contains 4 numerical problems involving various numerical methods: 1) The bisection method is used to find the temperature corresponding to a pressure of 760 mmHg. 2) The Gauss-Seidel method is used to solve a system of 3 linear equations. 3) The Newton-Raphson method is applied to find the roots of a pair of nonlinear equations. 4) Curve fitting is performed to determine constants in a correlation for Nusselt number in terms of Prandtl number, Reynolds number, and viscosity ratio by the method of least squares.

Uploaded by

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

CLC Clear: //soal No 1 A //tekanan Dalam MMHG

The document contains 4 numerical problems involving various numerical methods: 1) The bisection method is used to find the temperature corresponding to a pressure of 760 mmHg. 2) The Gauss-Seidel method is used to solve a system of 3 linear equations. 3) The Newton-Raphson method is applied to find the roots of a pair of nonlinear equations. 4) Curve fitting is performed to determine constants in a correlation for Nusselt number in terms of Prandtl number, Reynolds number, and viscosity ratio by the method of least squares.

Uploaded by

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

//soal no 1 a

clc;clear;clf

P=760 //tekanan dalam mmhg


xb=0.8;
xt=1-xb;
T=[30:10:110]
n=length(T)

disp(' T Pbo Pto P')


for i=n
Pbo=10^(6.905-(1211/(T+221)));
Pto=10^(6.953-(1344/(T+219)));
P= xb*Pbo+xt*Pto
printf('%10.0f %10.1f %10.1f %10.1f\n', T', Pbo, Pto, P)
end

plot(T,P,'y-');xlabel('T');ylabel('P');
--------------------------------------------------------------------------------------------------------------------------------------

//soal no 1 b
//menentukan nilai T
//dengan metode bisection

clear;clc;

xb=0.8;
xt=1-xb;
P=760

//misal T=x
xl=30; //tebakan awal
xu=110;

function [f]=sarah(x)
f=xb*(10^(6.905-(1211/(x+221))))+xt*(10^(6.953-(1344/(x+219))))-P
endfunction

//memulai iterasi
beda=1; //error
iter=0
tol=1e-5
disp(' iter xl xm xu fl fm fu error ')
while beda>tol
iter=iter+1
xm=(xl+xu)/2
fl=sarah(xl)
fu=sarah(xu)
fm=sarah(xm)
beda=abs(xu-xl)
printf('%5.0f %10.4f %10.4f %10.4f %10.4f %10.4f %10.4f %10.4f\n', iter, xl, xm, xu, fl, fm, fu,
beda)
uji=fl*fm
if uji<0 then
xl=xl; xu=xm
else
xl=xm; xu=xu
end
end

T=(xl+xu)/2
disp(' ')
printf('T=%5.4f\n', T)
--------------------------------------------------------------------------------------------------------------------------------------
//nomor 2
//metode Gauss-Seidel

clc;clear;

A=[17 -8 -3; 2 -9 3; 1 4 -15]


B=[530; 0; 0]

//menganalogikan A*x=B
x=[2; 2; 2]
x1=x(1); x2=x(2); x3=x(3);

//memulai iterasi
tol=1e-5
beda=1
iter=0
while beda>tol
iter=iter+1
x1baru = (B(1)-A(1,2)*x2-A(1,3)*x3)/A(1,1);
x2baru = (B(2)-A(2,1)*x1baru-A(2,3)*x3)/A(2,2);
x3baru = (B(3)-A(3,1)*x1baru-A(3,2)*x2baru)/A(3,3);
beda1=abs(x1baru-x1)
beda2=abs(x2baru-x2)
beda3=abs(x3baru-x3)
beda=(beda1+beda2+beda3)/3
x1=x1baru
x2=x2baru
x3=x3baru
end

printf('V1=%5.4f\n',x1)
printf('V2=%5.4f\n',x2)
printf('V3=%5.4f\n',x3)
--------------------------------------------------------------------------------------------------------------------------------------

//nomor 3
//metode

clc;clear;

K1=4e-4;
K2=3.7e-2;
CA0=50;
CB0=20;
CC0=5;
CD0=10;
x1=8; //tebakan awal x1
x2=1; //tebakan awal x2

function [f1, f2]=sarah(x1, x2)


f1=(CC0+x1+x2)/((CA0-2*x1-x2)^2*(CB0-x1))-K1
f2=(CC0+x1+x2)/((CA0-2*x1-x2)*(CD0-x2))-K2
endfunction

tol=1e-5
er1=1
er2=1
h=0.0005
iter=0
disp(' iter x1 x2 er1 er2 ')
while er1 > tol & er2 > tol
iter = iter + 1;
[f1, f2] = sarah(x1, x2);
[f1x1, f2x1] = sarah(x1+h, x2);
[f1x2, f2x2] = sarah(x1, x2+h);
df1dx1 = (f1x1-f1)/h;
df1dx2 = (f1x2-f1)/h;
df2dx1 = (f2x1-f2)/h;
df2dx2 = (f2x2-f2)/h;
J = [df1dx1 df1dx2; df2dx1 df2dx2];
Jx1 = [f1 df1dx2; f2 df2dx2];
Jx2 = [df1dx1 f1; df2dx1 f2]
x1b = x1 - det(Jx1)/det(J); //xbaru
x2b = x2 - det (Jx2)/det (J); //ybaru
er1 = abs(x1b-x1);
er2 = abs(x2b-x2);
x1 = x1b; x2 = x2b;
printf('%5.0f %10.4f %10.4f %10.4f %10.4f\n', iter, x1, x2, er1, er2)
end
--------------------------------------------------------------------------------------------------------------------------------------

//nomor 4
//curve fitting
//Nu = Pr^(1/3)*a*Re^b*(miu/miuw)^m
//misal (miu/niuw)=w
//linierisasi
//ln Nu = ln a + 1/3*ln Pr + b*ln Re + m*ln w
//y = a0 + a1*x1 + a2*x2 + a3*x3
//y = ln Nu
//x1 = ln Pr
//x2 = ln Re
//x3 = ln w
//a0 = ln a
//a1 = 1/3
//a2 = b
//a3 = m

clc;clear;

Nu = [1797 2462 3131 3737 4683]


Re = [600 900 1200 1500 2000]
Pr = [14000 15000 16000 17000 18000]
w = [12 14 17 18 20]
y = log(Nu)
x1 = log(Pr)
x2 = log(Re)
x3 = log(w)
n = length(y)
sigy = sum(y)
sigx1 = sum(x1)
sigx2 = sum(x2)
sigx3 = sum(x3)
sigx1x2 = sum(x1.*x2)
sigx1x3 = sum(x1.*x3)
sigx2x3 = sum(x2.*x3)
sigx12 = sum(x1.^2)
sigx22 = sum(x2.^2)
sigx32 = sum(x3.^2)
sigx1y = sum(x1.*y)
sigx2y = sum(x2.*y)
sigx3y = sum(x3.*y)

A = [n sigx1 sigx2 sigx3; sigx1 sigx12 sigx1x2 sigx1x3; sigx2 sigx1x2 sigx22 sigx2x3; sigx3 sigx1x3
sigx2x3 sigx32]
B = [sigy; sigx1y; sigx2y; sigx3y]
//menganalogikan dengan A*x=B
const = A\B
a0 = const(1); a1 = const(2); a2 = const(3); a3 = const(4)

//a
disp('a)')
a = exp(a0)
b = a2
m = a3
printf('a=%5.2f\n',a)
printf('b=%5.2f\n',b)
printf('m=%5.2f\n',m)

//b
disp('b)')
Nuhitung = Pr.^(1/3).*a.*Re.^b.*(w).^m
disp(' Nu-data Nu-hitung ')
printf('%10.2f %10.2f\n', Nu', Nuhitung')

You might also like