You are on page 1of 4

Lampiran nomor 2 Tugas III AOSTK-A def func(x):

T = (13.278*(x**3))-
Grafik dari Excel:
(13.737*(x**2))+(6.3363*x)-0.0182
Cs = (-282*np.log(x))+4.5746
Hubungan antara T dan X R = 1/T*((2*1000*x)-100*T-Cs)
7 return R
6 y = 13,278x3 - 13,737x2 + 6,3363x - 0,0182
R² = 0,9931 #Iterasi 1
5 x1 = xl+l*(xu-xl)
4 x2 = xu-l*(xu-xl)
T, hari

f1 = func(x1)
3
f2 = func(x2)
2 if f1>f2:
1
xopt = x1
xl = x2
0 x2 = x1
0 0,2 0,4 0,6 0,8 1
f2 = func(x2)
X, lb produk/lb umpan x1 = xl+l*(xu-xl)
f1 = func(x1)
else:
Hubungan antara Cs dan X xopt = x2
xu = x1
600 x1 = x2
500
f1 = func(x1)
x2 = xu-l*(xu-xl)
y = -282ln(x) + 4,5746
400
R² = 0,9996
f2 = func(x2)
Cs, $

300
er = np.abs((x2-x1)/xopt)*100
200
#Iterasi Optimum
100 xopt_matrix = []
er_matrix = []
0
0 0,2 0,4 0,6 0,8 1 while er>0.01:
X, lb produk/lb umpan
if f1>f2:
xopt = x1
xl = x2
Script perhitungan dari Python: x2 = x1
f2 = func(x2)
# -*- coding: utf-8 -*- x1 = xl+l*(xu-xl)
""" f1 = func(x1)
Created on Sat May 29 11:11:28 2021 else:
xopt = x2
@author: annisarifna xu = x1
""" x1 = x2
import numpy as np f1 = func(x1)
x2 = xu-l*(xu-xl)
#Kondisi batas awal (tebakan) f2 = func(x2)
xl = 0 xopt_matrix.append(xopt)
xu = 1 er = np.abs((x2-x1)/xopt)*100
er_matrix.append(er)
#Golden ratio (l**2+l-1=0) terus cari l yang (+) tp
kecil #Hasil Perhitungan
l=(np.sqrt(5)-1)/2 fopt = func(xopt)
xopt_data = np.array(xopt_matrix,float)
#Fungsi er_data = np.array(er_matrix,float)
fopt_data = func(xopt_data)
T_hitung = T = (13.278*(xopt**3))-
(13.737*(xopt**2))+(6.3363*xopt)-0.0182

#Output Hasil
#Tabel iterasi
Header = ['Konversi Optimum','Keuntungan
Maksimum,$','Error,%']
garis = 60*'_'
tabel = np.zeros([len(fopt_data),3])
tabel[:,0] = xopt_data
tabel[:,1] = fopt_data
tabel[:,2] = er_data
print(garis)
print ('{:^20s}|{:^22s}|{:^18s}'.format(*Header))
print(garis)
for baris in tabel:

print('{:^20.4f}|{:^22.4f}|{:^18.4f}'.format(*baris
))
print(garis)
#Hasil Akhir
print('Konversi Optimum = {:.4f}'.format(xopt))
print('Waktu Batch di Reaktor = {:.4f}
hari'.format(T_hitung))
print('Keuntungan Maksimum =
${:.4f}'.format(fopt))

You might also like