You are on page 1of 2

import numpy as np

import matplotlib.pyplot as plt


from scipy.integrate import solve_ivp as sl

D = 10 #m
T_amb = 40 + 273.15 #K
T_tank = 0 + 273.15 #K
P_amb = 1 #bar
P_init = 5 #bar
latent = 397746 #J/kg
Mr = 44.1 #g/mol
h = 20 #W/m2/K
R = 0.0082 #L.atm/mol/K
Cv = 2
Sg = 0.55
T_R = (9/5 * (T_tank - 273) + 32) + 460
t_span = [0, 3600 * 24]
rho_water = 1000 #kg/m3
rho = Sg * rho_water #kg/m3
A_tank = 4 * np.pi * (D/2)**2
V_tank = 4/3 * np.pi * (D/2)**3
V_cair = 0.8 * V_tank
Qin = h * A_tank * (T_amb - T_tank)

marker = 1

def Func(t,List):
Vc = List[0]
Ptank = List[1]
dVcdt = - Qin/(2 * latent * rho)

global marker
if Ptank >= 8:
marker = 0
elif Ptank <= 5:
marker = 1

if Ptank < 8 and marker == 1:


dPdt = 1/(V_tank - Vc) * (Qin * R * T_tank/(2 * latent * Mr) + Ptank *
dVcdt)
elif Ptank >= 8 or marker == 0:
Vflow = 13.63 * Cv * Ptank * 14.7 * (1/(T_R * Sg))**0.5 #ft3/menit
Q = 0.471947 * Vflow #L/s
Fout = Q/(R * 273 * 1000) #kmol/s
dPdt = 1/(V_tank - Vc) * (R * T_tank * (Qin/(2 * latent * Mr) - Fout)
+ Ptank * dVcdt)
return np.array([dVcdt, dPdt])
IC = np.array([V_cair, P_init])
ans = sl(Func, t_span, IC, method='RK23', max_step=10)
P_ans, Vc_ans = ans.y[1], ans.y[0]
t = ans.t

Vout = V_cair - Vc_ans[-1]


print('Jumlah total propane yang dikeluarkan setelah 24 jam adalah {:.2f}
m3.'.format(Vout))

plt.figure(0)
plt.plot(t/3600, P_ans,'-r')
plt.title('Profil Tekanan Tank vs. Waktu')
plt.xlabel('Waktu, jam')
plt.ylabel('Tekanan, bar')
plt.grid()

plt.figure(1)
plt.plot(t/3600, Vc_ans,'--b')
plt.title('Profil Volume Cairan Tank vs. Waktu')
plt.xlabel('Waktu, jam')
plt.ylabel('Volume cairan, m3')
plt.grid()
plt.show()

You might also like