In [3]:

```
# solution
#initialization of variables
# Please refer to the given figure in question for quantities
P2=2*1000 #higher pressure converted in in kPa
P1=10 # lower pressure in kPa
rho=1000 # density of water in Kg/m^3
h1=192 # enthalpy at state 1 in kJ/kg
h3=3248 # enthalpy at state 3 in kJ/kg
s3=7.1279# entropy at state 3 in kJ/kg.K
#calculation of pump work
wp=(P2-P1)/rho # pump work given by equation 4.56 in textbook
h2=h1+wp # by enrgy balance b/w state 1 and 2
q=h3-h2 # Heat input from 2 to 3
s4=s3 # isentropic process
sf=0.6491 # entropy of saturated liquid @10 kPa from steam table
sg=8.151 # entropy of saturated vapour @10 kPa from steam table
x=(s4-sf)/(sg-sf)# from property of pure substance
hf=191.8 #enthalpy of saturated liquid @10 kPa from steam table
hg=2584 # enthalpy of saturated vapour @10 kPa from steam table
h4=hf+x*(hg-hf)# enthalpy @ state 4
wt=h3-h4 # turbine work
efficiency=(wt-wp)/q # efficiency of power cycle
print " The Efficiency is",round(efficiency,4)," or",round(efficiency*100,1),"%"
# the answer is correct within limits
```

In [8]:

```
# solution
#initialization of variables
# Please refer to the given figure of question 6.1 for quantities
effi1=0.323 #old efficiency
P2=4*1000 #higher pressure converted in in kPa
P1=10 # lower pressure in kPa
rho=1000 # density of water in Kg/m^3
h1=192 # enthalpy at state 1 in kJ/kg
h3=3214 # enthalpy at state 3 i.e @400 degree celsius and 4MPa in kJ/kg
s3=6.769# entropy at state 3 i.e @400 degree celsius and 4MPa in kJ/kg.K
s4=s3 # insentropic process
sf=0.6491 # entropy of saturated liquid @10 kPa from steam table
sg=8.151 # entropy of saturated vapour @10 kPa from steam table
x=(s4-sf)/(sg-sf)# quality of steam
hf=192 #enthalpy of saturated liquid @10 kPa from steam table
hg=2584 # enthalpy of saturated vapour @10 kPa from steam table
h4=hf+x*(hg-hf)# enthalpy @ state 4
h2=h1 # isenthalpic process
qb=h3-h2 # heat addition
wt=h3-h4 # turbine work
effi2=(wt)/qb # efficiency of power cycle
print " The Efficiency is",round(effi2,3)," or",round(effi2*100),"% \n"
perincrease=((effi2-effi1)/effi1)*100
print " The % increase in Efficiency is",round(perincrease,2)," \n"
```

In [11]:

```
# solution
#initialization of variables
# Please refer to fig of question 6.1 for quantities
effi1=0.323 #old efficiency
P2=2*1000 #higher pressure converted in in kPa
P1=10 # lower pressure in kPa
rho=1000 # density of water in Kg/m^3
T2=600# max temperature of cycle in degree celsius
h1=192 # enthalpy at state 1 in kJ/kg
h3=3690 # enthalpy at state 3 in kJ/kg, 600*C and 2MPa pressure
s3=7.702# entropy at state 3 in kJ/kg.K, 600*C and 2MPa pressure
s4=s3# isentropic process
sf=0.6491 # entropy of saturated liquid @10 kPa from steam table
sg=8.151 # entropy of saturated vapour @10 kPa from steam table
x=(s4-sf)/(sg-sf)# quality of steam
hf=192 #enthalpy of saturated liquid @10 kPa from steam table
hg=2584 # enthalpy of saturated vapour @10 kPa from steam table
h4=hf+x*(hg-hf)# enthalpy @ state 4
h2=h1 # isenthalpic process
qb=h3-h2 # heat addition
wt=h3-h4 # turbine work
effi2=(wt)/qb # efficiency of power cycle
print " The Efficiency is",round(effi2,3)," or",round(effi2*100),"% \n"
perincrease=((effi2-effi1)/effi1)*100
print " The % increase in Efficiency is",round(perincrease,2)," \n"
```

