In [9]:

```
# initialization of variables
r=12 # compression ratio
k=1.4 # polytropic index for air
p1=200.0 # pressure at state 1 in kPa
p3=10000.0 # pressure at state 3 in kPa
c=100/(r-1) # clearance in percentage
print "The percent clearance is",round(c,2),"% \n"
v3=100.0 # let us assume v3=100 m^3 for calculations
p2=p1*(r**k) # polytopic process pressure relation
p4=p3*(1/(r**k))# polytropic process pressure relation
w34=v3*(r*p4-p3)/(1-k) # polytropic work done in process 3 to 4
v2=v3 # constant volume process
w12=v2*(p2-r*p1)/(1-k)
wcycle=w12+w34 # total work in cycle
# now equating the polytropic work calculated to work by MEP
MEP=wcycle/(r*v2-v2) # as work = pressure*change in volume
print "The MEP is",round(MEP)," kPa"
# The solution is wrong in textbook as calculation for P2 is wrong
```

In [5]:

```
# initialization of variables
r=10.0 # compression ratio
k=1.4 # polytropic index for air
R=0.287 # specific gas constant for air
Cv=0.717 # specific heat at constant volume
Wnet=1000 # net work output in kJ/kg
T1=227+273.0 # low air temperaure in kelvin
p1=200.0 # low pressure in kPa
effi=1-(1/r**(k-1)) # thermal efficeiency
print "The maximum possible thermal efficiency is",round(effi*100,1),"% \n"
T2=T1*(r)**(k-1) # isentropic process temperature relation
T4=((Wnet/Cv)+T2-T1)/((r**(k-1))-1) # using expression for work
T3=T4*(r)**(k-1)
efficarnot=1-T1/T3
print "The carnot efficiency is",round(efficarnot*100),"%"
v1=R*T1/p1 # initial volume
v2=v1/r # from compression ratio
MEP=Wnet/(v1-v2) # mean effective pressure equation
print "The MEP is",round(MEP)," kPa"
```

In [15]:

```
# initialization of variables
r=18 # compression ratio
k=1.4 # polytropic index for air
R=0.287 # specific gas constant for air
Cv=0.717 # specific heat at constant volume
Cp=1.0 # specific heat at constant pressure
T1=200+273 # lower temperaure in kelvin
P1=200.0 # low pressure in kPa
T3=2000 # higher temperature of cycle in kelvin
v1=R*T1/P1 # specific volume at state 1 in m^3
v2=v1/r # specific volume after compression in m^3
T2=T1*(v1/v2)**(k-1) # temperature after compression
P2=P1*(v1/v2)**k # pressure after compression
P3=P2 # diesel cycle
v3=R*T3/P3 # volume at state 3
rc=v3/v2 # cutoff ratio
effi=1-((rc**k)-1)/(r**(k-1)*k*(rc-1))
print "The thermal efficiency is",round(effi*100,1),"%"
v4=v1 # diesel cycle
T4=T3*(v3/v4)**(k-1) # adiabatic process
qin=Cp*(T3-T2) # using first law
qout=Cv*(T4-T1) # heat rejected
Wnet=qin-qout # net work
MEP=Wnet/(v1-v2) # expression of mean effective pressure in terms of work
print "The MEP is",round(MEP)," kPa"
```

In [23]:

