Chapter 2 : pipe flow of gasses and gas liquid mixtures

example 2.1 page no : 27

In [1]:
from scipy.optimize import fsolve
from math import *

# Initialization of Variable
pi = 3.1428
mmm = 16.04/1000            #molar mass of methane
mV = 22.414/1000            #molar volume
R = 8.314
mu = 1.08/10**5
r = 4.2/100                 #radius
rr = 0.026/2/r              #relative roughness
Pfinal = 560.*1000.
tfinal = 273+24
l = 68.5
m = 2.35                    #mass flow rate

#calculation
A = pi*r**2
A = round(A*10.**5)/10.**5
rho = mmm/mV
rho24 = mmm*Pfinal*273/mV/101.3/tfinal          #density at 24'C
u = m/rho24/A
Re = u*rho24*2*r/mu

#from graph
phi = 0.0032
#for solving using fsolve we copy numerical value of constant terms
#using back calculation
#as pressure maintained should be more than Pfinal so guessed value is Pfinal

def eqn(x):
    y = m**2/A**2*log(x/Pfinal)+(Pfinal**2-x**2)/2/R/tfinal*mmm+4*phi*l/2/r*m**2/A**2
    return y
x = fsolve(eqn,560*10**3)
print "pressure maintained at compressor in (kN/m**2):",x[0]/1000
pressure maintained at compressor in (kN/m**2): 960.06917347

example 2.2 pageno : 29

In [1]:
from math import *
from numpy import *
from scipy.optimize import fsolve

# Initialization of Variable
M = 28.8/1000
mu = 1.73/10**5
gamm = 1.402
P1 = 107.6*10**3
V = 22.414/1000
R = 8.314
temp = 285.
d = 4./1000
rr = 0.0008
phi = 0.00285
l = 68.5  

#calculation
#constant term of equation
#part1

a = 1.-8*phi*l/d            #constant term in deff
def f(x):
    return log(x**2)-x**2+2.938
    
x = fsolve(f,1)
print x
z = 1./x[0]
z = round(z*1000.)/1000
print "ratio of Pw/P1 : %.4f"%z

#part2
Pw = z*P1
nuw = V*P1*temp/Pw/M/273.
Uw = sqrt(nuw*Pw)
print "maximum velocity in (m/s): %.4f"%Uw

#part3
Gw = pi*d**2/4*Pw/Uw
print "maximum mass flow rate in(kg/s): %.4f"%Gw

#part4
G = 2.173/1000
J = G*Uw**2/2
print "heat taken up to maintain isothermal codition(J/s): %.4f"%J

#part5
nu2 = 2.79              #found from graph
nu1 = R*temp/M/P1
P2 = P1*(nu1/nu2)**gamm
print "crtical pressure ratio in adiabatic condition: %.4f"%(P2/P1)

#part6
Uw = sqrt(gamm*P2*nu2)
print "velocity at adiabatic condition in (m/s): %.4f"%Uw

#part7
Gw = pi*d**2/4*Uw/nu2
print "mass flow rate at adiabatic condition in (kg/s): %.4f"%Gw


#part8
#polynomial in T of the form ax**2+bx+c = 0
c = gamm/(gamm-1)*P1*nu1+.5*Gw**2/pi**2/d**4*16*nu1**2
b = gamm/(gamm-1)*R/M
a = .5*Gw**2/pi**2/d**4*16*(R/M/P2)**2
y = poly1d([a,b,-c],False)
T2 = roots(y)
print "temperature of discharging gas in (Celcius) : %.4f"%(T2[1]-273)
[ 1.0268468]
ratio of Pw/P1 : 0.9740
maximum velocity in (m/s): 295.6723
maximum mass flow rate in(kg/s): 0.0045
heat taken up to maintain isothermal codition(J/s): 94.9841
crtical pressure ratio in adiabatic condition: 0.1629
velocity at adiabatic condition in (m/s): 261.8257
mass flow rate at adiabatic condition in (kg/s): 0.0012
temperature of discharging gas in (Celcius) : -46.3847
/usr/lib/python2.7/dist-packages/scipy/optimize/minpack.py:227: RuntimeWarning: The iteration is not making good progress, as measured by the 
  improvement from the last ten iterations.
  warnings.warn(msg, RuntimeWarning)

example 2.3 pageno : 35

In [2]:
from scipy.optimize import fsolve 
import math 

# Initialization of Variable

#1 refer to initial condition
R=8.314
P1=550.*10**3
T1=273.+350
M=18./1000
d=2.4/100
pi=3.1428
A=pi*d**2./4
gamm=1.33
roughness=0.096/1000/d
l=0.85
phi=0.0035              #assumed value of friction factor

