import math
#initialisation of variables
g= 32.2 #ft/sec**2 gravitational acceleration
h= 4. #ft diameter
d2= 0.16 #ft
d1= 0.3 #ft
dp= 13.6 #lbf/in**2 mercury
#CALCULATIONS
Q= (math.pi/4)*math.sqrt(2*g*dp*h/((1/d2**4)-(1/d1**4)))
#RESULTS
print 'Volumetric flow rate = %.2f ft**3/sec'%(Q)
# note: book answer is not accurate.
#initialisation of variables
w= 0.0765 #lbm/ft**3 density
v1= 120. #ft/sec velocity
go = 62.4 #lmb/ft**3
#CALCULATIONS
dp= (w*v1**2)/(2*go)
#RESULTS
print 'Difference in pressure= %.2f lbf/ft**2'%(dp)
import math
#initialisation of variables
r=1.4
g= 32.2 #ft/sec**2 gas
R= 53.3 #lbf ft/lbm
T1= 760. #R Temperature
p2= 2. #lbf/in**2
p1= 3. #lbf/in**2
#CALCULATIONS
V2= math.sqrt(2*r*R*g*T1*(1-(p2/p1)**((r-1)/r))/(r-1))
#RESULTS
print 'Velocity in working section = %.f ft/sec'%(V2)
import math
#initialisation of variables
y = 1.4
g = 32.2 #ft/sec**2
R = 53.3 #lbf ft/lbm
T = 32. #C air
T1 = 2000. #R air
y1 = 1.32
p = 1440. #lbf/in**2
v1 = 1.2306 #ft**3/lbm
v2 = 1.2546 #ft**3/lbm
bm = 3.13*10**5 #lbf/in**2
w = 62.4 #lbf/ft**3
#CALCULATIONS
a1= math.sqrt(y*R*(460+T)*g)
a2= math.sqrt(y1*R*T1*g)
r2= p/(v1-v2)
a3= math.sqrt(-g*(v1+v2)**2*0.5**2*r2)
a4= math.sqrt(bm*144*g/w)
#RESULTS
print ' Acoustic veloctiy in air at 32 F = %.f ft/sec'%(a1)
print ' Acoustic veloctiy in air at 2000 R = %.f ft/sec'%(a2)
print ' Acoustic veloctiy in steam at 480 F = %.f ft/sec'%(a3)
print ' Acoustic veloctiy in water at 60 F = %.f ft/sec'%(a4)
#initialisation of variables
r= 1.4
ma2= 2.5 #ft/sec
g= 32.17 #ft/sec**2
p2= 1. #lbf/in**2
ps= 17.08 #lbf/in**2
ps2= 75. #lbf/in**2
Ts= 720. #R
R= 53.3 #lbf ft/lbm gas
A= 4. #ft**2 flow area
ps3= 0.4 #lbf/in**2
A2= 0.685 #ft**2
P= 5. #per cent throat area
#CALCULATIONS
R1= (1+0.5*(r-1)*ma2**2)**(r/(r-1))
R2= (2*(r/(r-1))*(p2/ps)**(2/(r))*(1-(p2/ps)**((r-1)/r)))**0.5
m2= R2*ps2*144*(g/(R*Ts))**0.5*0.1
m= m2*A
At= A*R2/A2
m1= m*(1-(P/100))
mrp= (1-(P/100))*R2
#RESULTS
print ' Mass flow rate= %.1f lbm/sec'%(m)
print ' Area of throat= %.3f ft**2'%(At)
print ' Mass flow rate= %.1f lbm/sec'%(m1)
print ' Mass flow rate parameter = %.4f'%(mrp)
#initialisation of variables
r1= 10. #ft point - 1
r2= 0.2 #miles point - 2
w= 0.0765 #lbm/ft**2 density
g= 32.2 #ft/sec**2
V1= 1. #ft/sec velocity
#CALCULATIONS
k= r2*5280*V1
dp= w*k**2*10*((1/r1)**2-(1/(5280*r2))**2)/(2*g)
#RESULTS
print 'k = %.f ft**2/sec'%(k)
print ' pressure difference = %.1f lbf/ft**2'%(dp)
#initialisation of variables
w= 12. #ft wide
q= 300. #ft**3/sec rate
h= 10. #ft depth upstream of the gate
g= 32.2 #ft/sec**2
R= 2.6
#CALCULATIONS
hc= ((q/12)**2/g)**(1./3)
r= h/hc
h1= hc*(((h/hc)+0.5*(hc/h)**2)-0.5*R**2)
#RESULTS
print ' hc = %.2f ft'%(hc)
print ' stream depth = %.3f ft'%(h1)
#rounding-off error
#initialisation of variables
Q= 400. #ft**3/sec flow rate
b1= 25. #ft channel width
b2= 20. #ft channel width
h1= 6. #ft stream depth
z1= 2.5 #ft elevation of channel bottom
z2= 3.3 #ft elevation of channel bottom
g= 32.2 #ft/sec**2
#CALCULATIONS
hc1= (Q**2/(g*b1**2))**(1./3)
hc2= (Q**2/(g*b2**2))**(1./3)
r= (hc1/hc2)*((h1/hc1)+0.5*(hc1/h1)**2)+((z1-z2)/hc2)
#RESULTS
print ' hc1 = %.3f ft'%(hc1)
print ' hc2 = %.3f ft'%(hc2)
print ' Ratio = %.3f '%(r)