```
# initialization of variables
r=18 # compression ratio
k=1.4 # polytropic index for air
R=0.287 # specific gas constant for air
T1=200+273 # lower temperaure in kelvin
P1=200.0 # low pressure in kPa
T3=2000.0 # higher temperature of cycle in kelvin
v1=R*T1/P1 # specific volume at state 1 in m^3
#using table E.1
u1=340.0 # specific internal energy in kJ/kg
vr1=198.1 # in m^3/kg
vr2=vr1*(1/r) # as r=v1/v2
# now finding corresponding values from table E.1
T2=1310.0 # temperature in kelvin
Pr2=34.0 # pressure in kPa
h2=1408.0 # specific entropy in kJ/kg
v2=v1/18 # volume at state 2
P2=R*T2/v2 # pressure at state 2
h3=2252.1 # specific enthalpy in kJ/kg from table E.1
vr3=2.776
P3=P2 # diesel cycle
v3=R*T3/P3 # after compression volume
v4=v1 # isochoric process
vr4=vr3*v4/v3 # isentropic process
# now using Vr4 we read corresponding value from table E.1
T4=915 # final temperature in kelvin
u4=687.5 # specific internal energy at state 4
qin=h3-h2 # using first law
qout=u4-u1 # heat rejected
Wnet=qin-qout # net work
effi=100*Wnet/qin # thermal efficiency
print" The thermal efficiency is",round(effi,1),"%"
MEP=Wnet/(v1-v2) # expression of mean effective pressure in terms of work
print " The MEP is",round(MEP)," kPa"
erroreffi=(66.6-effi)*100/effi # error in efficiency
errorMEP=(515-MEP)*100/MEP # error in MEP
print " The % error in efficiency is",round(erroreffi,1),"%"
print " The % error MEP is",round(errorMEP,1),"% \n"
# the answers are slight different due to approximation in textbook ... here answers are precise
```

In [33]:

```
# initialization of variables
Cp=1.0 # specific heat at constant pressure
k=1.4 # polytropic index for air
T1=25+273.0 # temperature at compressor inlet
T3=850+273.0 # maximum temperature in kelvin
r=5.0 # pressure ratio=P2/P1 & P4/P3
T2=T1*(r)**((k-1)/k) # temperature after compression
T4=T3*(1/r)**((k-1.0)/k) # final temperature
Wcomp=Cp*(T2-T1) # compressor work
Wturb=Cp*(T3-T4) # turbine work
BWR=Wcomp/Wturb # back work ratio
print " The BWR is",round(BWR*100,1),"%\n"
Effi=1-r**((1-k)/k) # thermal efficiency
print" The thermal efficiency is",round(Effi*100,1),"%"
```

In [37]:

```
# initialization of variables
Cp=1.0 # specific heat at constant pressure
k=1.4 # polytropic index for air
T1=25+273.0 # temperature at compressor inlet
T3=850+273.0 # maximum temperature in kelvin
r=5.0 # pressure ratio=P2/P1 & P4/P3
efficomp=0.75 # efficiency of compressor
effiturb=0.75 # efficiency of turbine
T2dash=T1*(r)**((k-1)/k) # temperature after compression
Wcomp=Cp*(T2dash-T1)/efficomp # compressor work
T4dash=T3*(1/r)**((k-1)/k) # final temperature
Wturb=Cp*(T3-T4dash)*effiturb # turbine work
BWR=100*Wcomp/Wturb # back work ratio
print " The BWR is",round(BWR,1),"%\n"
T2=(Wcomp/Cp)+T1 # actual temperature of state 2
qin=Cp*(T3-T2) # using first law
Wnet=(Wturb-Wcomp) # net work
effi=100*Wnet/qin # thermal efficiency
print" The thermal efficiency is",round(effi,1),"%"
```

In [41]:

```
# initialization of variables
Cp=1.0 # specific heat at constant pressure
k=1.4 # polytropic index for air
T1=25+273.0 # temperature at compressor inlet
T3=850+273.0 # maximum temperature in kelvin
r=5.0 # pressure ratio=P2/P1 & P4/P3
T2=T1*(r)**((k-1)/k) # temperature after compression
T4=T3*(1/r)**((k-1)/k) # final temperature
Wcomp=Cp*(T2-T1) # compressor work
Wturb=Cp*(T3-T4) # turbine work
BWR=Wcomp/Wturb # back work ratio
print " The BWR is",round(BWR,2),"\n"
effi=(1-((T1/T4)*(r**((k-1)/k))))# efficiency
print" The thermal efficiency is",round(effi*100,1),"%"
# The solution in textbook is incorrect due to wrong value of T4 (temperature at state 4)
```

