import math
#initialisation of variables
h= 2.5 #ft depth of water
a= 45. #degrees side slope
x= 5. #ft
Q= 45. #cuses
v= 2.6 #ft/sec velocity
w= 6.92 #ft
C= 120.
#CALCULATIONS
b= (Q/(v*h))-h
p= b+2*(h+math.sqrt(2))
A= h*w
m= A/p
i= (v/(C*math.sqrt(m)))**2
#RESULTS
print 'Width = %.2f ft'%(b)
print ' Slope = %.6f '%(i)
import math
#initialisation of variables
a= 60. #degrees sides inclined
i= 1./1600
Q= 8.*10**6 #gal/hr discharge
M= 110.
w= 6.24 #lb/ft**3
#CALCULATIOS
d= ((Q*2**(2./3)*math.sqrt(1./i))/(w*3600*math.sqrt(3)*M))**(3./8)
b=6.93 #ft
#RESULTS
print 'Diameter = %.f ft'%(d)
print ' breadth = %.2f ft'%(b)
import math
#initialisation of variables
g= 32.2 #ft/swc**2
Q= 40. #cuses rate
w= 5.5 #ft
h= 9. #in depth
d= 0.75 #ft
V= 3. #ft/sec
#CALCULATIONS
D= ((Q*2)**2/(g*(w*2)**2))**(1./3)
v= Q*d/w
D1= math.sqrt((2*v**2*d/g)+h/64)-(d/2)
dD= D1-d
El= -dD+((v**2*(1-(V/v)**2))/(2*g))
Els= Q*El*62.4/550
#RESULTS
print 'Critical depth = %.2f ft'%(D)
print ' Rise in level = %.f ft'%(D1)
print ' Horse-power lost = %.3f hp'%(Els)
#The answer is a bit different due to rounding off error in textbook
import math
#initialisation of variables
b= 3.5 #ft
H= 2.5 #ft
w= 3. #ft depth
h= 6. #ft wide
g= 32.2 #ft/sec**2
#CALCULATIONS
Q= 3.09*b*H**1.5
v= Q/(w*h)
H1= H+(v**2/(2*g))
Q1= 3.09*b*H1**1.5
hc= (Q1**2/(b**2*g))**(1./3)
h2= 0.5*(math.sqrt(hc**2+8*hc**2)-hc)
dh= h2+b-w
#RESULTS
print "Flow rate = %.1f cusecs"%(Q)
print " Flow rate = %d cusecs"%(Q1)
print ' maximum depth of water downstream = %.3f ft'%(dh)
print ' Shooting flow depth at hump = %.3f ft'%(h2)
import math
#initialisation of variables
m= 60./26
i= 1./2000
h1= 3. #ft depth
h2= 5. #ft depth
m1= 10./3
C= 90. # constant
l= 500. #ft depth
H= 20. #ft broad
H1= 29.62 #ft
g= 32.2 #ft/s**2
#CALCULATIONS
v= 90*math.sqrt(m*i)
v1= v*h1/h2
dh= (i-(v1**2/(C**2*m1)))*l/(1-v1**2/(g*h2))
h3= h2-dh
V= h1*v/h3
#RESULTS
print 'Height of water 1000 ft upstream = %.3f ft'%(h3)
print ' Height of water upstream = %.3f ft'%(h3)
#The answer is a bit different due to rounding off error in textbook
import math
#initialisation of variables
v= 5. #ft/sec
m= 60./26
i= 1./2000
h= 5.5 #ft
m1= 110./31
d= 3. #ft
g= 32.2 #ft/sec**2
#CALCULATIONS
C= v/(math.sqrt(m*i))
v1= v*d/h
r= (i-(v1**2/(C**2*m1)))/(1-(v1**2/(g*h)))
x= 1/r
#RESULTS
print 'Distance upstream = %.f ft'%(round(x,-1))
import math
from numpy import *
from numpy.linalg import *
#initialisation of variables
g= 32.2 #ft/sec**2
Q= 12 #cuses
#CALCULATIONS
hc= (Q/(3*math.sqrt(g)))**(2./3)
vec=roots([1,6,12,8,0,-8.95,-8.95])
H=vec[2]
#RESULTS
print 'Critical depth = %.2f ft'%(hc)
print ' Critical depth = %.2f ft'%(H)
import math
#initialisation of variables
Cd= 0.64 # coefficient
g= 32.2 #ft/sec**2
A= 12.5 #ft**2
H= 24.8 #ft
Q= 3200. #cuses
b= 150. #ft wide
A1= 5.*10**6 # avg surface area
h= 9. #ft
h1= 6. #in
#CALCULATIONS
N= Q/(Cd*A*math.sqrt(2*g*H))
H1= (Q/(3.2*b))**(2./3)
ES= (H1-(h1/12))*A1*h
#RESULTS
print 'number of siphons = %.f '%(N)
print ' Extra Storage = %.2e ft**3'%(ES)