import math
# variables
d = 4.; #feet
theta = 30.; # degrees
p_C = 5. # psi
# calculations
p_A = p_C-(62.4/144)*math.cos(theta*math.pi/180) *2;
p_B = p_C+(62.4/144)*math.cos(theta*math.pi/180) *2;
h = p_C*144/62.4;
# results
print 'The static pressures at A and B are %.2f psi and %.2f psi respectively.'%(p_A,p_B);
print 'The hydraulic grade line is %.2f ft vertically above C'%(h);
import math
# variables
h = 100.; #ft
d1 = 5.; #in
d2 = 8.; #in
h1 = 60.; # ft
h2 = 10.; #ft
h3 = 40.; #ft
h4 = 102.; #ft
H = 300.; #ft
theta = 30.; #degrees
gam = 0.43;
# calculations
V5 = math.sqrt(h*2*32.2);
Q = V5*0.25*math.pi*(d1/12)**2;
V1 = (d1/12)**4 *h;
V2 = h*(d1/d2)**4;
p1 = (h1-V1)*gam;
p2 = -(h2-V2)*2.04*gam;
p3 = (h3-V1)*gam;
p4 = (h4-V1)*gam;
V6 = V5*math.cos(theta*math.pi/180);
e = H - (V6**2)/(2*32.2);
# results
print 'p1 = %.1f psi, p2 = %.1f in. of Hg vacuum, p3 = %.f psi and p4 = %.1f psi'%(p1,p2,p3,p4);
print 'elevation = %.1f ft'%(e);
import math
# variables
p = 14.; #psia
gam = 62.; #lb/cuft
l1 = 35.; # ft
l2 = 10.; # ft
d = 6.; #in
# calculations
p_v = 2.2*gam;
p_B = p*144;
k_c = l1-l2+(p_B/gam)-(p_v/gam);
K6 = l1;
d_c = d*(K6/k_c)**0.25;
# results
print 'd = %.2f in'%(d_c);
import math
# variables
rho = 0.00238; #slug/cuft
h = 6. #in
# calculations
V_0 = math.sqrt(2*(h/12)*(62.4 - rho*32.2)/rho);
# results
print 'The velocity of the air stream = %.f fps'%(V_0);
import math
# variables
sg = 0.82;
p1 = 20.; #psia
p2 = 10.; #psia
d1 = 6.; #in
d2 = 12.; #in
del_z = 4.; #ft
d = 18.7; #in
# calculations
h1 = (p1-p2)*144/(sg*62.4) - del_z;
A1 = 0.25*math.pi*(d1/12)**2;
A2 = 0.25*math.pi*(d2/12)**2;
V2 = math.sqrt(-2*h1*32.2/(1-(A2/A1)**2));
V1 = (A2/A1)*V2;
Q = A1*V1;
# results
print 'Flow rate = %.2f cfs'%(Q);
#there is a small error in the answer given in textbook
import math
# variables
e1 = 100.; #ft
theta = 60.; #degrees
e2 = 98.5; #ft
V_s2 = 20.; #fps
e3 = 95.; #ft
# calculations
t2 = (e1-e2)/math.cos(theta*math.pi/180);
p2 = 3*62.4*math.cos(theta*math.pi/180);
V_F2 = math.sqrt((e1 + (V_s2**2 /(2*32.2)) - p2/62.4 -e2)*2*32.2);
q = 3*1*V_s2;
y = 11.22; #ft
y1 = 10.74; #ft
V1 = math.sqrt((y-y1)*2*32.2);
# results
print 'On spillway: Pressure = %.1f psf , velocity = %d fps' %(p2,V_F2);
print 'In the approach channel: Depth = %.2f ft, V1 = %.1f fps'%(y1,V1);
import math
# variables
d = 10.; # in
p = 40.; #psi
G = 5.; #cfs
y1 = 92.4; #ft
k1 = -11.3; #ft
k2 = 92.4; #ft
k3 = 3.2; #ft
k4 = 10.1; #ft
# calculations
E_p = k4+y1+d-k1-k3;
hp = G*62.4*E_p/550;
# results
print 'Pump horsepower = %.1f hp'%(hp);
import math
# variables
sw = 20.; # specific weight in lb/cuft
p_B = 6.; #psi
p_A = 2.; #psi
L = 17.28; #ft
l = 10.; #ft
# calculations
V_A = math.sqrt(2*32.2*((p_B-p_A)*144/50 - l));
# results
print 'The mean velocity = %.2f fps'%(V_A);
import math
# variables
D = 6.; #in
v = 100.; #fps
p = 0.; #psi
gam = 0.08; #specific weight in lb/cuft
R = 6.; #in
theta = 60.; #degrees
# calculations
v_r = v*(1-(0.5*D/R)**2)*math.cos(theta*math.pi/180);
v_t = -v*(1+(0.5*D/R)**2)*math.sin(theta*math.pi/180);
V = math.sqrt(v_r**2 + v_t**2);
p = ((v**2 /(2*32.2)) - (V**2 /(2*32.2)) - (math.cos(theta*math.pi/180)*math.sin(theta*math.pi/180)))*gam;
# results
print 'Velocity = %.1f fps Pressure = %.2f psf'%(V,p);
import math
from scipy.integrate import quad
# variables
p_A = 0;
p_B = 0;
p_C = 0;
p_D = 0;
#velocity heads
V1 = 15.28; #fps
V2 = 16.78; #fps
V3 = 15.50; #fps
V4 = 16.50; #fps
# calculations
def f0(h):
return h**(1./2)
q = math.sqrt(2*32.2)* quad(f0,3.771,4.229)[0]
# results
print 'V_A = %.2f fps, V_B = %.2f fps, V_C = %.2f fps, V_D = %.2f fps'%(V1,V2,V3,V4);
print 'Flow rate = %.2f cfs/ft'%(q);