import math
#initialisation of variables
w = 62.4 #lb/ft**3
x = 8. #ft
A = 16. #ft**2
X = 2.5 #ft
X1 = 0.66 #ft
x1 = 3.834 #ft
x2 = 2.182 #ft
#CALCULATIONS
P = w*x*A
y = A/3
P1 = w*x*A*0.5*X1
R = math.sqrt(P1**2+P**2)
m = P1/P
X2 = x1-x2
C = ((2./3)*A)-m*X
Y = m*X2+ C
print P1
#RESULTS
print 'Water pressure on vertical face = %.f lbs'%(round(P,-3))
print ' pressure which acts at the base = %.2f ft'%(y)
print ' Resultant = %.f lbs'%(R)
print ' x coordinate of the resultant = %.3f ft'%(X2)
print ' y coordinate of the resultant = %.3f ft'%(Y)
import math
#initialisation of variables
s = 13.6
h = 12. #in
u = 0.04
k = 1.
d = 6. #in
g = 32.2 #ft/sec**2
w = 62.4 #lbs/ft**3
#CALCULATIONS
h1 = h*(s-1)/12
hf = u*h1
hn = h1-hf
Q = k*math.pi/4*(d/12)**2*8.02*math.sqrt(hn)/(math.sqrt(16-k))
Q = Q*60*w/10 # fro, cusecs to GPM
#RESULTS
print 'discharge through flow = %.f ft G.P.M'%(Q)
# rounding off error
import math
#initialisation of variables
za = 16. #ft
h1 = 2. #ft
h2 = 3. #ft
g = 32.2 #ft/sec**2
#CALCULATIONS
vc = math.sqrt(2*g*(za-h1-h2))
vb = vc*(h1/(2*h1))**2
r = -h1-h2-(vb**2/(2*g))
r1 = r+34
#RESULTS
print 'pressure head at B = %.1f ft lb'%(r1)
import math
#initialisation of variables
g = 32.2 #ft/sec**2
Cd = 0.62
a = 90. #degrees
H1 = 14. #in
H2 = 8. #in
#CALCULATIONS
Q1 = (8./15)*Cd*math.sqrt(2*g)*math.tan(math.radians(a/2))*(H1/12)**(5/2.)
Q2 = (8./15)*Cd*math.sqrt(2*g)*math.tan(math.radians(a/2))*(H2/12)
Q = Q1-Q2
#RESULTS
print 'Discharge through notch = %.2f cuses'%(Q)
import math
#initialisation of variables
g = 32.2 #ft/sec**2
Cd = 0.62
d = 5./4 #in
h = 9. #ft
#CALCULATIONS
T = (2./3)*math.pi*(h)**(3./2)/(Cd*(math.pi/4)*math.sqrt(2*g)*(d/12)**2)
#RESULTS
print 'time required to lower water level = %.f secs'%(T)
# rounding off error
import math
#initialisation of variables
a = 60. #degrees
d = 4. #in
Cd = 0.62
h = 5. #ft
w = 30. #ft
g = 32.2 #ft/sec**2
#CALCULATIONS
H1 = 10*math.sin(math.radians(a))
H2 = H1-h
T = (2*w/math.tan(math.radians(a)))*(2./3)*(H1**(3./2)-H2**(3./2))/(Cd*math.sqrt(2*g)*math.pi/(4*(d/12)**2))*100
#RESULTS
print 'time required to lower water level = %.f secs'%(T)
# answer is accurate.please check manually
import math
#initialisation of variables
p1 = 40. #percent
p2 = 35. #percent
dh = 200. #ft
f = 0.1
g = 32.2 #ft/sec**2
l = 2000. #ft
d = 1. #ft
#CALCULATIONS
hf1 = p1*dh/100
hf2 = p2*dh/100
hf3 = (100-p1-p2)*dh/100
hft = hf1+hf2+hf3
v1 = math.sqrt(2*g*hf1/(4*f*l))
Q = v1*math.pi*d**2/4
d2 = (Q*7*math.sqrt(3/(5*g)))**(2./3)
v3 = Q*4*(4./3)**2/math.pi
l3 = hf2*2*g*(3./4)/(4*f*v3**2)
#RESULTS
print 'proportion of the quantity folwing in the bypass to the whole pass = %d ft'%(l3)
# rounding off error
import math
#initialisation of variables
d = 1. #ft
l = 2000. #ft
f = 0.038
g = 32.2 #/ft/sec**2
Q = 6. #cuses
l1 = 1500. #ft
r = 2.
#CALCULATIONS
v = 4*Q/(d**2*math.pi)
hf = 4*f*l*v**2/(2*g)
v1 = math.sqrt(hf*2*g/(4*f*l1+4*f*(l-l1)*r**2))
v3 = r*v1
Q1 = math.pi*d**2*v3/4
Q2 = math.pi*d**2*v1/4
r1 = Q2/Q1
#RESULTS
print 'proportion of the quantity folwing in the bypass to the whole pass = %.1f '%(r1)
import math
#initialisation of variables
f = 0.01
d = 3. #in
l = 22. #ft
l1 = 20. #ft
w = 20. #ft
h = 5. #ft
h1 = 20. #ft
t = 4. #min
g = 32.2 #ft/sec**2
#CALCULATIONS
h2 = h+h1
h3 = (h-(t*60*math.pi*math.sqrt(2*g/h)/(l1*w*2*64)))**2-4
dh = h2-h3
Q = dh*l1*w
#RESULTS
print 'Quantiy discharged = %.f cuses '%(round(Q,-2))
import math
#initialisation of variables
g = 32.2 #ft/sec**2
sct = 1.6
sl = 0.8
K = 0.98
dh1 = 4. #ft
W = 62.4 #lbs/ft**3
d1 = 8. #in
d2 = 6. #in
#CALCULATIONS
dp = dh1*((sct/sl)-1)
C = math.sqrt(2*g)*math.pi*(d1/24)**2 /math.sqrt((d1**2/d2**2)**2 -1)
Q = C*K*math.sqrt(dh1)
#RESULTS
print 'Discharge passing through the pipe = %.1f cuses '%(Q)
#The answer given in textbook is wrong. Please verify it.