In [1]:

```
from __future__ import division
print "\n Example 18.1 page no 225\n\n"
#there is a sudden expansion in which the diameter D1 doubls to D2,D2=2D1
#if D1=1 then D2=2
D1=1.0#diameter D1
D2=2#diameter D2
K_se=(1-(D1/D2)**2)**2# coefficent of sudden expansion
print "\n K_se coeff. of sudden expansion=%0.2f "%(K_se)#
```

In [2]:

```
from __future__ import division
print "\n Example 18.2 page no 227\n\n"
#cal. equivalent length of pipe that would cause the same head los for gate and globe valve located in piping
D=3#diameter of pipe,in
L_gate=7#L/D ratio for fully open gate valve
L_globe=300#L/D ratio for globe valve
L_eq_gate=L_gate*D#equivalent length for gate valve
print "\n L_eq_gate=%0.2f in"%(L_eq_gate)#
L_eq_globe=L_globe*D#equivalent length for globe valve
print "\n L_eq_globe=%0.2f in "%(L_eq_globe)#
```

In [3]:

```
from __future__ import division
print "\n Example 18.3 page no 227\n\n"
# water is flowing at room temperature
rho=62.4#density of water,lb/ft**3
meu=6.72e-4#viscosity of water,lb/ft.s
D=0.03125#diameter of pipe
v=10#velocity
R_e=D*v*rho/meu#reynolds no.
print "\n reynolds no R_e=%0.2f "%(R_e)#
f=0.0015+0.125/R_e**.30#equation for friction factor
print "\n friction factor f=%0.2f "%(f)#
L=30#length of pipe
gc=32.2#gravitational constant
P_drop=2*f*rho*v**2*L/(D*gc)#pressure drop
print "\n pressure drop P_drop=%0.2f lbf/ft**2 "%(P_drop)#
```

In [4]:

```
from __future__ import division
print "\n Example 18.4 pageno 229\n\n"
#refer to example 18.3
#applying eq 18.4 for friction loss by globe valve
K_f=22#coeff of expansion loss
v=10#velocity
gc=32.2#ravitational constant
h_f=K_f*v**2/(2*gc)#friction loss due to globe valve
print "\n friction loss due to globe valve h_f=%0.2f ft.lbf/lb"%(h_f)#
```

In [5]:

```
from __future__ import division
print " Example 18.5 page no. 230\n\n"
#refer to example no. 18.3 and 18.4
P_drop=34.16#pressure drop ,ft
h_f=43#friction loss due to fitting
rho=62.4#density,lb/ft**3
P_d_t=(P_drop+h_f)*rho#total pressure drop
print "\n total pressure drop P_d_t=%0.2f lbf/ft**2"%(P_d_t)#
```

In [6]:

```
from __future__ import division
from math import sqrt, pi
print "Example 18.6 page no 230\n\n"
k=0.00085#relative roughness of pipe ,ft
D=0.833#diameter of pipe,ft
f=0.005#we assume fanning friction factor ,0.004-0.005,select upper limit
K=0.45#entrance loss coefficient is estimated from eq. 18.10 and 18.11
L=5000#length of pipe,ft
h_f=4*f*(L/D)#the friction head loss in terms of the line velocity
print "\n h_f=%0.2f "%(h_f)##printing mistake in book 12 instead of 120
#applying bernoulli equation between points 1 and 2 to calculate v2
h_s=0#no shaft head
v1=0#large tank
#because both locations open to the atmosphere,P1=P2=0 psig
h=260#height from point 1 to 2
V2_h=sqrt(h/(1+h_f+K))#total velocity head at point 2
g=32.174
V2=V2_h*2*g
V2=11.75
neu=1.0825e-5#viscosity
R_e=D*(V2)/neu#reynolds number
print "\n reynolds number R_e=%0.2f "%(R_e)##printing mistake in book due to value of h_f
q=V2*(pi*(D**2)/4)#volumatric flow rate
print "\n vol. flow rate q=%0.2f ft**3/s"%(q)##printing mistake in book due to value of h_f
```

In [7]:

```
from __future__ import division
from math import sqrt, pi
print "Example 18.7 page no 232\n\n"
#two large water reservoirs are connected by a pipe
D=0.0779#diameter of pipe (m), by appendix A.5 for 3 inch schdule 40 pipe
k=0.046*1e-3#roughness of pipe
K_r=k/D#relative roughness
print "\n relative roughness K_r=%0.2f "%(K_r)#
q=0.0126#flow rate of water m**3/s,
S=(pi/4)*D**2#cross sectional area of pipe
v=q/S#flow velocity of water
print "\n flow velocity v=%0.2f m/s"%(v)#
neu=1e-6#viscosity of water
R_e=v*D/neu#reynolds no
print "\n reynolds no R_e=%0.2f "%(R_e)#
#from R_e and relative roughness K_r ,obtain friction factor
f=0.00345
L=2000*.3048#length of pipe,m
h_f=4*f*(L/D)*(v**2/2)
print "\n head loss h_f=%0.2f J/kg"%(h_f)#
#apply bernoulli equation between station 1 and 2. Note that P1=P2=1 atm,v1=v2,z1=z2
#P_drop/rho + V**2/2g + z = h_s - h_f
#whera h_s is the major friction loss
#above equation reduces to h_s=h_f
h_s=h_f#h_s is major friction loss
print "\n major friction losses h_s=%0.2f J/kg"%(h_s)#
```

In [8]:

```
from __future__ import division
print "\n Example 18.8 page no 233\n\n"
#refer to example no 18.7
rho=1000#density
g=9.807#gravitational acc.
h_f=38.39#head loss
P_rise=rho*g*h_f#pressure rise across the pump
P_rise=475000#in book by mistake this value instead original value
q=0.0126#flow rate from example 18.7
W_dot=q*P_rise#ideal pumping requirement(the fluid power)
print "\n W_dot fluid power=%0.2f kw"%(W_dot)##printing mistake in book in putting value of P_rise
```