In [14]:

```
# solution
#initialization of variables
# Please refer to fig of question 6.1 for quantities
effi1=0.323 #old efficiency
P2=2*1000 #higher pressure converted in in kPa
P1=4 # condenser pressure in kPa
rho=1000 # density of water in Kg/m^3
h1=192 # enthalpy at state 1 in kJ/kg
h3=3248 # enthalpy at state 3 in kJ/kg
s3=7.1279# entropy at state 3 in kJ/kg.K
s4=s3 # isentropic process
sf=0.4225 # entropy of saturated liquid @10 kPa from steam table
sg=8.4754 # entropy of saturated vapour @10 kPa from steam table
x=(s4-sf)/(sg-sf)# from property of pure substance
hf=121 #enthalpy of saturated liquid @4 kPa from steam table
hg=2554 # enthalpy of saturated vapour @4 kPa from steam table
h4=hf+x*(hg-hf)# enthalpy @ state 4h1=h2 # isenthalpic process
h2=h1 # isenthalpic process
qb=h3-h2 # heat addition
wt=h3-h4 # turbine work
effi2=(wt)/qb # efficiency of power cycle
print " The Efficiency is",round(effi2,4)," or",round(effi2*100),"% \n"
perincrease=((effi2-effi1)/effi1)*100
print " The % increase in Efficiency is",round(perincrease,2)," \n"
```

In [21]:

```
# solution
#initialization of variables
P2=2*1000 #higher pressure converted in in kPa
P1=10 # lower pressure in kPa
h1=192.0 # enthalpy at 10 kPa in kJ/kg
h3=3248.0 # enthalpy @ state 3 in kJ/kg from table C.3
s3=7.128 # entropy @ state 3 in kJ/kg.K from table C.3
s4=s3 # isentropic process
h2=h1 #isenthalpic process
h4=((s4-7.038)/(7.233-7.038))*(3056-2950)+2950 #using adjacent values for
#interpolation from table C.3
h5=3267.0 # enthalpy at 800 kPa and $00 degree celsius
s5=7.572 # entropy at 800 kPa and $00 degree celsius
s6=s5 # isentropic process
sf=0.6491# entropy of saturated liquid @10 kPa from steam table
sg=8.151 # entropy of saturated vapour @10 kPa from steam table
x=(s6-sf)/(sg-sf)# quality of steam
hf=192.0 #enthalpy of saturated liquid @10 kPa from steam table
hg=2585.0 # enthalpy of saturated vapour @10 kPa from steam table
h6=hf+x*(hg-hf)# enthalpy @ state 6
# we now calculate energy input
qb=(h5-h4)+(h3-h2)# heat interaction
# we now calculate work output
wt=(h5-h6)+(h3-h4)# turbine work
eff=(wt)/qb # efficiency of power cycle
print" The Efficiency is",round(eff,3)," or",round(eff*100,2),"%"
# // The anwer is different in textbook as there the intermediate values are approximated while in python the calculations are precise
```

In [27]:

```
# initialization of variables
# Please refer to fig of question 6.1 for quantities
effi1=0.357 #efficiency from example 6.3
P2=2*1000.0 #higher pressure converted in in kPa
P1=10.0 # lower pressure in kPa
rho=1000.0 # density of water in Kg/m^3
T2=600.0 # max temperature of cycle in degree celsius
h1=192.0 # enthalpy at state 1 in kJ/kg
h3=3690.0 # enthalpy at state 3 in kJ/kg, 600*C and 2MPa pressure
h4=2442.0 # enthalpy from example 6.3
h6=505.0 # specific enthalpy @ 200 kPa from steam table
h7=h6 # isenthalpic process
s3=7.702# entropy at state 3 in kJ/kg.K, 600*C and 2MPa pressure
h2=h1 # isenthalpic process
s5=s3 # isentropic process
h5=(s3-7.509)*(2971-2870)/(7.709-7.509)+2870 # interpolationg from steam table 2 200 kPa using s5=s3= 7.702 kJ/kg.
m6=1.0 # let mass of steam =1 Kg
m5=(h6-h2)*(m6)/(h5-h2)
m2=m6-m5 # conservation of mass
wt=h3-h5+(h5-h4)*m2 # work done by turbine
qb=h3-h7 # heat given to bolier
effi2=(wt)/qb # efficiency of power cycle
print " The Efficiency is",round(effi2,4)," or",round(effi2*100),"% \n"
perincrease=((effi2-effi1)/effi1)*100
print " The % increase in Efficiency is",round(perincrease,2)," \n"
# The anwer is different in textbook as there the intermediate values are approximated while in python the calculations are precise
```

