Chapter 2 : P V T Relations

Example 2.1 Page No : 29

In [1]:
import math 

#Given
m = 140 #m is the mass of N2 in Kg
P = 4.052*(10**5) #P is the pressure of the system in Pa
V = 30 #V is the volume of the system in m**3
R = 8314.4 # R is the gas consmath.tant

#To determine temperature required
T = P*V/float(((m/28)*R)) #T is the temperature of the system in K
print "Temperature of the system is ",
print "%.6f"%T,
print "K"
#end
Temperature of the system is  292.408352 K

Example 2.5 Page No : 33

In [2]:
import math
import numpy
from numpy.polynomial import Polynomial as poly


#Given
n = 1 #n is Kg moles of methane
T = 423 #T is the temperatue of the system in kelvin
P = float(100) #P is the pressure of the system in atm
Tc = 191 #Tc is the critical temperature of the system in K
Pc = 45.8 #Pc is the critical pressure of the system in atm
R = 0.08206 #R is the gas consmath.tant in (m**3 atm/Kg mole K)

#To calculate the volume of methane
#(i)Umath.sing ideal gas equation
V1 = (n*R*T)/P #V1 is the volume of the gas in m**3
print "i)Volume of the gas umath.sing ideal gas equation is ",
print "%.6f"%V1,
print "cubic meter"

#(ii)Umath.sing Vander Waals' equation
a = (27*(R**2)*(Tc**2))/(64*Pc) #Vander Waais consmath.tant
b = (R*Tc)/(8*Pc) #Vander Waais consmath.tant
q = numpy.poly1d([1,-(((R*T)+(b*P))/P),-((a*b)/P)+(a/P),0])
r = numpy.roots(q)
print " ii)Volume of the gas umath.sing Vander Waals equation is",
print "%.6f"%r[0],
print "cubic meter"

#(iii)Umath.sing generalized Z chart
Tr = T/Tc #Tr is the reduced temperatue
Pr = P/Pc #Pr is the reduced pressure
#From the figure A.2.2,
Z = 0.97 #Z is the compressibility factor
V = (Z*R*T)/P 
print " iii)Volume of the gas umath.sing Z chart is ",
print "%.6f"%V,
print "cubic meter"

#(iv)Umath.sing molar polarisation method
#From Table 2.2
Pmc = 6.82 #Pmc is the molar polarisation for methane
#From figure A.2.4
Z0 = .965 
Z1 = 14.8*(10**-4)
Z = Z0+(Z1*Pmc)
V = (Z*R*T)/P
print " iv)Volume of the gas umath.sing molar polarisation method is ",
print "%.6f"%V,
print "cubic meter"


#(v)From experiment
#Given
Z = 0.9848
V = (0.9848*n*R*T)/P
print " v)Volume of the gas calculated by experimental Z value is ",
print "%.6f"%V,
print "cubic meter"
#end
i)Volume of the gas umath.sing ideal gas equation is  0.347114 cubic meter
 ii)Volume of the gas umath.sing Vander Waals equation is 0.322787 cubic meter
 iii)Volume of the gas umath.sing Z chart is  0.336700 cubic meter
 iv)Volume of the gas umath.sing molar polarisation method is  0.338468 cubic meter
 v)Volume of the gas calculated by experimental Z value is  0.341838 cubic meter

Example 2.6 Page No : 35

In [4]:
%matplotlib inline
import math
import matplotlib.pyplot as plt
import numpy

#Given
P1 = 266
T1 = 473.16#Initial temperature in Kelvin
T2 = 273.16#Final temperature in Kelvin
V1 = 80
V2 = 80 #Initial & final volume in litres
N1 = (14.28/28)
N2 = (14.28/28) #Initial and final Kg moles are equal
Tc = 126 #Critical temperature of N2 in K
Pc = 33.5#Critical pressure of N2 in atm

#To calculate the final pressure achieved
#(i)Umath.sing ideal gas law
p2 = (P1*V1*N2*T2)/(V2*N1*T1);
print "i)Final pressure of N2  using ideal gas law is ",
print "%.6f"%p2,
print "atm"

#(ii)Umath.sing generalized Z chart
Tr1 = T1/Tc#reduced initial temp in k
Pr1 = P1/Pc #reduced initial press in K
#From the Z-chart compressibility factor coressponding to the above Tr1 &Pr1 is
Z1 = 1.07
P2 = [125,135,150]
Z2 = [0.95, 0.96, 0.98]
F = [];
for i in range(0,3):
    F.append((P2[i]/(Z2[i]*T2))-(P1/(Z1*T1)));
