You are on page 1of 9

function Qlossfungsisuhufix

clear;clc;

%Data T dan dt dari Excel


data1 = xlsread('C:\Users\Windows 7\Documents\PRAKTIKUM OTK\N-TEMPERATURE
CONTROLLER\Book1.xlsx','A1:B609'); %deltaT 2 degC
dataA = data1(1:10:end,:); %diambil tiap range 10
data2 = xlsread('C:\Users\Windows 7\Documents\PRAKTIKUM OTK\N-TEMPERATURE
CONTROLLER\Book1.xlsx','D1:E782'); %deltaT 5 degC
dataB = data2(1:10:end,:); %diambil tiap range 10

%Data lain
rho = 996.513*(44.8547-19.8666)/(44.8205-19.8666); %kg/m3
V = 22/7/4*(0.36)^2*0.23; %m3
Qel = 2200; %J/s
Fv = (41/5.0+41/5.0+40/5.0)/3*1e-6; %m3/s
Cp = 4185.8; %J/kg/degC = 1 cal/gr/degC
T0 = 25.8; %degC
Tud = 27; %degC
UA0 = 25; %W/C

%Perhitungan delta T 2 degC


TA = dataA(:,1);
tA = dataA(:,2);
TAmin = 38; %degC
TAmax = 40; %degcC
N = length(tA);
dtA = tA(end)/(N-1);

function SSEA = funA(x)


function ThitA = fA(TAA,Qin)
a = -(Fv/V+UA/(rho*Cp*V));
b = (Fv/V*T0+n*Qin/(rho*Cp*V)+UA/(rho*Cp*V)*Tud);
ThitA = ((a*TAA+b)*exp(a*dtA)-b)/a;
end
UA = x(1);
n = x(2);
i = 0;
T = TA(1);
t = 0;
if T<TAmax
while t(end)<tA(end) && T(end)<TAmax
Qin = Qel;
i = i+1;
T(i+1) = fA(T(i),Qin);
t(i+1) = t(i)+dtA;
end
while t(end)<tA(end)
if t(end)<tA(end)
while t(end)<tA(end) && T(end)>TAmin
Qin = 0;
i = i+1;
T(i+1) = fA(T(i),Qin);
t(i+1) = t(i)+dtA;
end
end
if t(end)<tA(end)
while t(end)<tA(end) && T(end)<TAmax
Qin = Qel;
i = i+1;
T(i+1) = fA(T(i),Qin);
t(i+1) = t(i)+dtA;
end
end
end
else
while t(end)<tA(end) && T(end)>TAmin
Qin = 0;
i = i+1;
T(i+1) = fA(T(i),Qin);
t(i+1) = t(i)+dtA;
end
while t(end)<tA(end)
if t(end)<tA(end)
while t(end)<tA(end) && T(end)>TAmin
Qin = 0;
i = i+1;
T(i+1) = fA(T(i),Qin);
t(i+1) = t(i)+dtA;
end
end
if t(end)<tA(end)
while t(end)<tA(end) && T(end)<TAmax
Qin = Qel;
i = i+1;
T(i+1) = fA(T(i),Qin);
t(i+1) = t(i)+dtA;
end
end
end
end
SSEA = sum((TA-T').^2);
end

x0 = [UA0 0.7];
[x, SSEA] = fminsearch(@funA,x0);
UA = x(1);
n = x(2);
Qloss = UA*(sum(T)/length(T)-Tud);

%Penyajian Data
fprintf('Perhitungan Temperature Controller Selisis Suhu 2 degC dengan Qloss Fungsi Suhu\n\n')
fprintf('Nilai UA terhitung = %4.4f W/degC\n',UA)
fprintf('Nilai Qloss rerata = %4.4f W\n',Qloss)
fprintf('Efisiensi Pemanas = %4.4f persen\n',n*100)
fprintf('Nilai SSE = %4.4f\n\n',SSEA)
fprintf('Perbandingan Data Suhu Percobaan dan Suhu Terhitung\n')
fprintf('----------------------------------------------------\n')
fprintf('Waktu(s) T Percobaan (degC) T Perhitungan (degC)\n')
fprintf('----------------------------------------------------\n')
for i=1:length(tA)
fprintf('%4.0f %4.1f %4.4f \n',t(i),TA(i),T(i))
end
fprintf('----------------------------------------------------\n\n\n')
TAmax(1:length(tA)) = TAmax;
TAmin(1:length(tA)) = TAmin;
figure(1)
plot(tA,TA,'o',t,T,tA,TAmax,'--r',tA,TAmin,'--r')
title('Hubungan Suhu Keluar Tangki tiap Waktu')
xlabel('Waktu (t,s)')
ylabel('Suhu (T,degC)')
legend('Data Perocabaan','Data Perhitungan','Batas Suhu','Location','SouthEast')

%Perhitungan delta T 5 degC


TB = dataB(:,1);
tB = dataB(:,2);
TBmin = 38; %degC
TBmax = 43; %degcC
N = length(tB);
dtB = tB(end)/(N-1);

function SSEB = funB(x)


function ThitB = fB(TBB,Qin)
a = -(Fv/V+UA/(rho*Cp*V));
b = (Fv/V*T0+n*Qin/(rho*Cp*V)+UA/(rho*Cp*V)*Tud);
ThitB = ((a*TBB+b)*exp(a*dtA)-b)/a;
end
UA = x(1);
n = x(2);
i = 0;
T = TB(1);
t = 0;
if T<TBmax
while t(end)<tB(end) && T(end)<TBmax
Qin = Qel;
i = i+1;
T(i+1) = fB(T(i),Qin);
t(i+1) = t(i)+dtB;
end
while t(end)<tB(end)
if t(end)<tB(end)
while t(end)<tB(end) && T(end)>TBmin
Qin = 0;
i = i+1;
T(i+1) = fB(T(i),Qin);
t(i+1) = t(i)+dtB;
end
end
if t(end)<tB(end)
while t(end)<tB(end) && T(end)<TBmax
Qin = Qel;
i = i+1;
T(i+1) = fB(T(i),Qin);
t(i+1) = t(i)+dtB;
end
end
end
else
while t(end)<tB(end) && T(end)>TBmin
Qin = 0;
i = i+1;
T(i+1) = fB(T(i),Qin);
t(i+1) = t(i)+dtB;
end
while t(end)<tB(end)
if t(end)<tB(end)
while t(end)<tB(end) && T(end)>TBmin
Qin = 0;
i = i+1;
T(i+1) = fB(T(i),Qin);
t(i+1) = t(i)+dtB;
end
end
if t(end)<tB(end)
while t(end)<tB(end) && T(end)<TBmax
Qin = Qel;
i = i+1;
T(i+1) = fB(T(i),Qin);
t(i+1) = t(i)+dtB;
end
end
end
end
SSEB = sum((TB-T').^2);
end

x0 = [UA0 0.7];
[x, SSEB] = fminsearch(@funB,x0);
UA = x(1);
n = x(2);
Qloss = UA*(sum(T)/length(T)-Tud);

%Penyajian Data
fprintf('Perhitungan Temperature Controller Selisis Suhu 5 degC dengan Qloss fungsi Suhu\n\n')
fprintf('Nilai UA terhitung = %4.4f W/degC\n',UA)
fprintf('Nilai Qloss rerata = %4.4f W\n',Qloss)
fprintf('Efisiensi Pemanas = %4.4f persen\n',n*100)
fprintf('Nilai SSE = %4.4f\n\n',SSEB)
fprintf('Perbandingan Data Suhu Percobaan dan Suhu Terhitung\n')
fprintf('----------------------------------------------------\n')
fprintf('Waktu(s) T Percobaan (degC) T Perhitungan (degC)\n')
fprintf('----------------------------------------------------\n')
for i=1:length(tB)
fprintf('%4.0f %4.1f %4.4f \n',t(i),TB(i),T(i))
end
fprintf('----------------------------------------------------\n')
TBmax(1:length(tB)) = TBmax;
TBmin(1:length(tB)) = TBmin;
figure(2)
plot(tB,TB,'o',t,T,tB,TBmax,'--r',tB,TBmin,'--r')
title('Hubungan Suhu Keluar Tangki tiap Waktu')
xlabel('Waktu (t,s)')
ylabel('Suhu (T,degC)')
legend('Data Perocabaan','Data Perhitungan','Batas Suhu','Location','SouthEast')

end

Perhitungan Temperature Controller Selisis Suhu 2 degC dengan Qloss Fungsi Suhu

Nilai UA terhitung = 24.1281 W/degC


Nilai Qloss rerata = 213.2378 W
Efisiensi Pemanas = 55.4600 persen
Nilai SSE = 11.9096

Perbandingan Data Suhu Percobaan dan Suhu Terhitung


----------------------------------------------------
Waktu(s) T Percobaan (degC) T Perhitungan (degC)
----------------------------------------------------
0 25.4 25.4000
50 26.0 26.0407
100 26.6 26.6627
150 27.1 27.2665
200 27.6 27.8526
250 28.1 28.4216
300 28.7 28.9739
350 29.2 29.5101
400 29.7 30.0306
450 30.2 30.5358
500 30.7 31.0263
550 31.1 31.5024
600 31.5 31.9646
650 32.0 32.4132
700 32.4 32.8488
750 32.9 33.2716
800 33.2 33.6820
850 33.7 34.0804
900 34.0 34.4672
950 34.5 34.8426
1000 34.9 35.2070
1050 35.2 35.5608
1100 35.6 35.9043
1150 35.9 36.2377
1200 36.3 36.5613
1250 36.6 36.8755
1300 38.0 37.1804
1350 38.3 37.4765
1400 38.6 37.7639
1450 38.9 38.0428
1500 39.2 38.3137
1550 39.5 38.5765
1600 39.8 38.8317
1650 40.1 39.0795
1700 40.2 39.3200
1750 40.0 39.5534
1800 39.7 39.7800
1850 39.4 40.0000
1900 39.2 39.5991
1950 38.9 39.2099
2000 38.6 38.8322
2050 38.4 38.4654
2100 38.0 38.1094
2150 37.8 37.7638
2200 37.9 38.0428
2250 38.1 38.3136
2300 38.4 38.5765
2350 38.7 38.8317
2400 39.1 39.0795
2450 39.4 39.3199
2500 39.6 39.5534
2550 39.9 39.7800
2600 40.2 40.0000
2650 40.1 40.2135
2700 40.0 39.8064
2750 39.7 39.4112
2800 39.4 39.0275
2850 39.1 38.6550
2900 38.6 38.2935
2950 38.4 37.9425
3000 38.1 38.2163
----------------------------------------------------

Perhitungan Temperature Controller Selisis Suhu 5 degC dengan Qloss fungsi Suhu

Nilai UA terhitung = 26.7435 W/degC


Nilai Qloss rerata = 361.0607 W
Efisiensi Pemanas = 58.8435 persen
Nilai SSE = 20.0915

Perbandingan Data Suhu Percobaan dan Suhu Terhitung


----------------------------------------------------
Waktu(s) T Percobaan (degC) T Perhitungan (degC)
----------------------------------------------------
0 38.0 38.0000
50 38.3 38.2949
100 38.7 38.5807
150 38.9 38.8579
200 39.1 39.1265
250 39.5 39.3870
300 39.7 39.6395
350 40.0 39.8842
400 40.3 40.1215
450 40.6 40.3516
500 40.9 40.5746
550 41.2 40.7908
600 41.5 41.0004
650 41.6 41.2036
700 41.9 41.4006
750 42.2 41.5915
800 42.4 41.7767
850 42.6 41.9561
900 42.9 42.1301
950 43.1 42.2988
1000 43.2 42.4623
1050 42.9 42.6208
1100 42.6 42.7745
1150 42.2 42.9235
1200 41.9 43.0679
1250 41.6 42.5564
1300 41.3 42.0606
1350 41.0 41.5799
1400 40.7 41.1138
1450 40.4 40.6621
1500 40.1 40.2241
1550 39.8 39.7995
1600 39.5 39.3879
1650 39.2 38.9888
1700 39.0 38.6020
1750 38.7 38.2270
1800 38.4 37.8634
1850 38.2 38.1624
1900 38.0 38.4523
1950 37.8 38.7334
2000 38.0 39.0059
2050 38.3 39.2700
2100 38.7 39.5261
2150 39.0 39.7743
2200 39.5 40.0150
2250 39.7 40.2483
2300 40.1 40.4744
2350 40.3 40.6937
2400 40.6 40.9063
2450 40.9 41.1123
2500 41.2 41.3121
2550 41.5 41.5058
2600 41.9 41.6935
2650 42.1 41.8755
2700 42.4 42.0520
2750 42.6 42.2230
2800 43.0 42.3889
2850 43.2 42.5496
2900 43.1 42.7055
2950 42.9 42.8566
3000 42.6 43.0030
3050 41.9 42.4935
3100 41.6 41.9996
3150 41.3 41.5208
3200 40.9 41.0565
3250 40.6 40.6065
3300 40.3 40.1702
3350 40.0 39.7473
3400 39.8 39.3373
3450 39.5 38.9398
3500 39.3 38.5544
3550 39.1 38.1809
3600 38.9 37.8187
3650 38.7 38.1191
3700 38.3 38.4103
3750 38.1 38.6927
----------------------------------------------------
Published with MATLAB R2012b

You might also like