import math
#Initialization of variables
s = 0.85
v = 1.8*10**-5 #m**2 /s
d = 10. #cm
flow = 0.5 #L/s
#calculations
Q = flow*10**3
A = math.pi*d**2 /4
V = Q/A
V = V/10**2
R = d*10**-2 *V/v
#Results
print "reynolds number = %.f. Hence the flow is laminar"%(R)
#Initialization of variables
Vc = 12.7 #cm/s
r = 2. #cm
r2 = 5. #cm
R = 354.
rho = 0.85
V = 6.37 #cm/s
D = 0.1 #m
#calculations
k = Vc/r2**2
f = 64/R
T0 = f/4 *rho*V**2 /2
T02 = T0/10
hr = f*(V*10**-2)**2 /(2*9.81*D)
#Results
print "Friction factor = %.2f"%(f)
print " Shear stress at the pipe wall = %.3f N/m**2"%(T02)
print " Head loss per pipe length = %.5f m/m"%(hr)
import math
#Initialization of variables
Q = 2.
A = 0.196 #cm**2
D = 0.5 #ft
rho = 0.9*1.94
mu = 0.0008 #viscosity - lb s/ft**2
hl = 25.
g = 32.2 #ft/sec**2
L = 200. #ft
r = 2. #in
#calculations
V = Q/A
R = D*V*rho/mu
f = hl*D*2*g/(L*V**2)
umax = V*(1+1.33*math.sqrt(f))
T0 = f*rho*V**2 /8
u2 = umax - 5.75* math.sqrt(T0/rho) *math.log10(D*12/r)
#Results
print "Center line velocity = %.1f fps"%(umax)
print " Shear stress = %.2f lb/ft**2"%(T0)
print " Velcoity at 2 in from center line = %.2f fps"%(u2)
import math
#Initialization of variables
f = 0.0131
d = 0.5 #m
#calculations
V = 2.12 #m/s
R = 10**6
Q = math.pi*d**2 /4 *V
d1 = 32.8*10**-6 /(V* math.sqrt(f))
#Results
print "flow rate = %.3f m**3/s"%(Q)
print " nominal thickness = %.3e m"%(d1)
# note : rounding off error
import math
#Initialization of variables
dz = 260. #ft
ke = 0.5
f = 0.02
l = 5000. #length of pipe - ft
D = 10. #in
A2 = 0.545
#calculations
V2by2g = dz/(1 + ke + f*l/(D/12))
V2 = V2by2g*2*32.2
V = math.sqrt(V2)
DV = D*V
Q = math.pi/4 *(D/12)**2 *V
#Results
print "Flow rate = %.2f cfs"%(Q)
import math
#Initialization of variables
z = 260. #ft
f = 0.02
#calculations
V2by2g = z/(1.11*256 + 6000*f)
V2 = V2by2g*2*32.2
V = math.sqrt(V2)
Q = 0.545*V
V3 = 16*V
H = z-f*6000*V2by2g
V3 = 16*V
#Results
print "rate of discharge = %.2f cfs"%(Q)
print "V3 = %.1f fps"%V3
# rounding off error
import math
#Initialization of variables
g = 52.
Hp = 2.
#calculations
Q = 3.48 #cfs
V6 = 3.48/0.196
P = -20.9 #ft
P2 = P*(g/144)
#Results
print "Flow rate = %.2f cfs"%(Q)
print " Pressure in the pipe = %.2f psi"%(P2)
import math
#Initialization of variables
h = 10. #m
g = 9.81 #m/s**2
f1 = 0.019
f2 = 0.021
f3 = 0.020
z1 = 300. #m
z2 = 150. #m
z3 = 250. #m
d1 = 0.3 #m
d2 = 0.2 #m
d3 = 0.25 #m
#calculations
print ("part(a)")
Vbyg = h/(f1*z1/d1 +f2*z2/d2 *(d1/d2)**4 + f3*z3/d3 *(d1/d3)**4)
V1 = math.sqrt(2*g*Vbyg)
Q = math.pi/4 *d1**2 *V1
print " Flow rate = %.3f m**3/s"%(Q)
print ('Part(b)')
Le2 = z2*f2/f1 *(d1/d2)**5
Le3 = z3*f3/f1 *(d1/d3)**5
Le1 = z1
Le = Le1+Le2+Le3
V1byg = h*d1/Le/f1
V2 = math.sqrt(2*g*V1byg)
Q1 = math.pi/4 *d1**2 *V2
print " Flow rate = %.3f m**3/s"%(Q1)
import math
#Initialization of variables
d1 = 6./12 #ft
d2 = 4./12 #ft
d3 = 8./12 #ft
l1 = 2000. #ft
l2 = 1600. #ft
l3 = 4000. #ft
f1 = 0.020
f2 = 0.032
f3 = 0.024
El1 = 200.
El2 = 50.
El3 = 120.
g = 32.2
#calculations
Vc = math.sqrt(2*g*(El1-El2)/288.9)
Qc = math.pi/4 *d3**2 *Vc
Va = 1.346*Vc
Qa = math.pi/4 *d1**2 *Va
Vb = (d3**2 *Vc - d1**2 *Va)/d2**2
Qb = math.pi/4 *d2**2 *Vb
P = 62.4/144 *(El1 - El3 - f1*l1/d1 *Va**2 /(2*g))
#Results
print "Flowrate at A = %.3f cfs"%(Qa)
print "Flowrate at B = %.3f cfs"%(Qb)
print "Flowrate at C = %.3f cfs"%(Qc)
print "Pressure at P = %.2f psi"%(P)