plt.plot(P2,F)
plt.ylabel("F")
plt.xlabel("P2")
plt.title("P2 vs F")
plt.show()
P3 = numpy.interp(0,F,P2);
print " ii)Final pressure of N2 from Z chart is ",
print "%.6f"%P3,
print " atm"
#(iii)Umath.sing Pseudo reduced density chart
R = 0.082 #gas consmath.tant
v = V1/N1 #Volume per moles of nitrogen in m**3/Kg mole
Dr = (R*Tc)/(Pc*v)
Tr2 = T2/Tc #final reduced temp in K
#From figure A.2.1, reduced pressure coressponding to this Dr and Tr2 is
Pr2 = 4.1#final reduced pressure in atm
p2_ = Pr2*Pc
print " iii)Final pressure achieved umath.sing Dr chart is ",
print "%.6f"%p2_,
print "atm"
#end
i)Final pressure of N2  using ideal gas law is  153.564460 atm
 ii)Final pressure of N2 from Z chart is  138.489629  atm
 iii)Final pressure achieved umath.sing Dr chart is  137.350000 atm

Example 2.7 Page No : 36

In [5]:
import math 

#Given
n = 1 #n is the Kg mole of methane gas
T = 298 #T is the consmath.tant temperature in K
P1 = 1 #P1 is the initial pressure of the system
P2 = 100 #P2 is the final pressure of the system
R = 8314.4 #R is the gas consmath.tant in Nm/Kgmole deg K

#To compute the work required
#(i)Umath.sing ideal gas law
W = R*T*math.log(P1/float(P2))
print "i)Work done by the system if the gas obeys ideal gas law is ",
print "%.2e"%W,
print 

#(ii)Umath.sing Vander Waals' equation
#Given
#For methane
a = 2.32*(10**5) #Vander Wals' consmath.tant a in N/m**2
b = 0.0428 #Vanderwaals' consmath.tant b in m**3
#V1 and V2 are evaluated by trial and error umath.sing Vanderwaals' equation as P1 and P2 are known
V1 = 11.1 #initial volume of the gas in m**3
V2 = 0.089 #final volume of the gas in m**3
W = (R*T*math.log((V2-b)/(V1-b)))+(a*((1/V2)-(1/V1)))
print " ii)Work done by the system if the gas obeys Vander Waals equation is ",
print "%.2e"%W,
print "Nm"
#end
i)Work done by the system if the gas obeys ideal gas law is  -1.14e+07
 ii)Work done by the system if the gas obeys Vander Waals equation is  -1.10e+07 Nm

Example 2.8 Page No : 38

In [6]:
%matplotlib inline
import math
import matplotlib.pyplot as plt
import numpy

#Given
V = 27*(10**-3) #Volume of the container in m**3
n = (15/70.91) #n is the Kg moles of chlorine
T = float(293)#T is the temperature in K
R = 0.08206
P = pow(10,(4.39-(1045/293))) #P is the vapour pressure of chlorine
Pc = 76.1 #Critical pressure of Chlorine
Tc = float(417) #Critical temperature of Chlorine 
Pr = P/Pc #Reduced pressure of Chlorine
Tr = T/Tc #Critical temperature of Chlorine
M = 70.91 #Molecular weight of the Chlorine

#To determine the vapour pressure of chlorine, amount of liquid Cl2 and temperature required
#(i)Specific volume of liquid Chlorine
#From figure A.2.2
Zg = 0.93
#From figure A.2.6
Zl = 0.013
vl = ((Zl*R*T)/P)
print "i)Specific volume of liquid Chlorine from compressibility chart is ",
print "%.6f"%vl,
print "cubic meter /Kgmole"

#From Francis relation, taking the consmath.tants from Table 2.3
D = (1.606-(216*(10**-5)*20)-(28/(200-20)))*10**3 #Density of liq Cl2 in Kg/m**3
Vl = M/D;
print "   Specific volume of liquid Chlorine from Francis relation is ",
print "%.6f"%Vl,
print "cubic meter /Kgmole"

#(ii)Amount of liquid Cl2 present in the cylinder
vg = ((Zg*R*T)/P)
V1 = V-vg #V1 is the volume of liquid Chlorine
Vct = 0.027 #volume of the container
Vg = (0.212-(Vct/vl))/((1/vg)-(1/vl)) #By material balance
W = ((V-Vg)*70.9)/vl 
print " ii)Weight of Chlorine at 20deg cel is ",
print "%.6f"%W
print "Kg"

