import math
x_acetone = 0.05 # Mole fraction of Acetone in liquid
x_water = (1-x_acetone)
y_acetone = 0.6381 # Mole fraction of Acetone in vapour
y_water = (1-y_acetone)
K_acetone = y_acetone/x_acetone
K_water = y_water/x_water
a = K_acetone/K_water
print "The K factor of acetone is %f"%(K_acetone)
print " The K factor of water is %f"%(K_water)
print " The relative volatility is %f"%(a)
import math
P = 1. #[atm]
Temp = 74.8 #[C]
A_a = 7.02447
B_a = 1161
C_a = 224
p_acetone = 10**(A_a-B_a/(Temp+C_a)) #[mmHg]
A_w = 7.94917
B_w = 1657.462
C_w = 227.02
p_water = 10**(A_w-B_w/(Temp+C_w)) #[mmHg]
p_acetone = p_acetone/760 #[atm]
p_water = p_water/760 #[atm]
y_acetone = 0.6381
x_acetone = 0.05
y_water = (1-y_acetone)
x_water =(1-x_acetone)
Y_acetone = y_acetone*P/(x_acetone*p_acetone)
Y_water = y_water*P/(x_water*p_water)
print "Liquid-phase activity coefficient for acetone is %f"%(Y_acetone)
print " Liquid-phase activity coefficient for water is %f"%(Y_water)
import math
x_a = 0.05 # mole fraction of acetone in liquid phase
x_w = (1-x_a) # mole fraction of the water in the liquid phase
P = 1.00 #[atm] Total pressure in vapor phase
T_1 = 80. #[C]
A_a = 7.02447
B_a = 1161.
C_a = 224.
A_w = 7.94917
B_w = 1657.462
C_w = 227.02
p_a_1 = (1./760)*10**(A_a - B_a/(T_1+C_a)) #[atm]
p_w_1 = (1./760)*10**(A_w - B_w/(T_1+C_w)) #[atm]
y_a_1 = (x_a*p_a_1)/P
y_w_1 = (x_w*p_w_1)/P
y_1 = (y_a_1 + y_w_1)
T_2 = 96.4060 #[C]
p_a_2 = (1./760)*10**(A_a - B_a/(T_2+C_a)) #[atm]
p_w_2 = (1./760)*10**(A_w - B_w/(T_2+C_w)) #[atm]
y_a_2 = (x_a*p_a_2)/P
y_w_2 = (x_w*p_w_2)/P
y_2 = (y_a_2 + y_w_2)
T_e = 74.8 #[C] Boiling temperature
y_a_e = 0.6381 # vapor phase composition of acetone
print " Comparison of experimental values to those computed by the ideal solution assumption x_acetone = 0.05 and P = 1.00 atm"
print " \t\t\t Experimental Values from Table 8.1 \t\t\t\tValues calculated assuming idea solution"
print " Equilibriumboiling) \t\t%0.1f \t\t\t\t\t\t\t\t\t %0.1f temperature T deg C"%(T_e,T_2)
print " Mole fraction acetone \t\t%f \t\t\t\t\t\t\t\t %f in the vapor phase y_a)"%(y_a_e,y_a_2)
import math
n_water = 80. #[mol]
n_bumath_tanol = 20. #[mol]
n_total = n_water+n_bumath_tanol #[mol]
x_feed = 0.8
x_a_1 = 0.65
x_a_2 = 0.98
n_1 = (x_feed-x_a_2)/(x_a_1-x_a_2)*n_total #[mol]
n_2 = (n_total-n_1) #[mol]
n_a_1 = 0.65*n_1 #[mol]
n_a_2 = 0.98*n_2 #[mol]
print " Total moles of water present in the first phase is %f mol"%(n_a_1)
print " Total moles of water present in the second phase is %f mol"%(n_a_2)
import math
P = 1. #[atm]
y_water = 0.60
x_water_1 = 0.22
x_water_2 = 0.99
print " The equilibrium amount of water in liquid at bubble-point for the dew-point composition y_water=60 mol%% is %f mol%% water"%(x_water_1)
print " The equilibrium amount of water in liquid at bubble-point for the dew-point composition y_water=90 mol%% is %f mol%% water"%(x_water_2)
import math
P = 1.00 #[atm] assumed total vapor pressure
P1 = 14.7 #[psia]
x_1_water = 0.65
x_1_bumath_tanol = (1-x_1_water)
x_2_water = 0.98
x_2_bumath_tanol = (1-x_2_water)
y_water = 0.73
y_bumath_tanol = (1-y_water)
T = 92. #[C]
A_w = 7.94917
B_w = 1657.462
C_w = 227.02
A_b = 7.838
B_b = 1558.190
C_b = 196.881
p_water = (14.7/760)*10**(A_w - B_w/(T+C_w))
p_bumath_tanol = (14.7/760)*10**(A_b - B_b/(T+C_b))
f_water = (y_water*P)
f_bumath_tanol = (y_bumath_tanol*P)
Y_water_1 = (y_water*P1)/(x_1_water*p_water)
Y_bumath_tanol_1 = (y_bumath_tanol*P1)/(x_1_bumath_tanol*p_bumath_tanol)
Y_water_2 = (y_water*P1)/(x_2_water*p_water)
Y_bumath_tanol_2 = (y_bumath_tanol*P1)/(x_2_bumath_tanol*p_bumath_tanol)
print " Four activity coefficients and fufacities are shown in the following table:"
print "Phase \t x_water \t f_wateratm \t Y_water \t x_butanol \t f_butanolatm \t\t Y_butanol"
print " 1 \t %f \t %f \t %f \t %f \t %f \t\t %f "%(x_1_water,f_water,Y_water_1,x_1_bumath_tanol,f_bumath_tanol,Y_bumath_tanol_1)
print " 2 \t %f \t %f \t %0.2f \t\t %f \t %f \t\t %f "%(x_2_water,f_water,Y_water_2,x_2_bumath_tanol,f_bumath_tanol,Y_bumath_tanol_2)
import math
P = 1. #[atm] Total pressure in the vapor phase
T = 89. #[C]
A_w = 7.94917
B_w = 1657.462
C_w = 227.02
A_b = 7.838
B_b = 1558.190
C_b = 196.881
p_water = (1./760)*10**(A_w - B_w/(T+C_w))
p_bumath_tanol = (1./760)*10**(A_b - B_b/(T+C_b))
y_water = p_water/P
y_bumath_tanol = p_bumath_tanol/P
y = y_water + y_bumath_tanol
print " Boiling point of the two phase system is %0.0f deg C"%(T)
print " In vapor phase mole fraction of the water is %0.2f"%(y_water)
import math
Temp = 68. #[F]
P = 1. #[atm]
Temp = 273.15+(Temp-32)*5./9 #[K]
P = P*1.01325 #[bar]
T_c = 647.1 #[K]
P_c = 220.55 #[bar]
T_r = Temp/T_c
P_r = P/P_c
w = 0.345
f_T_r = (0.083-0.422/T_r**(1.6))+w*(0.139-0.172/T_r**(4.2))
f_by_P = math.exp(P_r/T_r*f_T_r)
print "The value of the f/P for water vapour in the hypothetical state is %0.2f"%(f_by_P)
import math
x_a = 0.1238
x_b = (1-x_a)
T = 85.3 #[C] Given boiling temperature
A_a = 8.04494
B_a = 1554.3
C_a = 222.65
A_b = 7.96681
B_b = 1668.21
C_b = 228.0
p_a = (1./760)*10**(A_a - B_a/(T+C_a))
p_b = (1./760)*10**(A_b - B_b/(T+C_b))
A = 0.7292
B = 0.4104
Y_a = 10**((B**(2)*A*x_b**(2))/(A*x_a+B*x_b)**(2))
Y_b = 10**((A**(2)*B*x_a**(2))/(A*x_a+B*x_b)**(2))
P = (Y_a*p_a*x_a)+(Y_b*p_b*x_b) #[atm]
y_a = (Y_a*p_a*x_a)/P
y_b = (Y_b*p_b*x_b)/P
print " Boiling pressure of the liquid at 85.3 deg C is %0.4f atm"%(P)
print " Mole fraction of ethanaol in vapor phase is %0.4f"%(y_a)
print " Mole fraction of water in the vapor phase is %0.4f"%(y_b)
import math
x_a = 0.2608
x_b = (1-x_a)
P = 1.00 #[atm] Given boiling pressure
A_a = 8.04494
B_a = 1554.3
C_a = 222.65
A_b = 7.96681
B_b = 1668.21
C_b = 228.0
A = 0.7292
B = 0.4104
Y_a = 10**((B**(2)*A*x_b**(2))/(A*x_a+B*x_b)**(2))
Y_b = 10**((A**(2)*B*x_a**(2))/(A*x_a+B*x_b)**(2))
T = 80.
err = 1.
while err > 10**(-3):
P_a = (10**(8.04494 - 1554.3/(222.65 + T)))/760
P_b = (10**(7.96681 - 1668.21/(228 + T)))/760
y_a = Y_a*P_a*x_a/P
y_b = Y_b*P_b*x_b/P
err = abs((y_a + y_b) - 1)
T = T + 0.01
print " Boiling temperature of the liquid at 1 atm pressure is %0.4f atm"%(T)
print " Mole fraction of ethanaol in vapor phase is \t%0.4f"%(y_a)
print " Mole fraction of water in the vapor phase is \t%0.4f"%(y_b)
import math
y_a = 0.6122
y_b = (1-y_a)
T = 80.7 #[C] Given boiling temperature
A_a = 8.04494
B_a = 1554.3
C_a = 222.65
A_b = 7.96681
B_b = 1668.21
C_b = 228.0
p_a = (1./760)*10**(A_a - B_a/(T+C_a))
p_b = (1./760)*10**(A_b - B_b/(T+C_b))
A = 0.7292
B = 0.4104
x_a = 0.6122 # Initial assumption of liquid phase composition of ethanol
x_b = 0.3 # Initial assumption of liquid phase composition water
P = 0.80 #[atm]
err = 1
while err > 2* 10**(-2):
P = P + 0.01
Y_a = 10**((B**(2)*A*x_b**(2))/(A*x_a+B*x_b)**(2))
Y_b = 10**((A**(2)*B*x_a**(2))/(A*x_a+B*x_b)**(2))
err = abs((x_a + x_b) - 1)
x_a = y_a*P/(Y_a*p_a)
x_b = y_b*P/(Y_b*p_b)
print " Boiling pressure of the liquid at 80.7 deg C is %0.4f atm"%(P)
print " Mole fraction of ethanaol in liquid phase is %0.4f"%(x_a)
print " Mole fraction of water in the liquid phase is %0.4f"%(x_b)
import math
y_a = 0.1700
y_b = (1-y_a)
P = 1.00 #[atm] Given boiling pressure
A_a = 8.04494
B_a = 1554.3
C_a = 222.65
A_b = 7.96681
B_b = 1668.21
C_b = 228.0
A = 0.7292
B = 0.4104
x_a = 0.0100 # Initial assumption of liquid phase composition of ethanol
x_b = 0.9 # Initial assumption of liquid phase composition water
T = 80. #[C] Initial guess of the temperature
err = 1
while err > 1./16*10**(-2):
P_a = (10**(8.04494 - 1554.3/(222.65 + T)))/760
P_b = (10**(7.96681 - 1668.21/(228 + T)))/760
Y_a = 10**((B**(2)*A*x_b**(2))/(A*x_a+B*x_b)**(2))
Y_b = 10**((A**(2)*B*x_a**(2))/(A*x_a+B*x_b)**(2))
x_a = y_a*P/(Y_a*P_a)
x_b = y_b*P/(Y_b*P_b)
err = abs((x_a + x_b) - 1)
T = T + 0.01
print " Equilibrium Temperature of the system at pressure 1 atm is %0.4f atm"%(T)
print " Mole fraction of ethanaol in liquid phase is %0.4f"%(x_a)
print " Mole fraction of water in the liquid phase is %0.4f"%(x_b)
import math
x_aF = 0.126
x_bF = (1-x_aF)
P = 1.00 #[atm] Given total pressure
T = 91.8 #[C]
x_a = 0.0401
x_b = (1 - x_a)
y_a = 0.2859
y_b = ( 1 - y_a)
V_by_F = ( x_aF - x_a )/(y_a - x_a)
print " Mole fraction of the ethanol in the liquid phase in equilibrium at the given condition is %f"%(x_a)
print " Mole fraction of the water in the liquid phase in equilibrium at the given condition is %f"%(x_b)
print " Mole fraction of the ethanol in the vapour phase in equilibrium at the given condition is %f"%(y_a)
print " Mole fraction of the water in the vapour phase in equilibrium at the given condition is %f"%(y_b)
print " Vapor fraction of the given water-ethanol mixture after the flash in equilibrium is %f"%(V_by_F)
import math
P = 100. #[psia]
x_a = 0.05 # Mole fraction of methane
x_b = 0.40 # Mole fraction of bumath.tane
x_c = 0.55 # mole fraction of penmath.tane
T = [[15.8 ,0.087, 0.024],[16,0.105, 0.026],[16.2, 0.115, 0.03],[16.8 ,0.13, 0.035],[17.2 ,0.15, 0.04],[17.8, 0.17, 0.045],[18.2, 0.175, 0.0472727]]
print " Calculations for the various assumed temperatures are given in the table below"
print " Temperature \t\t y_a \t\t y_b \t\t\t y_c \t\t\t y "
T_b = 0 #[F] Bubble point
j=0
for i in range(7):
y_a = x_a*T[i][j]
y_b = x_b*T[i][j+1]
y_c = x_c*T[i][j+2]
y = y_a + y_b + y_c
T_b = T_b + 5
print " %f \t\t %f \t\t %f \t\t %f \t\t %f "%(T_b,y_a,y_b,y_c,y)
print " For the temperature 30 deg F the summation of the mole fractions in the vapor phase is close enough to unity so bubble point is 30 degF"
print " And compositions in the vapor phase are the values given in the above table corresonding to the temperature 30 deg F i.e."
print " y_methane = %f y_bumath.tane = %f y_penmath.tane = %f"%(y_a,y_b,y_c)
import math
n_sugar = 1. #[mol]
n_water = 1000/18. #[mol]
x_sugar = n_sugar/(n_sugar+n_water)
x_water = n_water/(n_sugar+n_water)
p_water = 1. #[atm]
p_sugar = 0. #[atm]
P = x_water*p_water+x_sugar*p_sugar #[atm]
P_1 = 1. #[atm]
p_water = P_1/x_water #[atm]
T = 100.51 #[C]
T_eb = T-100 #[C]
print "Vapour pressure of this solution at the 100C is %.3f atm"%(P)
print "The temperature at which this solution will boil at 1 atm is %.2f C"%(T)
from scipy.optimize import fsolve
import math
n_sugar = 1. #[mol]
n_water = 1000/18. #[mol]
x_sugar = n_sugar/(n_sugar+n_water)
x_water = n_water/(n_sugar+n_water)
p_sugar = 0
p_ice_by_p_water = x_water
def f(T):
return 1+0.0096686*T+4.0176*10**(-5)*T**(2)-p_ice_by_p_water
T = fsolve(f,0)
print "Freezing-point temperature of the given solution is %f C"%(T)