You are on page 1of 2

8/21/23, 6:47 PM Tugas 1.

ipynb

~\Desktop\Tugas 1 Prokom L\Tugas 1.ipynb

1 ## OKTAVIANUS STEVIAN ANGELINO


2 ## 21/481480/TK/53141
3  
4 import numpy as np
5 import pandas as pd
6 import matplotlib.pyplot as plt
7  
8 data = pd.read_excel('Physical properties.xlsx', index_col=1, header=3)
9  
10 ## YOU CAN CHANGE THE NAME OF THESE AS LONG AS THERE ARE
11 ## THE EXACT SAME COMPOUND NAMES IN THE EXCEL DATABASE.
12 substance1 = 'O-XYLENE'
13 substance2 = 'N-BUTANOL'
14 SystemPressure = 760 #mmHg
15  
16 class Antoine:
17 def __init__(self, substance1, substance2, Pressure):
18 self.substance1 = substance1
19 self.substance2 = substance2
20 self.Pressure = Pressure
21 Value1 = data.loc[substance1, 'Aanto':'Canto']
22 self.Value1 = Value1
23 Value2 = data.loc[substance2, 'Aanto':'Canto']
24 self.Value2 = Value2
25
26 def Boiling(self, Value):
27 A, B, C = Value
28 Tb = B/(A - np.log(self.Pressure)) - C
29 return Tb
30
31 def Key(self):
32 TbA = self.Boiling(self.Value1)
33 TbB = self.Boiling(self.Value2)
34 self.TbA = TbA
35 self.TbB = TbB
36 if TbA < TbB:
37 print(f'The light key component is {self.substance1}')
38 print(f'The heavy key component is {self.substance2}')
39 else:
40 print(f'The light key component is {self.substance2}')
41 print(f'The light key component is {self.substance1}')
42
43 def Pres(self, Value, T):
44 A, B, C = Value
45 P = np.exp(A - B/(T + C))
46 return P
47  
48 def Frac(self):
49 self.Key()
50 if self.TbA < self.TbB:
51 span = np.linspace(self.TbA, self.TbB, 101)
52 else:
53 span = np.linspace(self.TbB, self.TbA, 101)
54 Psis1 = self.Pres(self.Value1, span)
55 Psis2 = self.Pres(self.Value2, span)
56 if self.TbA < self.TbB:

localhost:50980/b87b92a2-6257-4e20-a003-667a061f84be/ 1/2
8/21/23, 6:47 PM Tugas 1.ipynb

57 xlight = (self.Pressure - Psis2)/(Psis1 - Psis2)


58 ylight = xlight * Psis1 / self.Pressure
59 else:
60 xlight = (self.Pressure - Psis1)/(Psis2 - Psis1)
61 ylight = xlight * Psis2 / self.Pressure
62 return xlight, ylight, span
63
64 def Plot(self):
65 xlight, ylight, span = self.Frac()
66  
67 plt.figure(0)
68 plt.plot(xlight, span, label='liquid')
69 plt.plot(ylight, span, label='vapor')
70 plt.xlabel('Mole Fraction of Light Component')
71 plt.ylabel('Temperature, K')
72 plt.legend()
73 plt.show()
74  
75 plt.figure(1)
76 plt.plot(xlight, ylight)
77 plt.plot(np.linspace(0, 1, 11), np.linspace(0, 1, 11), '--')
78 plt.xlabel('Liquid Mole Fraction of Light Component')
79 plt.ylabel('Vapor Mole Fraction of Light Component')
80 plt.show()
81
82 Antoine(substance1, substance2, SystemPressure).Plot()

localhost:50980/b87b92a2-6257-4e20-a003-667a061f84be/ 2/2

You might also like