#calculate the max. pressure, temperature and thermal efficiency
#Initalization of variables
import math
cr=9.
p1=14. #psia
t1=80.+460 #R
n=1.4
heat=800. #Btu
c=0.1715
R=53.35
J=778.
#calculations
p2=p1*math.pow(cr,n)
t2=t1*math.pow(cr,(n-1))
t3=heat/c +t2
p3=p2*t3/t2
eff=(1-1/math.pow(cr,(n-1)))*100
t4=t3/math.pow(cr,(n-1))
Qr=c*(t4-t1)
cyclework=heat-Qr
eff2= cyclework/heat *100
V1=R*t1/(144*p1)
pd=(1-1/cr)*V1
mep=cyclework*J/(pd*144)
#results
print '%s %d %s' %("Max. temperature =",t3,"R")
print '%s %d %s' %("\n Max. pressure =",p3,"psia")
print '%s %.1f %s' %("\n In method 1,Thermal efficiency =",eff," percent")
print '%s %.1f %s' %("\n In method 2,Thermal efficiency =",eff2," percent")
print '%s %.1f %s' %("\n Mean effective pressure mep =",mep," psia")
#calculate the max temperature, pressure and thermal efficiency
#Initalization of variables
import math
t1=80+460. #R
p1=14. #psia
n=1.4
cr=16.
heat=800. #Btu
cp=0.24
c=0.1715
#calculations
t2=t1*math.pow(cr,(n-1))
p2=p1*math.pow(cr,n)
t3=t2 +heat/cp
v32=t3/t2
v43=cr/v32
t4=t3/math.pow(v43,(n-1))
Qr=c*(t4-t1)
etat=(heat-Qr)/heat *100
#results
print '%s %d %s' %("Max. Temperature =",t3," R")
print '%s %d %s' %("\n Max. Pressure =",p2,"psia")
print '%s %.1f %s' %("\n Thermal efficiency =",etat," percent")
#calculate the Mean effective pressure
#Initalization of variables
eff=0.585
heat=800. #Btu
t1=80+460. #R
p1=14. #psia
n=1.4
R=53.35
cr=9.
cp=0.24
J=778.
#calculations
W=eff*heat
v1=R*t1/(144*p1)
v2=v1/cr
t2=1301 #R
t3=t2+ heat/cp
v3=v2*t3/t2
v4=cr*v3
mep=W*J/(144*(v4-v2))
#results
print '%s %.1f %s' %("Mean effective pressure =",mep," psia")
#calculate the max temperature, pressure, thermal efficiency, mean effective pressure
#Initalization of variables
import math
eff=0.585
heat=500. #Btu
heat1=300. #Btu
t1=80+460. #R
p1=14. #psia
n=1.4
R=53.35
cr=9.
J=778.
c=0.1715
cp=0.24
t2=1301. #R
p2=308. #psia
#calculations
t3=t2+ heat/c
p3=p2*t3/t2
t4=t3+ heat1/cp
v43=t4/t3
v54=cr/v43
t5=t4/math.pow(v54,(n-1))
Qr=c*(t5-t1)
etat=(heat+heat1-Qr)/(heat+heat1) *100
mep=(heat+heat1-Qr)*J/(12.69*144)
#results
print '%s %d %s' %("Max. Temperature =",t4," R")
print '%s %d %s' %("\n Max. Pressure =",p3,"psia")
print '%s %.1f %s' %("\n Thermal efficiency =",etat,"percent")
print '%s %.1f %s' %("\n Mean effective pressure =",mep," psia")
print '%s' %("The calculations are a bit different due to rounding off error in textbook")