In [28]:

```
# solution
#initialization of variables
P2=2*1000 #higher pressure converted in kPa
P1=10 # lower pressure in kPa
h1=192 # enthalpy at 10 kPa in kJ/kg
h3=3248 # enthalpy @ state 3 in kJ/kg from table C.3
s3=7.128 # entropy @ state 3 in kJ/kg.K from table C.3
s4=s3 # isentropic process
h4=((s4-7.038)/(7.233-7.038))*(3056-2950)+2950 #using adjacent values for
#interpolation from table C.3
h5=3267 # enthalpy at 800 kPa and $00 degree celsius
s5=7.572 # entropy at 800 kPa and $00 degree celsius
s6=s5 # isentropic process
sf=0.6491# entropy of saturated liquid @10 kPa from steam table
sg=8.151 # entropy of saturated vapour @10 kPa from steam table
x=(s6-sf)/(sg-sf)# quality of steam
hf=192 #enthalpy of saturated liquid @10 kPa from steam table
hg=2585 # enthalpy of saturated vapour @10 kPa from steam table
h6=hf+x*(hg-hf)# enthalpy @ state 6
h7=721 # enthalpy of saturated liquid @800 kPa from steam table
h8=h7 # isenthalpic process
h2=h1 # isenthalpic process
m8=1 # let mass of steam =1 Kg
m4=(h8-h2)*(m8)/(h4-h2)
m2=m8-m4 # conservation of mass
wt=h3-h4+(h5-h6)*m2 # work done by turbine
qb=h3-h8+(h5-h4)*m2 # heat given to bolier
effi=(wt)/qb # efficiency of power cycle
# result
print " The Efficiency is",round(effi,3)," or",round(effi*100,2),"%"
```

In [32]:

```
# solution
#initialization of variables
# for rankine cycle refer to fig 6.9
effiT=0.8 # turbine efficiency
P2=2*1000 # higher pressure converted in kPa
P1=10 # lower pressure in kPa
h1=192 # enthalpy at 10 kPa in kJ/kg
h3=3690 # enthalpy of superheated steam @ 2 MPa from steam table in kJ/kg
s3=7.702 #entropy of superheated steam @ 2 MPa from steam table in kJ/kg.K
# state 4' is repsresented by '41'
h2=h1 #isenthalpic process
s41=s3 # entropy is constant
sf=0.6491 # entropy of saturated liquid @10 kPa from steam table
sg=8.151 # entropy of saturated vapour @10 kPa from steam table
x=(s41-sf)/(sg-sf)# from property of pure substance
hf=191.8 #enthalpy of saturated liquid @10 kPa from steam table
hg=2584 # enthalpy of saturated vapour @10 kPa from steam table
h41=hf+x*(hg-hf)# enthalpy @ state 41
wa=effiT*(h3-h41)# turbine efficiency =(actual work)/(isentropic work)
qb=h3-h2 # heat supplied
effi=(wa)/qb # efficiency of power cycle
print" The Efficiency is",round(effi,3)," or",round(effi*100,1),"%"
h4=h3-wa # adiabatic process
# now using interpolation for superheated steam @ 10 kPa
T4=(h4-2688)*(150-100)/(2783-2688)+100
print "\n The Temperature from interpolation comes out to be",int(T4)," degree celsius"
```

In [37]:

