# Initialization of Variable
from math import pi
from math import atan
from numpy import *
area1=2.7
length=3.4
scale=60
area2=2.75
dia=12 #ft
d2=2.5 #ft
L=15.0/12 #ft
n=250.0 #rpm
F=600.0 #lb
r=3 #ft
#calculations
Ah=dia**2 *pi/4
Ac=(dia**2 -d2**2)*pi/4
Pih=area1/length *scale
Pic=area2/length *scale
Hihp=Pih*L*Ah*n/33000.0
Cihp=Pic*L*Ac*n/33000.0
Tihp=Hihp+Cihp
Bhp=2*pi*r*F*n/33000.0
Fhp=Tihp-Bhp
eff=Bhp/Tihp *100 #efficiency
#results
print "Ihp in ihp",round(Tihp,3)
print "Bhp in bhp",round(Bhp,3)
print "Fhp in fhp",round(Fhp,3)
print "Efficiency in percent",round(eff,3)
print "The answer is a bit different due to rounding off error in the textbook"
# Initialization of Variable
from math import pi
from math import atan
from numpy import *
Ihp=101.1
Bhp=85.7
md=3000.0 #lb/hr
h1=1172.0 #Btu/hr
h2=180.0 #Btu/hr
h3=1025.0 #Btu/hr
#calculations
eta1=Ihp*2545/(md*(h1-h2)) *100 #efficiency
eta2=Bhp*2545/(md*(h1-h2)) *100 #efficiency
etat=(h1-h3)/(h1-h2) *100 #efficiency
engeff=eta1/etat *100 #engine efficiency
rate1= md/Ihp
rate2=md/Bhp
h22=h1-2545/rate1 #enthalpy
#results
print "Actual thermal efficiency based upon Ihp in lb per ihp hr",round(eta1,3)
print "Actual thermal efficiency based upon Bhp in lb per ihp hr",round(eta2,3)
print "Ideal thermal efficiency in percent ",round(etat,3)
print "Engine efficiency in percent",round(engeff,3)
print "Steam rate in lb per ihp hr",round(rate1,3)
print "Steam rate in lb per bhp hr",round(rate2,3)
print "Enthalpy of exhaust steam in Btu per lb of steam",round(h22,3)