In [45]:

```
# initialization of variables
#REFER TO FIG.:7.8
Cp=1 # specific constant at constant pressure
k=1.4 # polytropic constant for air
T5=25+273.0 # temperature at state 5 in kelvin
T7=850+273.0 # temperature at state 4 in kelvin
T9=350 # exit temperature of water from bolier in kelvin
WdotST=100000.0 # power from steam turbine in Watt
r=5.0 # pressure ratio=P2/P1 & P4/P3
h1=192.0 # specific enthalpy at 10 Kpa from steam table
h2=h1 # isenthalpic process
h3=3214.0 # specific enthalpy at 4 Mpa and 400 degree celsius from steam table
s3=6.769 # specific entropy at 4 Mpa and 400 degree celsius from steam table
s4=s3 # isentropic process
sf=0.6491 # specific entropy of saturated liquid at 10 kPa and 45 degree celsiusfrom table C.2
sg=8.1510 # specific entropy of saturated liquid at 10 kPa and 45 degree celsiusfrom table C.2
x4=(s4-sf)/(sg-sf) # quality of steam
hf=h1 # specific enthalpy of saturated liquid @ 10 Kpa
hg=2584.6
h4=hf+x4*(hg-hf) # specific entropy at state 4
mdots=WdotST/(h3-h4) # steam mass flow rate from turbine output
T6=T5*(r**((k-1)/k)) # adiabatic process relation
T8=T7*(1/r**((k-1)/k)) # adiabatic process relation
# Now using energy balance in boiler
mdota=mdots*(h3-h2)/(Cp*(T8-T9)) # mass flow rate of water
Wdotturb=mdota*Cp*(T7-T8) # power produced by turbine
Wdotcomp=mdota*Cp*(T6-T5) # energy needed by compressor
WdotGT=Wdotturb-Wdotcomp # net turbine work
Qdotin=mdota*Cp*(T7-T6) # energy input by combustor
effi=100*(WdotST+WdotGT)/Qdotin # combined efficiency
print "The thermal efficiency of the combined cycle is",round(effi,1),"%"
```

In [48]:

```
# initialization of variables
Cp=1 # specific constant at constant pressure
k=1.4 # polytropic constant for air
r=10.0
T2=-10+273 # temperature at entry of compressor
T4=30+273 # temperature at entry of turbine
T3=T2*(r**((k-1)/k)) # temperature at state 3 in kelvin
T1=T4*(1/r**((k-1)/k)) # temperature at state 1 in degree celsius
print "The minimum temperature is",round(T1-273),"degree celsius \n"
qin=Cp*(T2-T1) # heat input
Wcomp=Cp*(T3-T2)# compressor work
Wturb=Cp*(T4-T1) # turbine work
COP=qin/(Wcomp-Wturb) # COP of refrigeration
print" The COP is",round(COP,2)
```

In [51]:

```
#solution
# initialization of variables
Cp=1.0 # specific constant at constant pressure
k=1.4 # polytropic constant for air
r=10.0
T3=-10+273 # temperature at entry of compressor
T6=-40+273 # temperature at entry of turbine
T5=T3 # heat exchanger
T2=T6 # heat exchanger
T4=T3*(r**((k-1)/k)) # temperature after compression
T1=T6*(1/r**((k-1)/k)) # temperature after exit from turbine
print "The minimum temperature is",round(T1-273),"degree celsius \n"
qin=Cp*(T2-T1) # heat input
Wcomp=Cp*(T4-T3)# compressor work
Wturb=Cp*(T6-T1) # turbine work
COP=qin/(Wcomp-Wturb) # COP of refrigeration
print" The COP is",round(COP,3)
# the answer is correct within given limits
```