```
#initialization of variables
# refer to fig 6.10c
mdot=0.6 # mass flow rate of refrigerant in kg/sec
T1=-24 # evaporator temperature in degree celsius
T2=39.39 # condenser temperature in degree celsius
h1=232.8 # enthalpy of saturated R134a vapour @ -24 degree celsius from table D.1
s1=0.9370 # entropy of saturated R134a vapour @ -24 degree celsius from table D.1
h3=105.3 # enthalpy of saturated R134a liquid @ -24 degree celsius from table D.2
h4=h3 # isenthalpic process
# interpolating enthalpy from table D.3 @ 39.39 degree celsius
h2=(s1-0.9066)*(280.19-268.68)/(0.9428-0.9066)+268.68
QdotE=mdot*(h1-h4) # heat transfer rate
WdotC=mdot*(h2-h1)# power given to compressor
COP=QdotE/WdotC # coefficient of performance
Hp=(WdotC/0.746)/(QdotE/3.52) #calculating Horsepower required per Ton
print "The rate of refrigeration is",round(QdotE,2),"kJ/s \n "
print "The coefficient of performance is",round(COP,2),"\n "
print "The rating in horsepower per ton is",round(Hp,3)," hp\n "
```

In [41]:

```
#initialization of variables
# refer to fig 6.10c
effi=0.8 # compressor efficiency
mdot=0.6 # mass flow rate of refrigerant in Kg/sec
T4=-24 # temperature of evaporator
T2=39.39 # temperature of condensor
T1=-20.0 # supeheating temperature
T3=40 # subcooling temperature
h3=106.2 # enthalpy of liquid R-134a @ 40 degree celsius from table D.1
h4=h3 # isenthalpic process
h1=236.5 # enthalpy of superheated R-134a @ 0.10 MPa and -20 degree celsius from table D.3
s1=0.960 #entropy of superheated R-134a @ 0.10 MPa and -20 degree celsius from table D.3
s2dash=s1 # isentropic process
# using interpolation from table D.3 @ 1.0 MPa for s2dash=0.960
h2dash=(s2dash-0.9428)*(291.36-280.19)/(0.9768-0.9428)+280.19
h2=(h2dash-h1)/(effi)+h1 # by definition of compressor efficiency
QdotE=mdot*(h1-h4)#heat transfer rate power given to compressor
wdotc=mdot*(h2-h1)# power given to compressor
COP=QdotE/wdotc # coefficient of performance
print "The rate of refrigeration is",round(QdotE,1),"kJ/s \n "
print "The coefficient of performance is",round(COP,2),"\n "
# The value of Wdotc is shown wrong in the textbook. It should be multiplied by mass flow rate
```

In [66]:

```
# solution
#initialization of variables
# refer to fig 6.10c
QdotC=300 #heating Load in KWh or heat rejected by condensor
T1=-12 # evaporator temperature in degree celsius
P2=800 # condensor pressure in kPa
h1=240 # specific enthalpy of saturated R-134a vapour @ -12 degree celsius from table D.1
s1=0.927 # specific entropy of saturated R-134a vapour @ -12 degree celsius from table D.1
s2=s1 # isentropic process
h3=93.4 #specific enthalpy of saturated R-134a liquid @ 800 kPa from tableD.2
# extrapolating enthalpy from table D.2 @ 0.8 MPa for s=0.927
h2=273.7-(0.9374-s2)*(284.4-273.7)/(0.9711-0.9374)
# QdotE=mdot*(h1-h4) is heat transfer rate
mdot=QdotC/(h2-h3)# mass flow rate
WdotC=mdot*(h2-h1)# power given to compressor
#part(a)
COP=QdotC/WdotC # coefficient of performance
print "The coefficient of performance is",round(COP,2),"\n "
#part(b)
Cost=WdotC*0.07 # cost of electricity
print "The cost of electricity is $",round(Cost,3),"/hr \n"
#part(c)
costgas=(300*3600*0.50)/100000 # cost of gas
print "The cost of gas is $",round(costgas,2),"/hr \nThus heat pump is better "
```