#calculation
nu1=R*T1/M/P1
Pw=0.4*P1              #estimation
nuw=(P1/Pw)**0.75*nu1
enthalpy=3167*1000.
Gw=math.sqrt(enthalpy*A**2/(gamm*nuw**2/(gamm-1)-nu1**2/2-nuw**2/2))
def eqn(x):
    return math.log(x/nu1)+(gamm-1)/gamm*(enthalpy/2*(A/Gw)**2*(1/x**2-1/nu1**2)+0.25*(nu1**2/x**2-1)-.5*math.log(x/nu1))+4*phi*l/d

x=fsolve(eqn,0.2)

if x[0] != nuw:
    print "we again have to estimate Pw/P1"
    print "new estimate assumed as 0.45"
    Pw=0.45*P1                 #new estimation
    nuw=(P1/Pw)**0.75*nu1
    # & we equalise nu2 to nuw
    nu2=nuw 
    Gw=math.sqrt(enthalpy*A**2/(gamm*nuw**2/(gamm-1)-nu1**2./2-nuw**2./2))
    print "mass flow rate of steam through pipe kg/s): %.2f"%(Gw) 
    #part 2
    print "pressure of pipe at downstream end in (kPa):",Pw/1000
else:
    print "our estimation is correct"

#part3
enthalpyw=2888.7*1000.      #estimated from steam table
Tw=math.sqrt((enthalpy-enthalpyw+.5*Gw**2/A**2*nu1**2)*2*A**2/Gw**2/R**2*M**2*Pw**2)
print "temperature of steam emerging from pipe in (Celcius): %.4f"%(Tw-273)
we again have to estimate Pw/P1
new estimate assumed as 0.45
mass flow rate of steam through pipe kg/s): 0.46
pressure of pipe at downstream end in (kPa): 247.5
temperature of steam emerging from pipe in (Celcius): 209.9420

example 2.4 pageno : 39

In [3]:
import math 

# Initialization of Variable
M=28.05/1000
gamm=1.23
R=8.314
atm=101.3*1000
P1=3.*atm

#calculation
P2=P1*(2./(gamm+1))**(gamm/(gamm-1))
print "pressure at nozzle throat (kPa): %.4f"%(P2/1000.)

#part2
temp=273.+50
nu1=R*temp/P1/M
G=18.                      #mass flow rate
nu2=nu1*(P2/P1)**(-1/gamm)
A=G**2*nu2**2*(gamm-1)/(2*gamm*P1*nu1*(1-(P2/P1)**((gamm-1)/gamm)))
d=math.sqrt(4*math.sqrt(A)/math.pi)
print "diameter required at nozzle throat in (cm) : %.4f"%(d*100)
#part3
vel=math.sqrt(2*gamm*P1*nu1/(gamm-1)*(1-(P2/P1)**((gamm-1)/gamm)))
print "sonic velocity at throat in(m/s): %.4f"%vel
pressure at nozzle throat (kPa): 169.7903
diameter required at nozzle throat in (cm) : 18.8847
sonic velocity at throat in(m/s): 324.9787

example 2.5 page no : 41

In [4]:
import math 

# Initialization of Variable
T=273.+15
rho=999.
rhom=13559.         #density of mercury
g=9.81
P2=764.3/1000*rhom*g
R=8.314
M=16.04/1000
d=4.5/1000.
A=math.pi*d**2/4.
G=0.75/1000         #mass flow rate
delP=(1-math.exp(R*T*G**2./2/P2**2/M/A**2))*P2
h=-delP/rho/g
print "height of manometer in (cm) %.4f"%(h*100)
height of manometer in (cm) 16.7941

example 2.6 page no : 44

In [5]:
import math 

# Initialization of Variable
rhol=931.
mu=1.55/10000               #viscosity of water
Vsp=0.6057                  #specific volume
T=273+133.
mug=1.38/100000             #viscosity of steam
P=300*1000.
d=0.075
Gg=0.05                     #mass flow gas phase
Gl=1.5                      #mass flow liquid phase
A=math.pi*d**2./4
rho = 999.
#calculation
rhog=1./Vsp
rhog=round(rhog*1000)/1000.
velg=Gg/A/rhog
velg=round(velg*100)/100.
Reg=rhog*velg*d/mug

#using chart
phig=0.00245                #friction factor gas phase
l=1
delPg=4*phig*velg**2*rhog/d

#consider liquid phase
vell=Gl/A/rho
Rel=rho*vell*d/mu
if Rel>4000 and Reg>4000:
    print "both liquid phase and solid phase in turbulent  motion"
    #from chart

PHIg=5.
delP=PHIg**2.*delPg
print "required pressure drop per unit length in (Pa) : %.4f"%delP
both liquid phase and solid phase in turbulent  motion
required pressure drop per unit length in (Pa) : 253.8050
In [ ]: