import math
#Given
#N2 obeys the relation : Z = 1+(2.11*10**-4*P)
Tc = 126;#Critical temperature in K
Pc = 33.5;#Critical pressure in atm
T = 373;#in K
P = 100;#in atm
#To Calculate the fugacity of N2 at 373K and 100 atm
#(i)Umath.sing the Z relation given above
#From equation 13.12 (page no 239)
phi = math.e**(2.11*10**-4*(P-0));#fugacity coefficient
f = phi*P;
print "i)The fugacity of N2 umath.sing the given Z relation is %f atm"%(f);
#(ii)Umath.sing the fugacity chart given in figure A.2.9
Pr = P/Pc;#Reduced pressure in atm
Tr = T/Tc;#Reduced temperature in K
#From figure A.2.9,
phi = 1.04
f = phi*P;
print " ii)The fugacity of N2 umath.sing the fugacity chart is %f atm"%(f);
#end
import math
#Given
P1 = 50*1.03*10**4;#Initial pressure in Kgf/sq m
T = 373.0;#Temperature in K
P2 = 1.03*10**4;#Final pressure in Kgf/sq m
V = 0.001*18;#Volume in cubic meter
R = 848.0;#gas consmath.tant in m Kgf/Kgmole K
#To Calculate the fugacity of liquid water
#From equation 13.13(page no 240)
del_u = (V/(R*T))*(P2-P1);#del_u = ln(f2/f1); Change in chemical potential
f1 = P2;#in Kgf/sq m
f2 = f1*(math.e**del_u);
print "The fugacity of the liquid water at 50 atm is %4.2e Kgf/sq m"%(f2);
#end
%matplotlib inline
import math
import matplotlib.pyplot as plt
import numpy
#Given
x1 = 0.1;#mole fraction of methane
x2 = 0.9;#mole fraction of propane
P = [28.1,31.6,35.1];#Pressure in Kgf/sq cm are
K1 = [5.8,5.10,4.36];#Vapourisation consmath.tants of methane at the corresponding presssures
K2 = [0.61,0.58,0.56];#Vapourisation consmath.tants of propane at the correspondig pressures
#To Calculate the bubble point pressure of the solution
#From equation 13.27 (page no 245)
y1 = []
y2 = []
y = []
for i in range(0,3):
y1.append(K1[i]*x1);#mole fraction of methane in the vapour phase
y2.append(K2[i]*x2);#mole fraction of propane in the vapour phase
y.append(y1[i]+y2[i]);#sum of the mole fraction in the vapour phase
plt.plot(P,y)
plt.title("y vs pressure")
plt.xlabel("P")
plt.ylabel("y")
plt.show()
P1 = numpy.interp(1,y,P)
print "The bubble point pressure of the solution is %f Kgf/sq cm"%(P1);
#end
import math
#Given
T = [80.6,79.0,77.3,61.4];#Various temperature in deg cel
x1 = [0.0,15.0,29.0,100.0];#mole fraction of CHCl3 in liquid phase
y1 = [0.0,20.0,40.0,100.0];#mole fraction of CHCl3 in vapour phase
P1 = [1370,1310,1230,700];#Vapour pressure of CHCl3 in mm Hg
P = 760.0;#Total pressure in mm Hg
#To Calculate the equilibrium data i.e y/x and compare with the experimental values
#From equation 13.27 (page no 245);K = y1/x1 = Pi/P
print "Temperature Experimental Calculated";
Ke_x = []
K_c = []
for i in range(0,4):
print " %f"%(T[i]),
if x1[i] == 0 :
print " Not defined",
Ke_x.append(0)
else:
Ke_x.append(y1[i]/x1[i]);
print " %f"%(Ke_x[i]),
K_c.append(P1[i]/P);
print " %f"%(K_c[i])
if Ke_x[i] == K_c[i]:
print ' The liquid solution is perfect';
else:
print " The liquid solution is imperfect";
#end
#Given
x1 = 0.1;#Mole fraction of dichloromethane (CCl2H2)
x2 = 0.9;#Mole fraction of methyl acetate (C3H6O2)
M1 = 85.0;#Molecular weight of CCl2H2
M2 = 74.0;#Molecular weight of C3H602
D1 = 1.3163;#Density of CCl2H2 in gm/cc
D2 = 0.9279;#Density of C3H6O2 in gm/cc
#To Calculate the volume of 10% dichloromethane solution
V1 = M1/D1;#Specific volume of pure CCL2H2 in cc/gmole
V2 = M2/D2;#Specific volume of C3H6O2 in cc/gmole
#From equation 13.62(page no 256)& 13.78 (page no 257)
V_e = x1*x2*(1.2672-0.771*x1);#excess volume in cc/gmole
V = V1*x1+V2*x2+V_e;
print "The volume of 10 percent dichloromethane is %f cc/gmole"%(V);
#end
%matplotlib inline
import math
import matplotlib.pyplot as plt
import numpy
#Given
x_T = 0.957;#mole fraction of Toluene
x_D = 0.043;#mole fraction of 1,2-dichloroethane
t = [90, 100, 110];#temperature in deg cel
R = 1.98;#gas consmath.tant in Kcal/Kgmole K
#To Calculate the vapour pressure of the solution, bubble point at 686 mm Hg and the vapour composition at equilibrium,
#compare the experimental value of 91.2% toluene in vapour with the calculated value & calculate the free energy of mixing
#(1)Calculation of vapour pressure
print "1Tempdeg cel P_TmmHg P_DmmHg P_smmHg";
P_T = []
P_D = []
P_s = []
for i in range(0,3):
P_T.append(10**(6.95464-(1344.8/(219.482+t[i]))));#Given as equation(a)(page no 260)
P_D.append(10**(7.03993-(1274.079/(223+t[i]))));#Given as equation(b)(page no 260)
P_s.append(x_T*P_T[i]+x_D*P_D[i]);#pressure of the solution in mm Hg
print ' %f'%(t[i]),
print ' %f'%(P_T[i]),
print ' %f'%(P_D[i]),
print ' %f'%(P_s[i])
#(2)Calculation of bubble point and comparison of values
plt.plot(t,P_s)
plt.title("t vs P_s")
plt.xlabel("t")
plt.ylabel("P_s")
plt.show()
T = numpy.interp(686,P_s,t)
P = 686.0;#pressure of solution in mm Hg
y_T_e = 0.912;#experimental value of mole fraction of toluene
#From the graph we found that the temperature at P = 686 mm Hg is
#t = 105.3;#in deg cel
print '2)The bubble point is %f deg cel'%(T);
#From equation (a)(page no 260)
P_T = 10**(6.95464-(1344.8/(219.482+T)));#vapour pressure of Toluene in mmHg
#From equation 13.27 (page no 245)
y_T_c = (x_T*P_T)/P;
y_D_c = 1-y_T_c;
print ' The vapour composition of toluene is %f'%(y_T_c);
print ' The vapour composition of 1,(2-dichloroethane is %f'%(y_D_c);
e = ((y_T_e-y_T_c)/y_T_e)*100;
print ' The percentage error is %f percent'%(e);
#(3)Calculation of free energy
del_F = R*(T+273)*((x_T*math.log(x_T))+(x_D*math.log(x_D)));
print '3)The free energy of mixing is %f Kcal/Kgmole'%(del_F);
#end
import math
#Given
#Consider the diagram shown in page no 263
w1 = 100.0;#weight of LiBr entered as feed in the evaporator per hour in Kg
x1 = 0.45;#weight fraction of LiBr entered as feed
x2 = 0.0;#weight fraction of steam in the LiBr soln
x3 = 0.65;#weight fraction of LiBr formed as product
H1 = -39.0;#Enthalpy of 45% solution at 25 deg cel in Kcal/Kg
H3 = -4.15;#Enthalpy of 65% solution at 114.4 deg cel in Kcal/Kg
H2 = 649.0;#Enthalpy of superheated steam at 100 mmHg and 114.4 deg cel in Kcal/Kg
#To Calculate the heating load required for the process
#According to material balance
w3 = (w1*x1)/x3;#weight of LiBr solution formed after evaporation per hour in Kg
w2 = w1-w3;# weight of steam formed in Kg/hr
#According to energy balance
Q = (w2*H2)+(w3*H3)-(w1*H1);
print 'The heat that has to be supplied for this concentration process is %f Kcal/hr'%(Q);
#end
%matplotlib inline
import math
import matplotlib.pyplot as plt
import numpy
#Given
x_A = [0.0, 0.0435, 0.0942, 0.1711, 0.2403, 0.3380, 0.5981];#mole fraction of acetic acid
p_A = [0.0, 17.2, 30.5, 46.5, 57.8, 69.3, 95.7];#partial pressure of acetic acid in mmHg
P_T1 = 202.0;#vapour pressure of toulene in mmHg
P_T2_ex = 167.3;#experimental partial pressure in mmmHg
#To Calculate the partial pressure of toulene in the solution and check with the experimental value
#From the equation 13.95,
#ln(P_T2/P_T1) = -intg(x_A/((1-x_A)*p_A))
x = []
for i in range(0,7):
if (p_A[i] != 0):
x.append((x_A[i]/((1-x_A[i])*p_A[i]))*10**4)
else:
x.append(0)
plt.plot(x,p_A)
plt.title(" ")
plt.xlabel("(x_A/((1-x_A)*p_A))*10**4")
plt.ylabel("p_A")
plt.show()
#Area of the graph drawn is
A = -0.138;
P_T2 = (math.e**A)*P_T1;
e = ((P_T2-P_T2_ex)*100)/P_T2_ex;
print 'The partial pressure of toulene is %f mmHg'%(P_T2);
print ' This deviates %i percent from the reported value'%(e);
#end
%matplotlib inline
import math
import matplotlib.pyplot as plt
import numpy
from numpy.linalg import solve
#Given
P = 760.0;#pressure at maximum boiling azeotrope of A and B in mmHg
x_A = 0.6;#mole fraction of A in liquid phase
x_B = 0.4;#mole fraction of B in liquid phase
p_A = 600.0;#vapour pressure of A at 90 deg cel
p_B = 300.0;#vapour pressure of B at 90 deg cel
#To Check whether the activity coefficient of the solution can be represented by the Margules equation
y_A = P/p_A;#Activity coefficient of A
y_B = P/p_B;#Activity coefficient of B
#From the Margules equation or equation (a) & (b)
U = [[((x_B**2)-(2*(x_B**2)*x_A)), (2*(x_B**2)*x_A)], [(2*(x_A**2)*x_B), ((x_A**2)-(2*(x_A**2)*x_B))]];
V = [math.log(y_A), math.log(y_B)];
W = solve(U,V);
#Now the value of consmath.tants A and B in equations(a)&(b) are given as
A = W[0];
B = W[1];
#let us assume
x_A = [0.0,0.2,0.4,0.6,0.8,1.0];
x_B = [1.0,0.8,0.6,0.4,0.2,0.0];
#C = lny_A; D = lny_B; E = ln(y_A/y_B)
C = []
D = []
E = []
for i in range(6):
C.append((x_B[i]**2)*(2*(B-A)*x_A[i]+A));
D.append((x_A[i]**2)*(2*(A-B)*x_B[i]+B));
E.append(C[i]-D[i]);
plt.plot(x_A,E)
plt.title(" ")
plt.xlabel("x_A")
plt.ylabel("ln(y_A/y_B)")
plt.show()
#Since the graph drawn is approximately symmetrical.Thus it satisfies the Redlich-Kister Test
print 'The actvity coefficients of the system can be represented by Margules equation';
#end
%matplotlib inline
import math
import matplotlib.pyplot as plt
import numpy
#Given
P = 760.0#Total pressure of the mixture in mmHg
T = [80, 90, 95, 100];#Temperature in deg celsius
P1 = [87.4, 129.0, 162.0, 187.0];#vapour pressure of 1,1,2,2-tetrachloroethane in mmHg
P2 = [356, 526, 648, 760];#Vapour pressure of water in mmHg
#To Calculate the composition of the vapour evolved
plt.plot(T,P1,"green",T,P2,"red")
plt.title(" ")
plt.xlabel("Temp in deg cel")
plt.ylabel("Vapour pressure in mmHg")
plt.show()
#From the graph we conclude that at 93.8 deg cel
P1 = 155.0;#in mm Hg
P2 = 605.0;#in mm Hg
y_1 = P1/P;
y_2 = P2/P;
print 'Mole fraction of 1,(1,(2,(2-tetrachloroethane in vapour is %f'%(y_1);
print ' Mole fraction of water in vapour is %f'%(y_2);
#end
%matplotlib inline
import math
import matplotlib.pyplot as plt
import numpy
#Given
T = [146.2, 142.3, 126.1, 115.9, 95.0, 98.0, 100.0];#Temperature in deg cel
P1 = [760.0, 685.0, 450.3, 313.0];#Vapour pressure of 1,1,2,2-tetrachloroethane at the coressponding temperature in mm Hg
P2_5 = 648.0;#Vapour pressure of water at 95 deg cel in mm Hg
P2_6 = 711.0;#Vapour pressure of water at 98 deg cel in mm Hg
P = 760.0;#Total pressure of mixture in mm Hg
x1 = [0, 0, 0, 0, 0, 0, 0];
#To plot a graph between temperature and vapour phase composition
for i in range(0,4):
x1[i] = P1[i]/P;#mole fraction of 1,1,2,2-tetrachloroethane
x2_5 = P2_5/P;#mole fraction of water at 95 deg cel
x2_6 = P2_6/P;#mole fraction of water at 98 deg cel
x1[4] = 1-x2_5;
x1[5] = 1-x2_6;
plt.plot(x1,T)
plt.title("")
plt.xlabel("mole fraction of 1,1,2,2-tetrachloroethane")
plt.ylabel("Temperature in deg cel")
plt.show()
print 'The required graph has been ploted in the graphic window';
#end
import math
#Given
#B = -(1.203*10**10)*(T**2.7); second virial coefficient, T is in K
#math.log P = 6.95464-(1344.8/(219.482+t))...(a);Vapour pressure of toulene
t = 107.2;#Temperature in deg cel
T = t+273.16;#in K
H_ex = 7964.0;#experimental value of heat of vapourisation in Kcal/Kgmole
d = 800.0;#density of liquid toulene in Kg/cubic meter
R = 1.98;#gas consmath.tant in Kcal/Kgmole K
M = 92.14;#molecular weight of toulene
#To Calculate the heat of vapourization of toulene by umath.sing ideal gas law, second virial coefficient but neglecting vl and including vl
#From equation (a), let K = dmath.logP/dT
K = 1344.8/(219.482+t)**2;
#(i)Umath.sing ideal gas behaviour
#From equation 13.112(page no 286)
H_c = (2.303*R*(T**2))*K;
print 'i)The heat of vapourization umath.sing ideal gas behaviour is %f Kcal/Kgmole'%(H_c);
D = ((H_c-H_ex)/H_c)*100;
print ' The deviation is %f percent'%(D);
#(ii)Umath.sing second virial coeff but neglecting vl
#From equation(a)
P = 10**(6.95464-1344.8/(219.482+t));#in mm Hg
P1 = P*1.033*10**4/760;#in Kgf/sq m
B = -((1.203*10**10)/(T**2.7))*10**-3;#in cubic meter/Kgmole
#From equation 13.111 (page no 286) neglecting vl,
l = (R*T)+((B*P1)/427);#in Kcal/Kgmole
H_c = K*2.303*T*l;
print 'ii)The heat of vapourisation umath.sing second virial coefficient but neglecting vl is %f Kcal/Kgmole'%(H_c);
D = ((H_c-H_ex)/H_c)*100;
print ' The deviation in this case is %f percent'%(D);
#(iii)Umath.sing second virial coeff including vl
vl = M/d;#Liquid specific volume in cubic meter/Kgmole
n = P1*vl/427;#in Kcal/Kgmole
H_c = K*2.303*T*(l-n);
print 'iii)The heat of vapourisation umath.sing second virial coefficient including vl is %f Kcal/Kgmole'%(H_c);
D = ((H_c-H_ex)/H_c)*100;
print ' The deviation in this case is %f'%(D);
#end
import math
#Given
H_ex = 539.0;#Heat of vapoization of water in Kcal/Kg
Tc = 647.0;#Critical temperature in K
Pc = 218.0;#Critical pressure in atm
Tb = 373.0;#Boiling point of water in K
t = 100.0;#temperature in deg cel
M = 18.0;#Molecular weight of water
P = 1.0;#pressure at boiling point in atm
P1 = 1.033*10**4;#pressure in Kgf/sq m
#To Calculate the heat of vapourisation of water by Vishwanath and Kuloor method and by Riedel's method and compare with the experimental value
#(i) Umath.sing Vishwanath and Kuloor method
H_c = (4.7*Tc*((1-(P/Pc))**0.69)*math.log(P/Pc))/((1-(Tc/Tb))*18);
print 'i)The heat of vapourisation of water umath.sing Vishwanath and Kuloor method is %f Kcal/Kg'%(H_c);
D = (H_c-H_ex)*100/H_c;
print ' The deviation occurs umath.sing this method is %f percent'%(D);
#(ii)Umath.sing Riedel's method
H_c = (Tb*2.17*(math.log(218)-1))/((0.93-(Tb/Tc))*18);
print 'ii)The heat of vapourisation of water umath.sing Riedel method is %f Kcal/Kg'%(H_c);
D = (H_c-H_ex)*100/H_c;
print ' The deviation occurs umath.sing this method is %f percent'%(D);
#(iii)By umath.sing given vapour equation; math.logP = 8.2157-(2218.8537/(273.16+t)), t is in deg cel
#From steam table,
Vv = 1.673;#in cubic meter/Kg
Vl = 0.001;#in cubic meter/Kg
H_c = (2218.8/(273.16+t)**2)*(2.3*Tb*P1*(Vv-Vl)/427);
print 'iii)The heat of vapourisation umath.sing the given vapour equation is %f Kcal/Kg'%(H_c);
D = (H_c-H_ex)*100/H_c;
print ' The deviation occurs umath.sing this method is %f percent'%(D);
#end
import math
#Given
T1 = 273-87.0;#temp in K
T2 = 273.0;#temp in K
H1 = 115.0;#Latent heat of saturated ethane at 1 atm and -87 deg cel in Kcal/Kg
H2_ex = 72.44;#Experimental value of latent heat at 0 deg cel in Kcal/Kg
Tc = 306.0;#Critical temperature in K
M = 30.0;#Molecular weight of ethane
#To Calculate the latent heat of saturated ethane at 0 deg cel
Tr1 = T1/Tc;#reduced temp in K
Tr2 = T2/Tc;#reduced temp in K
#(i)Umath.sing Waton's method:
H2_c = H1*((1-Tr2)/(1-Tr1))**0.38;
print 'i)The latent heat of saturated ethane at 0 deg cel umath.sing Waton method is %f Kcal/Kg'%(H2_c);
D = (H2_ex-H2_c)*100/H2_ex;
print ' The deviation occurs umath.sing this method is %f percent'%(D);
#(ii)Umath.sing Vishwanath and Kuloor method
#From equation 13.117 (page no 289)
n = (0.00133*(H1*M/T1)+0.8794)**(1/0.1);
H2_c = H1*((1-Tr2)/(1-Tr1))**n;
print 'ii)The latent heat of saturated ethane at 0 deg cel umath.sing Vishwanath and Kuloor method is %f Kcal/Kg'%(H2_c);
D = (H2_ex-H2_c)*100/H2_ex;
print ' The deviation occurs umath.sing this method is %f percent'%(D);
#end
import math
#Given
H_s_ex = 32.7;#experimental value of latent heat of the solution in KJ/mole
x1 = 0.536;#mole percent of toulene in the solution
x2 = 1-0.536;#mole percent of 1,1,1-trichloroethane in the solution
H1 = 33.34;#Latent heat of toulene in KJ/gmole
H2 = 29.72;#Latent heat of 1,1,1-trichloroethane in KJ/gmole
He = 0.0;#excess enthalpy is neglected
Cp1 = 39.55;#Specific heat of toulene in cal/gmole deg cel
Cp2 = 24.62;#Specific heat of 1,1,1-trichloroethane in cal/gmole deg cel
T_D = 100.0;#dew point temperature in deg cel
T_B = 92.6;#bubble point temperature in deg cel
#To calculate the latent heat of the solution and compare it with the one which calculated from the given vapour pressure equation
#(i)Calculation of latent heat of the solution
#From equation 13.118 (page no 291)
H_s = H1*x1+H2*x2+He+(Cp1*x1+Cp2*x2)*10**-3*4.17*(T_D-T_B);
print 'i)The latent heat of the solution is %f KJ/gmole'%(H_s);
D = ((H_s_ex-H_s)*100)/H_s_ex;
print ' The deviation occurs using this method is %f percent'%(D);
#(ii)Calculation of latent heat from the vapour pressure equation
#From equation (a) (page no 291)
K = 1657.599/((273.16+5)**2);
H_s = (K*2.303*8.314*(273.16+5)**2)*10**-3;
print 'ii)The latent heat of the solution is %f KJ/gmole'%(H_s);
D = ((H_s_ex-H_s)*100)/H_s_ex;
print ' The deviation occurs using this method is %f percent'%(D);
#end