#(iii)Calculation of temperature required to evaporate all the liquid chlorine
#math.log P' = 4.39 - 1045/T (given)
#Assume the various temperature
Ng = 0.212#total Kg moles of gas
Ta = [413,415,417]
N = [0,0,0]
for i in range(0,3):
    Tr = Ta[i]/Tc #reduced temperature in K
    P = pow(10,(4.39-(1045/Ta[i])))
    Pr = P/Pc #reduced pressure in K
#From the compressibility factor chart,Z values coressponding to the above Tr &Pr are given as
    Z = [0.4,0.328,0.208]
    N[i] = (P*Vct)/(Z[i]*R*Ta[i])
#end


plt.plot(N,Ta)
plt.ylabel("Ta")
plt.xlabel("N")
plt.title("Ta vs N")
plt.show()
T1 = numpy.interp(0.212,N,Ta) #in K
print " iii)The temperature required to evaporate all the liquid chlorine is ",
print "%.6f"%(T1-273),
print "deg celsius"
#end
i)Specific volume of liquid Chlorine from compressibility chart is  0.012733 cubic meter /Kgmole
   Specific volume of liquid Chlorine from Francis relation is  0.045374 cubic meter /Kgmole
 ii)Weight of Chlorine at 20deg cel is  13.112602
Kg
 iii)The temperature required to evaporate all the liquid chlorine is  140.000000 deg celsius

Example 2.9 Page No : 40

In [8]:
import math
import numpy


#Given
N1 = 0.7 #Kg mole of CH4
N2 = 0.3 #Kg mole of N2
R = 0.08206 #Gas consmath.tant
T = float(323) #Temperature in Kelvin
V = 0.04 #Volume in m**3
a1 = 2.280
b1 = 0.0428 #Vanderwaals consmath.tants for CH4
a2 = 1.345
b2 = 0.0386 #Vanderwaals consmath.tants for N2
Tc1 = 191
Pc1 = 45.8 #Critical temperature in K and pressure of CH4 in atm
Tc2 = 126
Pc2 = 33.5 #Critical temperature in K and pressure of N2 in atm

#To find Approx Value
def approx(V,n):
    A = numpy.around([V*pow(10,n)])/pow(10,n)
    return A[0]

#To calculate the pressure exerted by the gas mixture
#(i)Umath.sing ideal gas law
P = (N1+N2)*((R*T)/V)
print "i) Pressure exerted by the gas mixture umath.sing ideal gas law is ",
print "%d"%P,
print "atm"

#(ii)Umath.sing Vander waal equation
P1 = ((N1*R*T)/(V-(N1*b1)))-((a1*(N1**2))/(V**2)) #Partial pressure of CH4
P2 = ((N2*R*T)/(V-(N2*b2)))-((a2*(N2**2))/(V**2)) #Partial pressure of N2
Pt = P1+P2 
print "ii) Pressure exerted by the gas mixture umath.sing Vander waal equation is ",
print "%.6f"%Pt,
print "atm"

#(iii)Umath.sing Zchart and Dalton's law
Tra = T/Tc1 #reduced temperature of CH4
Trb = T/Tc2 #reduced temperature of N2
#Asssume the pressure
P = [660,732,793,815,831]
Pa =[]
Pb = []
Pra = []
Prb = []
for i in range(0,5):
    Pa.append(N1*P[i]) # partial pressure of CH4 for the ith total pressure
    Pb.append(N2*P[i]) # partial pressure of N2 for the ith total pressure
    Pra.append(Pa[i]/Pc1) #reduced pressure of CH4 for the ith total pressure
    Prb.append(Pb[i]/Pc2) #reduced pressure of N2 for the ith total pressure
#end

#For the above Pr and Tr values compressibility factors  from the figure A.2.3 are given as
Za = [1.154,1.280,1.331,1.370,1.390] #Z values of CH4  
Zb = [1,1,1,1,1]#Z values of N2
V3 = 0.0421
for i in range(0,5):
    Pa[i] = Za[i]*N1*((R*T)/V);#partial pressure of CH4 coressponding to the ith total presure
    Pb[i] = Zb[i]*N2*((R*T)/V);#partial pressure of N2 coressponding to the ith total pressure
    Pt = Pa[i]+Pb[i] #total pressure of the gas mixture
    if Pt-P[i] < 15:
        print "iii) pressure exerted by the gas mixture umath.sing Z chart and Dalton Law is ",
        print "%d"%Pt,
        print "atm"
    #end
