import math
#Variable Decleration
u_max=6 #Maximum Velocity in m/s
R=0.02 #Radius of the Pipe in m
L=70 #Length of the pipe in m
rho=1252 #Density of glycerin in kg/m^3
u=0.3073 #Viscosity of glycerin in kg/m.s
g=9.81 #Acceleration due to gravity in m/s^2
C=10**-3 #Conversion factor
#Calculations
D=R*2 #Diameter of the pipe in m
V=u_max/2 #Average Velocity in m/s
V_dot=V*(pi*R**2) #Volumertic Flow rate in m^3/s
Re=(rho*V*D)/u #Reynolds Number
f=64/Re #Friction Factor
h_L=(f*L*V**2)/(2*g*D) #Head loss in m
theta=(pi*15)/180 #Angle in radians
#Applying the energy balance equation
#As z2=z1 z2-z1=0 hence we do not consider it in the computation
delta_P=rho*g*(h_L)*C #Pressure difference in kPa
W_dot=V_dot*delta_P #Useful pumping Power in kW
#Inclined Case
delta_z=L*sin(theta) #elevation difference in m
delta_P_up=(rho*g*delta_z*C)+(rho*g*h_L*C) #Pressure difference up in kPa
V_dot_upward=W_dot/delta_P_up #Flow rate through the upward pipe in m^3/s
#Percentage Calculations
per_V=((V_dot-V_dot_upward)/V_dot)*100 #Percentage change in the flow rate
#Result
print "The velocity of the flow is",round(V),"m/s"
print "The pressure difference across 70m long pipe is",round(delta_P),"kPa"
print "The power required to maintain the flow is",round(W_dot,2),"kW"
print "The percentage change in the flow rate is",round(per_V,1),"%"
#Answer for percentage change and flow rate through the pipe upward direction are incorrect
import math
#Variable Decleration
rho=1000 #Density of water in kg/m^3
u=1.519*10**-3 #Viscosity of water in kg/m.s
L=9 #Length of the pipe in m
D=0.003 #Diameter of the pipe in m
V=0.9 #Average velocity inside the pipe of water in m/s
g=9.81 #Acceleration due to gravity in m/s^2
#Calculations
#Part(a)
Re=(rho*V*D)/u #Reynolds Number
f=64/Re #Friction Factor
h_L=(f*L*V**2)/(2*g*D) #Head Loss in m
#Part(b)
delta_P=(f*L*V**2)/(2*D) #Pressure difference in kPa
#Part(c)
V_dot=(V*pi*D**2)/4 #Volumetric Flow rate in m^3/s
W_dot=V_dot*delta_P*1000 #Pumping power required in W
#Result
print "The Head Loss is",round(h_L,2),"m"
print "The pressure drop is",round(delta_P,1),"kPa"
print "The pumping power required is",round(W_dot,2),"W"
import math
#Variable Decleration
rho=999 #Density of water in kg/m^3
u=1.138*10**-3 #Viscosity in kg/m.s
D=0.05 #Diameter of the pipe in m
V_dot= 0.006 #Volumetric Flow rate in m^3/s
L=60 #Length of the pipe in m
e=0.002 #Relative roughness value from table
f=0.0172 #Value from Moody Chart
g=9.81 #Acceleration due to gravity in m/s^2
#Calculations
V=round((V_dot*4)/(pi*D**2),2) #Velocity of the flow in the pipe in m/s
Re=(rho*V*D)/u #Reynolds Number
e_D=e/(D*1000) #Relative roughness
#Taking the value for root f from Moody Chart as f=0.0172
delta_P=(f*L*rho*V**2)/(D*2) #Pressure Drop in N/m^2
h_L=delta_P/(rho*g) #Head Loss in m
W_pump=V_dot*delta_P #Required Power in W
#Result
print "The Pressure Drop is",round(delta_P),"N/m^2"
print "The head loss is",round(h_L,2),"m"
print "The Power required is",round(W_pump),"W"
#The answer for delta_P is off by 4 due to decimal accuracy in the formula
import math
#Variable Decleration
V_dot=0.35 #Volumertic flow rate in m^3/s
L=150 #Length of the pipe in m
rho=1.145 #Density of the fluid in kg/m^3
u=1.895*10**-5 #Dynamic viscosity of the fluid in kg/m.s
v=1.655*10**-5 #Kinematic Viscosity of the fluid in m^2/s
h_l=20 #Allowable head loss in m
g= 9.81 #Acceleration due to gravity in m/s^2
#The following three equations are solved using EES hence we will be taking the values directly here
D=0.267 #Diameter of the pipe in m
f=0.0180
V=6.24 #Velocity of low in m/s
Re=100800 #Reynolds Number
#Calculations
#Simplfying the calculations
c=V_dot**9.4
d=L/(g*h_l)
f=d**5.2
#Using Swamee-Jain Formula
D=0.66*((v*c*f)**0.04) #Diameter of the pipe in m
#Result
print "The diameter of the pipe is",round(D,3),"m"
import math
#Variable Deceleration
#Using the computationally simple method given in the discussion
g=9.81 #Acceleration due to gravity in m/s^2
D=0.267 #Diameter in m
h_l=20 #Head loss in m
L=300 #Length of the pipe in m
v=1.655*10**-5 #Kinematic Voscosity in m^2/s
V_dot_old=0.35 #Volumetric Flow rate in m^3/s
#Calculations
a=((3.17*v**2*L)/(g*D**3*h_l))**0.5
b=log(a)
c=((g*D**5*h_l)/L)**0.5
V_dot_new=-0.965*b*c #Volumetric Flow rate in m^3/s
V_dot=V_dot_old-V_dot_new #Drop in the flow rate in m^/s
print "The drop in the flow rate is",round(V_dot,2),"m^3/s"
import math
#Variable Decleration
D1=0.06 #Diameter of the pipe at section 1 in m
D2=0.09 #Diameter of the pipe at section 2 in m
V1=7 #Average Velocity at section 1 in m/s
K_l=0.133 # interpolating from table
g=9.81 #Acceleration due to gravity in m/s^2
P1=150 #Pressure head at section one in kPa
rho=1000 #Density of the fluid in kg/m^3
alpha1=1.06 #momentum correction factor
alpha2=alpha1 #momentum correction factor
C=10**-3 #Conversion factor
#Calculations
#Applying the one dimensional continuity equation
V2=(D1**2/D2**2)*V1 #Velocity of the fluid at section 2 in m/s
#Irreversible head loss
h_l=K_l*(V1**2/(2*g)) #Irreversible head loss in m
#Using the energy equation
P2=P1+rho*(((alpha1*V1**2-alpha2*V2**2)*0.5)-g*h_l)*C #Pressure head at section 2 in kPa
#Result
print "The head loss is",round(h_l,4),"m"
print "The pressure head at section two is",round(P2),"kPa"
#The answer differs due to decimal point accuracy
import math
#Variable decleration
rho=999.7 #Density of the fluid in kg/m^3
u=1.307*10**-3 # Dynamic Viscosity in kg/m.s
e=0.00026 #Roughness of cast iron in m
V_dot=0.006 #Volumetric Flow rate in m^3/s
z2=4 #static head at section 2 in m
D=0.05 #Diameter of the pipe in m
#Kl declerations
Kl_entrance=0.5
Kl_elbow=0.3
Kl_valve=0.2
Kl_exit=1.06
f=0.0315 #Using Moody Chart and Colebrook Equation friction factor
L=89 #Length of the pipe in m
g=9.81 #Acceleration due to gravity in m/s^2
#Calculations
V=(V_dot*4)/(pi*D**2) #Average Velocity in the pipe in m/s
Re=(rho*V*D)/u #Reynolds Number
e_D=e/D
sum_Kl=Kl_entrance+2*Kl_elbow+Kl_valve+Kl_exit #Summation of all Kl
#Total Head Loss
h_l=(((f*L)/D)+sum_Kl)*(V**2/(2*g)) #Total head loss in m
#Using Energy equation
z1=z2+h_l #Free surface of the first reservoir in m
#Result
print "The elevation of the free surface of the first reservoir is",round(z1,1),"m"
import math
#Variable Decleration
rho_met=788.4 #Density of the fluid in kg/m^3
u=5.857*10**-4 #Dynamic Viscosity in kg/m.s
rho_hg=13600 #Density of mercury in kg/m^3
d=0.03 #diameter of the orifice meter in m
D=0.04 #Diameter of the pipe in m
h=0.11 #differential height of the manometer in m
g=9.81 #Acceleration due to gravity in m/s^2
Cd=0.61 #Coefficient of discharge
#Calculations
beta=d/D #Diameter ratio
Ao=(pi*d**2)/4 #Area of throat in m^2
#Pressure Drop
delta_P=(rho_hg-rho_met)*g*h #Pressure drop in m
#Flow rate
V_dot=Ao*Cd*(((2*delta_P)/(rho_met*(1-beta**4)))**0.5) #Volumetric Flow rate in m^3/s
V=(V_dot*4)/(pi*D**2) #Average Velocity in m/s
#Reynolds Number
Re=(rho_met*V*D)/u #Reynolds Number
#Coefficient of Discharge
Cd_calculations=0.5959+0.0312*beta**2.1-0.184*beta**8+((91.71*beta**2.50)/Re**0.75)
#Result
print "The flow rate of methanol in the pipe is",round(V_dot,5),"m^3/s"
print "The average velocity of low in the pipe is",round(V,2),"m/s"