import math
#Initialization of variables
P1 = 10. #psia
Q = 0.6 #cfs
A1 = 0.0491 #ft**2
g = 32.2
V = 39.2 #fps
A0 = 0.0218 #ft**2
d1 = 2. #in
d2 = 3. #in
#calculations
Phead = P1*144/62.4
V1 = Q/A1
V2i = math.sqrt(2*g*(Phead + V1**2 /(2*g)))
Cv = V/V2i
A2 = Q/V
Cc = A2/A0
Cd = Cc*Cv
hL = (1/Cv**2 -1)*(1- (d1/d2)**4)*V**2 /(2*g)
#Results
print " Cc = %.2f "%(Cc)
print " Cd = %.2f"%(Cd)
print " Cv = %.2f"%(Cv)
print " Head loss = %.2f ft"%(hL)
import math
#Initialization of variables
d = 2. #in
g = 32.2
d1 = 3. #in
k = 1.06
#calculations
A2 = math.pi/4 *d**2 /144
dp = d/12
Q = k*A2*math.sqrt(2*g*dp)
A = math.pi/4 *(d1/12)**2
V1 = Q/A
K2 = 1.04
Q2 = K2/k *Q
#Results
print "Flow rate = %.4f cfs"%(Q2)
import math
#Initialization of variables
P1 = 700. #kN/m**2
P2 = 400. #kN/m**2
D2 = 12.5 #cm
D1 = 25. #cm
C = 0.985
g = 9.81
R = 287. #m**2/s**2 K
T = 273.+20 #K
#calculations
Pr = P2/P1
Dr = D2/D1
Y = 0.72
gam1 = P1*g/(R*T)
G = C*Y*math.pi/4 *(D2/100)**2 *math.sqrt(2*g*gam1*(P1-P2)/(1- Dr**4))
#Results
print "Weight flow rate = %.4f kN/s"%(G)
import math
#Initialization of variables
V = 3. #fps
y = 1. #ft
L = 4. #ft
#calculations
H = (V*y/3.33)**(2./3)
P = L-H
#Results
print "Height of weir = %.2f ft"%(P)