#end

#(iv)Umath.sing Amagat's law and Z chart
P = [1000,1200,1500,1700]
for i in range(0,4):
    Pra[i] = P[i]/Pc1
    Prb[i] = P[i]/Pc2
#end
#For the above Pr and Tr values compressibility factors  from the figure A.2.3 are given as
Za = [1.87,2.14,2.52,2.77]
Zb = [1.80,2.10,2.37,2.54]
Va = []
Vb = []
V1 = []
for i in range(0,4):
    Va.append(approx((N1*Za[i]*((R*T)/P[i])),4))
    Vb.append(approx((N2*Zb[i]*((R*T)/P[i])),4))
    V1.append(approx((Va[i]+Vb[i]),4))
    if V1[i]-V <= 0.003:
        print "iv) Pressure exerted by the gas mixture umath.sing Amagat law and Zchart is ",
        print "%d"%P[i],
        print "atm"
#end
#end
#end
i) Pressure exerted by the gas mixture umath.sing ideal gas law is  662 atm
ii) Pressure exerted by the gas mixture umath.sing Vander waal equation is  1353.867785 atm
iii) pressure exerted by the gas mixture umath.sing Z chart and Dalton Law is  843 atm
iv) Pressure exerted by the gas mixture umath.sing Amagat law and Zchart is  1700 atm

Example 2.10 Page No : 41

In [9]:
import math 

#Given
yN2 = 1.0/4 #mole faction of N2 in the mixture
yH2 = 3.0/4 #mole fraction of H2 in the mixture
V = 5.7 #V is the rate at which mixture enters in m**3 in 1 hour
P = float(600) #P is in atm
T = float(298) #T is in K
TcN2 = float(126) #critical temp of N2 in K
TcH2 = 33.3 #critical temp of H2 in K
TcNh3 = 406.0 #critical temp of NH3 in K
PcN2 = 33.5 #critical pressure of N2 in atm
PcH2 = 12.8 #critical pressure of H2 in atm
PcNH3 = 111.0 #critical pressure of NH3 in atm
R = 0.082 #gas consmath.tant

#To calculate the amount of ammonia leaving the reactor and the velocity of gaseous product leaving the reactor
#(i)Calculation of amount of NH3 leaving the reactor
Tcm = (TcN2*yN2)+(TcH2*yH2) #critical temperature of the mixture
Pcm = (PcN2*yN2)+(PcH2*yH2) #critical pressure of the mixture
Trm = T/Tcm 
Prm = P/Pcm 
#From figure A.2.3
Zm = 1.57 #compressibility factor of the mixture
N = (P*V)/(Zm*R*T) #Kg mole of the mixture 
N1 = 0.25*N #Kg mole of N2 in feed
#N2+3H2 - 2NH3
W = 2*0.15*N1*17 
print "i)Ammonia formed per hour is ",
print "%.6f"%W,
print "Kg"

#(ii)Calculation of velocity
N1 = 0.25*N-(0.25*N*0.15) #Kg mole of N2 after reactor
N2 = 0.75*N-(0.75*N*0.15) #Kg mole of H2 after reactor
N3 = 0.25*N*2*0.15 #Kg mole of NH3 after reactor
Nt = N1+N2+N3 #total Kg moles after reactor
y1NH3 = N3/Nt #mole fraction of NH3 after reactor
y1N2 = N1/Nt #mole fraction of N2 after reactor
y1H2 = N2/Nt #mole fraction of H2 after reactor
T1cm = (TcN2*y1N2)+(TcH2*y1H2) 
P1cm = (PcN2*y1N2)+(PcH2*y1H2) 
T1 = 448 #in K
P1 = 550 #in atm
T1rm = T1/T1cm 
P1rm = P1/P1cm
#From Figure A.2.2
Zm1 = 1.38
V1 = (Zm1*Nt*R*T1)/P1
d = 5*(10**-2)#diameter of pipe
v = V1/((math.pi/4)*(d**2)*3600)
print "ii)Velocity in pipe is ",
print "%.6f"%v,
print "m/s"
#end
i)Ammonia formed per hour is  113.659704 Kg
ii)Velocity in pipe is  1.075261 m/s