#calculate the thermal efficiency in both cases
#Initalization of variables
Qs=825.1 #Btu/lb
ds=0.9588
t1=101.74 #F
th=400.95 #F
#calculations
Qr=ds*(t1+459.69)
work=Qs-Qr
eta=work/Qs*100.
eta2=(th-t1)/(th+459.69) *100.
#results
print '%s %.2f %s' %("In case 1, Thermal efficiency =",eta,"percent")
print '%s %.2f %s' %("\n In case 2, Thermal efficiency =",eta2," percent")
#calculate the thermal efficiency in both cases
#Initalization of variables
s2=1.5263
sfg=1.8456
sf=1.9782
h2=1201.1 #Btu/lb
hf=1106 #Btu/lb
hfg=1036.3 #Btu/lb
v=0.01616 #m^3/kg
p2=250 #psia
p1=1#psia
J=778
#calculations
x3=1+ (s2-sf)/sfg
h3=hf-(1-x3)*hfg
h4=69.7
Wp=v*144*(p2-p1)/J
h1=h4+Wp
etat=((h2-h3)-Wp)/(h2-h1) *100.
eta2=(h2-h3)/(h2-h4)*100.
#results
print '%s %.2f %s' %("\n In case 1, Efficieny =",etat,"percent")
print '%s %.2f %s' %("\n In case 2, Efficieny =",eta2,"percent")
#calculate the steam rate, enthalpy of exhaust steam, internal engine efficiency and excess heat removed
#Initalization of variables
p=40000 #kW
ef=0.98
rate=302000. #lb
s3=1.6001
h2=1490.1
loss=600.
v=400. #ft/s
g=32.2 #ft/s^2
J=778.
#calculations
out=p/(0.746*ef)
srate=rate/out
X=-(s3-1.9782)/1.8456
h3=1106 - X*1036.3
theoturb=h2-h3
intturb=(out+loss)*2544/rate
Ie=intturb/theoturb *100
h3d=h2-intturb-v*v /(2*g*J)
hexa=h3d+ v*v /(2*g*J)
excess=rate*(hexa-h3)
#results
print '%s %.2f %s' %("Steam rate =",srate,"lb/shaft hp-hr")
print '%s %.1f %s' %("\n Internal engine efficiency =",Ie," percent")
print '%s %.1f %s' %("\n Enthalpy of exhaust steam =",h3d," Btu/lb")
print '%s %d %s' %("\n Excess heat to be removed =",excess,"Btu/hr")
print '%s' %("The answers are a bit different due to rounding off error in textbook")
#calculate the thermal efficiency
#Initalization of variables
s2=1.5263
sf=1.6993
sfg=1.3313
hf=1164.1 #Btu/lb
hfg=945.3 #Btu/lb
h2=1201.1 #Btu/lb
h1=852.3 #Btu/lb
#calculations
X3=-(s2-sf)/sfg
h3=hf-X3*hfg
h4=218.82
h6=h4
h5=69.7
x=(h4-h5)/(h3-h5)
W= h2-h3+ (1-x)*(h3-h1)
Qs=h2-h4
eff=W/Qs *100
#results
print '%s %.2f %s' %("Thermal efficiency =",eff,"percent")
#calculate the thermal efficiency
#Initalization of variables
h6=157.933 #Btu/lb
s2=0.11626
sf=0.16594
sfg=0.14755
hf=139.095 #Btu/lb
hfg=126.98 #Btu/lb
h5=12.016 #Btu/lb
h2=1201.1 #Btu/lb
h1=69.7 #Btu/lb
w=348.8 #Btu/lb
m=0.0745 #lb
#calculations
x7=-(s2-sf)/sfg
h7=hf-x7*hfg
dh6=h6-h7
mr=(h7-h5)/(h2-h1)
work=w*m
tw=work+dh6
dh65=h6-h5
eff=tw/dh65 *100
#results
print '%s %.2f %s' %("Thermal efficiency =",eff,"percent")
#calculate the available portion of heat transferred
#Initalization of variables
import math
m=1 #lb
cp=0.26
t2=1800+460. #R
t1=400.95+460 #R
x=0.6
sink=100+460. #R
tm=2600+460. #R
#calculations
Q=m*cp*(t2-t1)
ds=m*cp*math.log((t2/t1))
tds=ds*(sink)
avail=Q-tds
hf=Q*x/(1-x)
av2=hf*(tm-sink)/(tm)
Qt=Q+hf
av=avail+av2
per=av/Qt *100.
#results
print '%s %.1f %s' %("Available portion of heat transferred =",per,"percent")