# Determine maximum velocity and shear stress
# Given
from math import *
P1 = 200 # Pressure at inlet in kPa
P2 = 260 # Pressure at outlet in kPa
d = 0.004 # diameter in m
L = 8 # length of pipe in meters
z = 6 # height of the pipe from the ground
g = 9.81 # acceleration due to gravity in m/s**2
# properties of kerosene
mu = 19.1*10**-4 # viscosity of kerosene at 20 deg C
S = 0.81 # specific gravity of kerosene
rho = 1000 # density in kg/m**3
# Solution
# calculating direction of flow
p1 = (P1+g*z*S)*1000 # point 1
p2 = (P2)*1000 # point 2
# direction of flow is from point 1-2
# shear stress
Sp = -((p1-p2)/sqrt(L**2+z**2))
r = d/2
Tau_max = r*Sp/2
print "(a) Maximum shear stress =",round(Tau_max,3),"N/m**2"
# maximum velocity
Vmax = r**2*Sp/(4*mu)
print "(b) Maximum velocity =",round(Vmax,3),"m/s"
# discharge
Q = pi*r**4*Sp/(8*mu)
print "(c) Discharge = ",round(Q,7),"m**3/s"
# calculate reynolds number
V = Vmax/2
R = rho*V*d*S/mu
print "Reynolds number =",round(R,0),"is less than 2000, the flow is laminar and the calculations are valid"
# Determine the head loss
# Given
d = 0.02 # diameter of the pipe in m
l = 30 # length of the pipe in m
v = 0.1 # velocity in m/s
g = 9.81 # acceleration due to gravity in m/s**2
# for water at 5 deg C
nu = 1.54*10**-6 # kinematic viscosity of water in m**2/s
# Solution
R = v*d/nu
print "R = ",round(R,0),"is lesss than 2000 , the flow is laminar"
f = 64/R # friction factor
Hf = f*l*v**2/(2*g*d) # head loss due to friction
H=Hf*100
print "Head loss = ",round(H,2),"cm of water"
# Horsepower required to pump 50 tons of oil
# Given
from math import *
# oil properties
S = 0.92 # specific gravity
gma = S*62.4 # density in lbs/ft**3
nu=0.0205 # viscosity in ft**2/s
W = 50 # weight of oil
d = 9 # diameter of the pipe in inches
g = 32.2 # acceleration due to gravity in ft/s**2
# Solution
Q = W*2000/(gma*3600) # discharge in ft**3/s
A = pi*d**2/(4*144) # area of pipe
V = Q*1000/(A) # velocity in ft/s
R = V*0.75/(nu*1000) # Reynolds number
print "R =",round(R,2),"is less than 2000 and hence flow is laminar"
f = 64/R # friction factor
Hf = (f*5280*(V/1000)**2)/(2*g*0.75)
Hp = gma*Q*Hf/(550)
print "Horse power required to pump the oil = ",round(Hp,1)
# Viscosity of the liquid in poise
# Given
from math import *
V = 50 # Volume in m**3
d = 5 # diameter in m
d1 = 0.1 # diameter of bore
l = 10 # length of the tube
t = 20*60 # time in seconds
rho = 0.88 # density in g/cm**3
H1 = 5 # height from the base in m
A = pi*d**2/4
a = pi*d1**2/4
# Solution
# From derivation we obtain a equation for T
H2 = H1-(V/A)
mu = t*rho*a*(0.1)*98.1/(32*A*10*log(H1/H2))
print "Viscosity of the liquid =",round(mu,4),"poise"
# Velocity distribution; Discharge ; shear on the upper plate
# Given
from math import *
# properties of kerosene oil at 20 deg C
S = 0.81 # specific gravity of oil
mu = 4*10**-5 # viscosity of oil in lb.s/ft**2
gma = 62.4*S # density in lbs/ft**3
p1 = 6.51 # pressure at point 1 in psia
p2 = 8 # pressure at point 2 in psia
h = 0.006 # distance between the plate in ft
l = 4 # length of the plate in ft
theta = pi/6 # angle of inclination
# Solution
# point 1
P1 = p1*144 + gma*l*sin(theta)
# point 2
P2 = p2*144
# flow is taking from poont 2-1
Sp = (P2-P1)/4
# equation for u = 2154.75*y-359125*y**2
y = h
# discharge per ft width
q = (2154.75*y**2/2) - (359125*y**3/3)
print "Discharge q = ",round(q,3),"per unit ft of the plate"
# to find shear at the top of the plate take du/dy = 0
dV = 2154.75 - 718250*h
# shear stress
T = -mu*dV
print "Shear stress on the plate = ",round(T,3),"lbs/ft**2 and resisting the motion of the plate"