Chapter 5 - Fluid viscosity and flow of real fluids

Example 3 - Pg 187

In [1]:
#calculate the viscosity of oil
#Initialization of variables
import math
m=1155. #lb
gam=62.4
spg=0.93
t=3*60. #sec
d=1./6. #in
L=20. #ft
dp=2.5 #psi
#calculations
Q=m/(t*spg*gam)
A=math.pi/4. *d*d
V=Q/A
mu=dp*d*d *144./(32.*V*L)
#results
print '%s %.4f %s' %("Viscosity of oil =",mu,"lb-sec/ft^2")
Viscosity of oil = 0.0031 lb-sec/ft^2

Example 4 - Pg 187

In [2]:
#calculate the values of alpha and beta
#Initialization of variables
import math
import scipy
from scipy import integrate
g=32.2
gam=62.4
r0=1.
#calculations
def func1(r):
    al=8./math.pow(r0,8) *math.pow((r0*r0-r*r),3) *(2*r)
    return al
alpha,err=scipy.integrate.quad(func1,0,r0)
def  func2(r):
    a2=4/math.pow(r0,6) *math.pow((r0*r0 -r*r),2) *(2*r)
    return a2
bet,err2=scipy.integrate.quad(func2,0,r0)
#results
print '%s %d' %("Alpha = ",alpha)
print '%s %.2f' %("\n beta = ",bet)
Alpha =  2

 beta =  1.33

Example 5a - Pg 188

In [3]:
#calculate the direction of flow and the loss of energy
#Initialization of variables
spg=0.93
mu=3.1e-3 #lb-sec/ft^2
gam=62.4
z=50. #m
p1=60. #psia
p2=25. #psia
#calculations
p1g=144.*p1
p2g=144.*p2 + spg*gam*z
dp=p1g-p2g
#results
if p1g>p2g:
    print '%s' %("The flow is in upward direction")
else:
    print '%s' %("The flow is in downward direction")

print '%s %d %s' %("\n Energy loss=",dp,"ft-lb/ft^3")
The flow is in upward direction

 Energy loss= 2138 ft-lb/ft^3

Example 5b - Pg 189

In [4]:
#calculate the flow rate
#Initialization of variables
import math
hl=2140. #ft-lb/ft^3
spg=0.93
mu=3.1e-3 #lb-sec/ft^2
gam=62.4
z=50. #m
p1=60. #psia
p2=25. #psia
d=1. #in
#calculations
V= hl*(d/12.)*(d/12.) /(32*mu*z)
Q=V*math.pi/4. *(d/12.)*(d/12.)
Q2=Q*7.48*60.
#results
print '%s %.2f %s' %("Flow rate =",Q2,"gal/min")
Flow rate = 7.33 gal/min

Example 7 - Pg 194

In [1]:
#calculate the flow in model
#Initialization of variables
muw=2.04e-5 #lb-sec/ft^2
rhow=1.94 #slugs/ft^3
mua=3.74e-7 #lb-sec/ft^2
rhoa=0.00237 #slug/ft^3
Qw=200. #gal/min
Lr=5.
#calculations
Qa=Qw*Lr *(rhow/rhoa)*(mua/muw)
#results
print '%s %d %s' %("Flow in model =",Qa,"gal/min")
print '%s' %("The answers are a bit different from textbook due to rounding off error")
Flow in model = 15007 gal/min
The answers are a bit different from textbook due to rounding off error