Chapter 4:Flow of compressible Fluids

Example no:4.1,Page no:150

In [75]:
#Variable declaration
d=0.006 #Diameter of the cylinder
Gamma=1.47 
#The critical pressures ratio for discharge through the valve
C_r=(2/(Gamma+1))**(Gamma/(Gamma-1)) 
#(i) Sonic velocity will occur until the
P_c=101.3/C_r #pressure at which sonic velocity will occur
M=29 #molecular mass of air


#Calculatiom

%matplotlib inline
import numpy as np
import math
G=[0]*13
G2=[0]*11
P1a=[0.1,0.125,0.15,0.17,0.19,0.2,0.5,1.0,2.0,3.0,4.0,5.0,6.0]
for i in range(4,13):
    G[i]=4.23e-2*P1a[i] 
for j in range(0,4):
    
    G[j]=0.0314*(P1a[j])**0.286*math.sqrt((1.0-round(0.519*(P1a[j])**(-0.286),2)))
P2a=[0,1,2,2.65,3,3.5,4,4.5,4.9,4.95,5] 
for j in range(4,11):
    G2[j]=0.2548*P2a[j]**0.714*math.sqrt(1-0.631*P2a[j]**0.286) 

for i in range(0,4):
    G2[i]=0.210 
    

#Result
print"\n\n(i)...The discharge rate are plotted as:"
print"G vs P1a data:"
print"Above P1a=0.19 MN/m**2"
print"P1a(MN/m^2)\tG(kg/s)"
for z in range(4,13):
    
        print P1a[z],"\t\t",round(G[z],4)
print"\nBelow P1a=0.19 MN/m**2"
print"P1a(MN/m^2)\tG(kg/s)"
for w in range(0,5):
    print P1a[w],"\t\t",round(G[w],4)
a=plt.plot(P1a,G) 
plt.title('Rate of discharge of air vs Cylider Pressure\n')
plt.xlabel('$Cylinder Pressure,P1a(MN/m**2$')
plt.ylabel('$Mass flow G (kg/s)$')
show(a)
print"\n\n(ii)...The Values of G as a functio of P2a:"
print"P2a(MN/m^2)\tG(kg/s)"
print "<0.265","\t\t",round(G2[3],4)
for w in range(4,10):
    print P2a[w],"\t\t",round(G2[w],4)
print P2a[10],"\t\t",round(G2[10])
b=plt.plot(P2a,G2) 
plt.annotate('G max', xy=(1,0.22), xytext=(1,0.22))
plt.title('Rate of discharge of air vs Downstream Pressure\n')
plt.xlabel('$Downstream Pressure,P2a(MN/m**2)$')
plt.ylabel('$Mass flow rate G (kg/s)$')

show(b)
Populating the interactive namespace from numpy and matplotlib


(i)...The discharge rate are plotted as:
G vs P1a data:
Above P1a=0.19 MN/m**2
P1a(MN/m^2)	G(kg/s)
0.19 		0.008
0.2 		0.0085
0.5 		0.0211
1.0 		0.0423
2.0 		0.0846
3.0 		0.1269
4.0 		0.1692
5.0 		0.2115
6.0 		0.2538

Below P1a=0.19 MN/m**2
P1a(MN/m^2)	G(kg/s)
0.1 		0.0
0.125 		0.0042
0.15 		0.0061
0.17 		0.0071
0.19 		0.008

(ii)...The Values of G as a functio of P2a:
P2a(MN/m^2)	G(kg/s)
<0.265 		0.21
3 		0.2059
3.5 		0.1942
4 		0.1707
4.5 		0.1288
4.9 		0.0609
4.95 		0.0439
5 		0.0

Example no:4.2,Page no:167

In [81]:
#Variable declaration
l=30 #Length of the tube
d=150e-3 #Diameter of the tube
P1=0.4e3 #Initial Pressure
P2=0.13e3 #final Pressure
X=0.003 
Y=0.005 
v1=21.15e1 

#Calculation
import math
import sympy
G_A=sympy.Symbol('G_A') 
f=(G_A**2*math.log(P1/P2))+((P2**2-P1**2)/(2*P1*v1))+(4*(Y*l/d)*G_A**2) 
A=sympy.solve(f) 

#Result
print"The approximate flow rate =",round(A[1],2),"kg/m**2 s"
The approximate flow rate = 0.41 kg/m**2 s

Example no:4.3,Page no:168

In [104]:
#Variable declaration
Q=50.0  #volumetric flow rate of methane
P=101.3e3 #Given Pressure
T1=288.0 #Given Temperature
d=0.6 #Diameter of pipeline
l=3e3 #length of the pipe line
R_R=0.0001 #Relative roughness
P2=1.7*10**5 #Pressure at which methane is to be discharged
T2=297.0 #Temperature at which methane leaves the compressor
M=16.0 #molecular mass of methane
R=8314.0 #Gas constant
Meu=1e-5 #Viscosity of methane at 293 K

#Calculation
import math
from scipy.optimize import fsolve
T=(T1+T2)/2.0 #Mean temperature
P1_v1=R*T/(M) 
#At 288 K and 101.3 kN/m**2
v=P1_v1/P*T1/T 
G=Q/v #Mass flow rate of methane
A=math.pi/4*d**2 #cross sectional area of pipeline
G_A=G/A
Re=G_A*d/Meu 
#Y=R/(rho*u**2) = 0.0015
Y=0.0015 #(from fig 3.7)
#The upstream pressure is calculated using equation 4.55:
def pressure(P1):
    return((G_A**2)*math.log(P1/P2)+(P2**2-P1**2)/(2*P1_v1)+4*Y*(l/d)*G_A**2)
#P1 = 1e5 
z = fsolve(pressure,100000) 

#Result
print"Pressure to  developed at the compressor in order to achieve this flowrate =%.3e"%z,"N/m**2" 
print"NOTE:Approx answer is given in book"
Pressure to  developed at the compressor in order to achieve this flowrate =4.042e+05 N/m**2
NOTE:Approx answer is given in book

Example no:4.4,Page no:176

In [133]:
#Variable declaration
A1=0.007 #cross sectional area of stack pipe
A2=4000e-6 #flow area of ruptured disc
P1=10e6 #Pressure of the gas in the vessel
Gamma=1.4 
M=40 #mean molecular weight of gas

#Calculation
import math
w_c=(2/(Gamma+1))**(Gamma/(Gamma-1)) 
w_c=round(w_c,2)

V1=(22.4/M)*(500.0/273.0)*(101.3e3/P1) #Specific volume of the gas in the reactor
V=V1*(1/w_c)**(1/Gamma) #Specific volume of gas at the throat
u=math.sqrt(Gamma*5.3e6*V) #velocity at the throat
G=u*A2/V #initial rate of discharge
#obtaining the equations as given in book and solving for 'w' we get
w=0.0057 #Pressure ratio
P_u=P1*w 
Mach_no=2.23*(w**(-0.29)-1)**0.5 
P_s=56.3*w*(w**(-0.29)-1)*1e6 


#Result
print"(a)Initial rate of discharge of gas =",round(G,1),"kg/s"
print"(b)The pressure upstream from the shockwave =",P_u/1000.0,"kN/m**2"
print"The mach number is =",round(Mach_no,2)
print"(c)The pressure downstream from the shockwave =",P_s/1000,"kN/m**2"
print"NOTE:Mismatched answer due to very approximate value of v1 taken in book"
(a)Initial rate of discharge of gas = 85.2 kg/s
(b)The pressure upstream from the shockwave = 57.0 kN/m**2
The mach number is = 4.16
(c)The pressure downstream from the shockwave = 1115.17300403 kN/m**2
NOTE:Mismatched answer due to very approximate value of v1 taken in book