#calculate the theoretical horse power
#Initalization of variables
import math
q=200. #cfm
p2=90. #psia
p1=14.5 #psia
n=1.36
#calculations
hpp=n/(n-1) *144.*p1*q/33000. *(-1+math.pow(p2/p1, (n-1)/n))
#results
print '%s %.1f %s' %("Theoretical horse power required =",hpp," hp")
print '%s' %("The answer given in textbook is wrong. Please verify with a calculator")
#calcualte the indicated hp and shaft hp
#Initalization of variables
import math
q=350. #cfm
eff=0.78
x=0.95
p2=120. #psia
p1=14.3 #psia
#calculations
cal=p1*144*q/550 *math.log(p2/p1) /100.
ihp= cal/eff
shp=ihp/x
#results
print '%s %.1f %s' %("Indicated hp =",ihp,"hp")
print '%s %.1f %s' %("\n Shaft hp =",shp,"hp")
#calculate the theoretical hp and piston displacement and max. temperature
#Initalization of variables
import math
n=1.35
p1=14.2
q=400. #cfm
p2=200. #psia
p1=14.2 #psia
ve=0.75
t1=530. #R
#calculations
thp=-n/(n-1) *144 *p1*q/33000 *(1- math.pow(p2/p1,(n-1)/n))
pd=q/ve
Tmax=t1*math.pow(p2/p1,(n-1)/n)
#results
print '%s %.1f %s' %("Theoretical hp =",thp," hp")
print '%s %d %s' %("\n Piston displacement =",pd,"cfm")
print '%s %d %s' %("\n Max. Temperature =",Tmax,"R")
#calculate the theoretical hp and piston displacement and max. temperature
#Initalization of variables
import math
n=1.35
p1=14.2 #psia
p3=200. #psia
q=400. #cfm
ve=0.78
t1=530. #R
#calculations
p2=math.sqrt(p3*p1) #psia
thp=-2*n/(n-1) *144 *p1*q/33000 *(1- math.pow(p2/p1,(n-1)/n))
pd=q/ve
pd2=q*p1/p2 /ve
Tmax=t1*math.pow(p2/p1,(n-1)/n)
#results
print '%s %.1f %s' %("Theoretical hp =",thp," hp")
print '%s %.1f %s' %("\n For low pressure case, Piston displacement =",pd,"cfm")
print '%s %.1f %s' %("\n For high pressure case, Piston displacement =",pd2,"cfm")
print '%s %.1f %s' %("\n Max. Temperature =",Tmax," R")
print '%s' %('The answers are a bit different due to rounding off error')
#calculate the theoretical pressure at exit
#Initalization of variables
import math
dia=2 #ft
rpm=6000. #rpm
p=14.2 #psia
t=75. #F
g=32.17
n=1.4
R=53.35
#calculations
v=2*math.pi*rpm/60.
wbym=v*v /g
T=t+460.
pr=1+ wbym*(n-1)/n /(R*T)
pr2=math.pow(pr,(n/(n-1)))
p2=pr2*p
#results
print '%s %.1f %s' %("Theoretical pressure at exit =",p2," psia")
#calculate the velocity of air
#Initalization of variables
import math
pa=14.7 #psia
p1=12. #psia
t1=560. #R
n=1.4 #gamma
J=778. #constant conversion
g=32.2 #ft/s^2
cp=0.24 #heat capacity
eff=0.7 #efficiency
m1=1.8
m3=1.
#calculations
t5=t1*math.pow(pa/p1,((n-1)/n))
v4=math.sqrt(2*g*J*cp*(t5-t1)/eff)
v3=(m1+m3)/m1 *v4
#results
print '%s %.1f %s' %("Velocity of air =",v3," ft/s")
print '%s' %("The answer given in textbook is wrong. Please verify with a calculator")
#calculate the pressure required
#Initalization of variables
import math
v2=1180. #ft/s
etan=0.95
cp=0.24
n=1.4
p2=12.
#calculations
dh=v2*v2 /(etan*223.8*223.8)
dt=dh/cp
t2d=560. #R
t1=t2d+ etan*dt
t2=554. #R
pr=math.pow(t1/t2,(n/(n-1)))
p1=p2*pr
#results
print '%s %.2f %s' %("Pressure required =",p1,"psia")