import math
from sympy.functions.elementary.trigonometric import acot
#Initialization of variables
ns = 20.
eta = 0.925
etah = 0.94
BD = 0.1
phie = 0.72
g = 32.2
alpha2 = 90. #degrees
#calculations
Cr = ns**2 /(67100*phie**2 *BD*eta)
c1cos = etah/(2*phie)
alpha = math.degrees(math.atan(Cr/c1cos))
C1 = Cr/math.sin(alpha)
#beta1 = 1/math.tan(math.radians((C1*math.cos(alpha) -phie)/(C1*math.sin(alpha))))
cotb1 = (0.653 - phie)/0.1243
beta1 = math.degrees(1./math.atan(cotb1))
#Results
print "Alpha = %.2f degrees"%(alpha)
print " Beta = %.2f degrees"%(beta1)
print ("part b")
h = 402.
n = 600. #rpm
bhp = 3600.
ns = n*math.sqrt(bhp) /h**(5./4)
D = 153.2*phie*math.sqrt(h) /n
B = BD*D
Dt = D*0.735
Ac = 0.95*math.pi*D*B
Vr = Cr*math.sqrt(2*g*h)
Q = Ac*Vr
#Results
print " Breadth = %.3f ft"%(B)
print " depth D = %.2f ft"%(D)
print " velocity Vr = %d ft/s"%(Vr)
print " Flow rate Q = %.1f cfs"%(Q)
# note : answers are slightly different because of rounding off error.
#Initialization of variables
ns = 70.
z1 = 10. #ft
z2 = 5000. #ft
#calculations
P1 = 12.2*144/62.4
P2 = 0.26*144/62.4
sigmac = 0.31
h = (P1-P2-z1)/sigmac
#Results
print "Max permissible head to assure against cavitation = %.f ft"%(h)
import math
#Initialization of variables
Q = 600. #cfs
z = 350. #ft
eta = 0.9
#calculations
power = 62.4*Q*z*eta/550
rpm = 75.
n = 2.
ns = rpm*math.sqrt(power/n) /z**(5./4)
phi = 0.45
D = 153.3*math.sqrt(z) *phi/rpm
rpm2 = 600.
ns2 = rpm2*math.sqrt(power/n) /z**(5./4)
#Results
print "For two turbines, ns = %.2f"%(ns)
print "For Francis turbines, ns = %d "%(ns2)