# Difference in pressure at top and bottom
from math import *
from __future__ import division
# Given
d1 = 0.1 # diameter in m
d2 = 0.05 # diameter in m
Q = 0.1 # discharge in m**3/s
A1 = pi*d1**2/4
A2 = pi*d2**2/4
gma =9810 # specific weight
z= 6 # difference in the height
g = 9.81
# Solution
V1 = Q/A1 # velocity at section 1
V2 = Q/A2 # velocity at section 2
dP = gma*((V2**2/(2*g))-(V1**2/(2*g))-z)/1000
print "Difference in pressure in section 1 and 2 = ",round(dP,1),"kN/m**2"
# Actual discharge
from math import *
from __future__ import division
# Given
d = 2.5 # diameter in cm
h =200 # head in cm
Cd = 0.65 # coefficient of discharge
A =pi*d**2/4
g = 9.81 # acceleration due to gravity in m/s**2
# Solution
Q = Cd*A*sqrt(2*g*h)/100
print "Actual discharge =",round(Q,2),"l/s"
# Discharge through the orifice
from __future__ import division
from math import *
from scipy import integrate
import numpy as np
# Given
H1 = 3 # height in m
H2 = 4 # height in m
b = 0.5 # width in m
Cd = 0.65 # co-efficient of discharge
g = 9.81 # acceleration due to grvity in m/s**2
# Solution
q = lambda h: h**(1/2)
Q,err = integrate.quad(q, H1, H2)
Qt = Cd*b*sqrt(2*g)*Q
print "Discharge through the orifice =",round(Qt,2),"m**3/s"
# discharge through orifice
from math import *
from scipy import integrate
from __future__ import division
import numpy as np
# Given
b = 1 # bredth of the tank
d = 0.5 # depth of the tank
h1 = 0.2 # height of the orifice in m
Cd = 0.6 # coefficient of discharge
H1 = 2 # height in m
H2 = 2+h1 # height in m
g = 9.81 # acceleration due to gravity in m/s**2
A = 1*0.3 # area of submerged section in m**2
# Solution
q = lambda h: h**(1/2)
Q,err = integrate.quad(q, H1, H2)
Q1 = Cd*b*sqrt(2*g)*(Q) # Flow through area 1
Q2 = Cd*sqrt(2*g*H2)*A
Td = Q1+Q2
print "Total Discharge =",round(Td,2),"m**3/s"
# Determine flow rate of water
from math import *
from __future__ import division
# Given
d1 = 2 # radius of pipe
d2 = 1 # radius of throat
D1 = 40
D2 = 20
A1 = pi*D1**2/4
A2 = pi*D2**2/4
Cd = 0.95
# Solution
V2 = sqrt(21582/0.9375)
Q = 1.52*pi*(d1/100)**2/4
Qa = Q*Cd
print "Actual discharge =",round(Qa,6),"m**3/s"
# Velocity of stream point at the point of insertion
from math import *
from __future__ import division
# Given
dx = 0.5 # in ft
K = 1 # constant
g = 32.2 # acceleration due to gravity in ft/s**2
# solution
V = sqrt(2*g*dx)
print "velocity at the dept of 1 ft =",round(V,2),"ft/s"
# Discharge throught the system
from math import *
from __future__ import division
gma= 0.8 # specific weight
V2 = 40 # velocity in m/s
z1 =25 # height at point 1
g = 9.81 # acceleration due to gravity in m/s**2
d = 15 # diameter of the nozzle in cm
# Solution
V2 = sqrt(2*g*z1/4.25)
A = pi*(d/100)**2/4
Q = A*V2*1000
print "Discharge throught the system =",round(Q,0),"l/s"
# Power input to the pump
from math import *
from __future__ import division
# Given
Eff = 0.8 # pump efficiency
Hl = 30 # head loss in m
D1 =6 # diameter in cm
D2 = 2 # diameter in cm
gma = 9810 # specific weight in N/m**3
V2 = 40 # velocity in m/s
P1 = -50 # pressure at point 1 in N/m**2
z2 = 100 # height at point 2
g = 9.8 # acceleration due to gravity in m/s**2
z1 = 30 # height in m
# Solution
V1=(2/6)**2*V2
Q = (pi*6**2/4)*V1*10**-4
Hs = z2 + (V2**2/(2*g)) + z1 + (50/gma) -(V1**2/(2*g))
P = gma*Q*Hs
Pi = (P/Eff)/1000
print "Power input = ",round(Pi,1),"kW"
# Pressure head at A and B
from math import *
# Given
Q = 0.2 # discharge in m**3/s
d1 = 0.25 # diameter of the pipe in m
A = pi*d1**2/4 # area of the pipe
za = 480 # height in m
z1 = 500 # height in m
z3 = 550 # elevation in m
gma =9810 # specific weight in N/m**2
g =9.81 # acceleration due to gravity in m/s**2
# Solution
V=Q/A # Velocity of in m/s
Hl1 = (0.02*100*V**2/(0.25*2*9.81))
# pressure head at A
Pa =(z1-za-(V**2/(2*g))-Hl1)
El = za+Pa
print "Elevation at height A =",round(El,2),"m"
# pressure head at B
hs = z3 - z1 + (0.02*(500/0.25)*(V**2/(2*g)))
El2 = El+hs
print "Elevation at height B =",round(El2,2),"m"