In [1]:

```
#pg 436
print('Example 15.1');
# aim : To determine
# the thermal efficiency of the cycle
# given values
T1 = 273.+400;# temperature limit, [K]
T3 = 273.+70;# temperature limit, [K]
# solution
# using equation [15] of section 15.3
n_the = (T1-T3)/T1*100;# thermal efficiency
#results
print ' The thermal efficiency of the cycle is (percent) = ',round(n_the)
# End
```

In [3]:

```
#pg 437
print('Example 15.2');
# aim : To determine
# (a) the volume ratios of the isothermal and adiabatic processes
# (b) the thermal efficiency of the cycle
# given values
T1 = 273.+260;# temperature, [K]
T3 = 273.+21;# temperature, [K]
er = 15.;# expansion ratio
Gama = 1.4;# heat capacity ratio
# solution
# (a)
T2 = T1;
T4 = T3;
# for adiabatic process
rva = (T1/T4)**(1/(Gama-1));# volume ratio of adiabatic
rvi = er/rva;# volume ratio of isothermal
print ' (a) The volume ratio of the adiabatic process is = ',round(rva,3)
print ' The volume ratio of the isothermal process is = ',round(rvi,2)
# (b)
n_the = (T1-T4)/T1*100;# thermal efficiency
print ' (b) The thermal efficiency of the cycle is (percent) = ',round(n_the,1)
# End
```

In [5]:

```
#pg 438
print('Example 15.3');
# aim : To determine
# (a) the pressure, volume and temperature at each corner of the cycle
# (b) the thermal efficiency of the cycle
# (c) the work done per cycle
# (d) the work ratio
from math import log
# given values
m = 1;# mass of air, [kg]
P1 = 1730.;# initial pressure of carnot engine, [kN/m^2]
T1 = 273.+300;# initial temperature, [K]
R = .29;# [kJ/kg K]
Gama = 1.4;# heat capacity ratio
# solution
# taking reference Fig. 15.15
# (a)
# for the isothermal process 1-2
# using ideal gas law
V1 = m*R*T1/P1;# initial volume, [m^3]
T2 = T1;
V2 = 3.*V1;# given condition
# for isothermal process, P1*V1=P2*V2, so
P2 = P1*(V1/V2);# [MN/m^2]
# for the adiabatic process 2-3
V3 = 6.*V1;# given condition
T3 = T2*(V2/V3)**(Gama-1);
# also for adiabatic process, P2*V2^Gama=P3*V3^Gama, so
P3 = P2*(V2/V3)**Gama;
# for the isothermal process 3-4
T4 = T3;
# for both adiabatic processes, the temperataure ratio is same,
# T1/T4 = T2/T3=(V4/V1)^(Gama-1)=(V3/V2)^(Gama-1), so
V4 = 2*V1;
# for isothermal process, 3-4, P3*V3=P4*V4, so
P4 = P3*(V3/V4);
print '(a) At line 1'
print ' V1 = ',round(V1,3),' m^3, t1 = ',T1-273,' C, P1 = ',P1,' kN/m^2 '
print 'At line 2'
print ' V2 = ',round(V2,3),' m^3, t2 = ',T2-273,' C, P2 = ',round(P2,1),' kN/m^2'
print 'At line 3'
print ' V3 = ',round(V3,3),' m^3, t3 = ',round(T3-273),' C, P3 = ',round(P3,1),' kN/m^2'
print 'At line 4'
print ' V4 = ',round(V4,3),' m^3, t4 = ',round(T4-273,1),' C, P4 = ',round(P4,1),' kN/m^2'
# (b)
n_the = (T1-T3)/T1;# thermal efficiency
print ' (b) The thermal efficiency of the cycle (percent) = ',round(n_the*100)
# (c)
W = m*R*T1*log(V2/V1)*n_the;# work done, [J]
print ' (c) The work done per cycle is (kJ) = ',round(W,1)
# (d)
wr = (T1-T3)*log(V2/V1)/(T1*log(V2/V1)+(T1-T3)/(Gama-1));# work ratio
print ' (d) The work ratio is = ',round(wr,3)
print 'there is calculation mistake in the book so answer is not matching'
# End
```

In [6]:

```
#pg 446
print('Example 15.4');
# aim : To determine
# (a) the pressure, volume and temperature at cycle state points
# (b) the heat received
# (c) the work done
# (d) the thermal efficiency
# (e) the carnot efficiency
# (f) the work ration
# (g) the mean effective pressure
# given values
ro = 8.;# overall volume ratio;
rv = 6.;# volume ratio of adiabatic compression
P1 = 100.;# initial pressure , [kN/m^2]
V1 = .084;# initial volume, [m^3]
T1 = 273.+28;# initial temperature, [K]
Gama = 1.4;# heat capacity ratio
cp = 1.006;# specific heat capacity, [kJ/kg K]
# solution
# taking reference Fig. 15.18
# (a)
V2 = V1/rv;# volume at stage2, [m^3]
V4 = ro*V2;# volume at stage 4;[m^3]
# using PV^(Gama)=constant for process 1-2
P2 = P1*(V1/V2)**(Gama);# pressure at stage2,. [kN/m^2]
T2 = T1*(V1/V2)**(Gama-1);# [K]
P3 = P2;# pressure at stage 3, [kN/m^2]
V3 = V4/rv;# volume at stage 3, [m^3]
# since pressure is constant in process 2-3 , so using V/T=constant, so
T3 = T2*(V3/V2);# temperature at stage 3, [K]
# for process 1-4
T4 = T1*(V4/V1);# temperature at stage4, [K
P4 = P1;# pressure at stage4, [kN/m^2]
print ' (a) P1 = ',P1,' kN/m^2, V1 = ',V1,' m^3, t1 = ',T1-273,' C,\n P2 = ',round(P2),' kN/m^2, V2 = ',V2,' m^3, t2 = ',round(T2-273),' C,\n P3 = ',round(P3),' kN/m^2, V3 = ',round(V3,3),' m^3, t3 = ',round(T3-273),' C,\n P4 = ',P4,' kN/m^2, V4 = ',V4,' m^3, t4 = ',round(T4-273),' C'
# (b)
R = cp*(Gama-1)/Gama;# gas constant, [kJ/kg K]
m = P1*V1/(R*T1);# mass of gas, [kg]
Q = m*cp*(T3-T2);# heat received, [kJ]
print ' (b) The heat received is (kJ) = ',round(Q,2)
# (c)
W = P2*(V3-V2)-P1*(V4-V1)+((P3*V3-P4*V4)-(P2*V2-P1*V1))/(Gama-1);# work done, [kJ]
print ' (c) The work done is (kJ) = ',round(W,2)
# (d)
TE = 1-T1/T2;# thermal efficiency
print ' (d) The thermal efficiency is (percent) = ',round(TE*100,1)
# (e)
CE = (T3-T1)/T3;# carnot efficiency
print ' (e) The carnot efficiency is (percent) = ',round(CE*100,1)
# (f)
PW = P2*(V3-V2)+(P3*V3-P4*V4)/(Gama-1);# positive work done, [kj]
WR = W/PW;# work ratio
print ' (f) The work ratio is = ',round(WR,3)
# (g)
Pm = W/(V4-V2);# mean effective pressure, [kN/m^2]
print ' (g) The mean effective pressure is (kN/m^2) = ',round(Pm,2)
print ' there is minor variation in answer reported in the book due to rounding off error'
# End
```

In [7]:

```
#pg 450
print('Example 15.5');
# aim : To determine
# (a) the actual thermal efficiency of the turbine
# (b) the specific fuel consumption of the turbine in kg/kWh
# given values
P2_by_P1 = 8;
n_tur = .6;# ideal turbine thermal efficiency
c = 43.*10**3;# calorific value of fuel, [kJ/kg]
Gama = 1.4;# heat capacity ratio
# solution
# (a)
rv = P2_by_P1;
n_tur_ide = 1-1/(P2_by_P1)**((Gama-1)/Gama);# ideal thermal efficiency
ate = n_tur_ide*n_tur;# actual thermal efficiency
print ' (a) The actual thermal efficiency of the turbine is (percent) = ',round(ate*100,2)
# (b)
ewf = c*ate;# energy to work fuel, [kJ/kg]
kWh = 3600.;# energy equivalent ,[kJ]
sfc = kWh/ewf;# specific fuel consumption, [kg/kWh]
print ' (b) The specific fuel consumption of the turbine is (kg/kWh) = ',round(sfc,3)
# End
```

In [8]:

```
#pg 456
print('Example 15.6');
# aim : To determine
# the relative efficiency of the engine
import math
# given values
d = 80;# bore, [mm]
l = 85;# stroke, [mm]
V1 = .06*10**6;# clearence volume, [mm^3]
ate = .22;# actual thermal efficiency of the engine
Gama = 1.4;# heat capacity ratio
# solution
sv = math.pi*d**2/4*l;# stroke volume, [mm^3]
V2 = sv+V1;# [mm^3]
rv = V2/V1;
ite = 1-(1/rv)**(Gama-1);# ideal thermal efficiency
re = ate/ite;# relative thermal efficiency
#results
print ' The relative efficiency of the engine is (percent) = ',round(re*100,1)
# End
```

In [9]:

```
#pg 457
print('Example 15.7');
# aim : To determine
# (a) the pressure, volume and temperature at each cycle process change points
# (b) the heat transferred to air
# (c) the heat rejected by the air
# (d) the ideal thermal efficiency
# (e) the work done
# (f) the mean effective pressure
# given values
m = 1.;# mass of air, [kg]
rv = 6.;# volume ratio of adiabatic compression
P1 = 103.;# initial pressure , [kN/m^2]
T1 = 273.+100;# initial temperature, [K]
P3 = 3450.;# maximum pressure, [kN/m^2]
Gama = 1.4;# heat capacity ratio
R = .287;# gas constant, [kJ/kg K]
# solution
# taking reference Fig. 15.20
# (a)
# for point 1
V1 = m*R*T1/P1;# initial volume, [m^3]
# for point 2
V2 = V1/rv;# volume at point 2, [m^3]
# using PV^(Gama)=constant for process 1-2
P2 = P1*(V1/V2)**(Gama);# pressure at point 2,. [kN/m^2]
T2 = T1*(V1/V2)**(Gama-1);# temperature at point 2,[K]
# for point 3
V3 = V2;# volume at point 3, [m^3]
# since volume is constant in process 2-3 , so using P/T=constant, so
T3 = T2*(P3/P2);# temperature at stage 3, [K]
# for point 4
V4 = V1;# volume at point 4, [m^3]
P4 = P3*(V3/V4)**Gama;# pressure at point 4, [kN/m^2]
# again since volume is constant in process 4-1 , so using P/T=constant, so
T4 = T1*(P4/P1);# temperature at point 4, [K]
print ' (a) P1 = ',P1,' kN/m^2, V1 = ',round(V1,3),' m^3, t1 = ',T1-273,' C,\n P2 = ',round(P2),' kN/m^2, V2 = ',round(V2,3),' m^3, t2 = ',round(T2-273),' C,\n P3 = ',round(P3),' kN/m^2, V3 = ',round(V3,3),' m^3, t3 = ',round(T3-273),' C,\n P4 = ',round(P4,1),' kN/m^2, V4 = ',round(V4,3),' m^3, t4 = ',round(T4-273),' C'
# (b)
cv = R/(Gama-1);# specific heat capacity, [kJ/kg K]
Q23 = m*cv*(T3-T2);# heat transferred, [kJ]
print ' (b) The heat transferred to the air is (kJ) = ',round(Q23)
# (c)
Q34 = m*cv*(T4-T1);# heat rejected by air, [kJ]
print ' (c) The heat rejected by the air is (kJ) = ',round(Q34,1)
# (d)
TE = 1-Q34/Q23;# ideal thermal efficiency
print ' (d) The ideal thermal efficiency is (percent) = ',round(TE*100,1)
# (e)
W = Q23-Q34;# work done ,[kJ]
print ' (e) The work done is (kJ) = ',round(W,1)
# (f)
Pm = W/(V1-V2);# mean effective pressure, [kN/m^2]
print ' (f) The mean effective pressure is (kN/m^2) = ',round(Pm,2)
print 'The answers are a bit different due to rounding off error in textbook'
# End
```

In [10]:

```
#pg 460
print('Example 15.8');
# aim : To determine
# (a) the pressure, volume and temperature at cycle state points
# (b) the thermal efficiency
# (c) the theoretical output
# (d) the mean effective pressure
# (e) the carnot efficiency
# given values
rv = 9.;# volume ratio
P1 = 101.;# initial pressure , [kN/m^2]
V1 = .003;# initial volume, [m^3]
T1 = 273.+18;# initial temperature, [K]
P3 = 4500.;# maximum pressure, [kN/m^2]
N = 3000.;
cp = 1.006;# specific heat capacity at constant pressure, [kJ/kg K]
cv = .716;# specific heat capacity at constant volume, [kJ/kg K]
# solution
# taking reference Fig. 15.20
# (a)
# for process 1-2
Gama = cp/cv;# heat capacity ratio
R = cp-cv;# gas constant, [kJ/kg K]
V2 = V1/rv;# volume at stage2, [m^3]
# using PV^(Gama)=constant for process 1-2
P2 = P1*(V1/V2)**(Gama);# pressure at stage2,. [kN/m^2]
T2 = T1*(V1/V2)**(Gama-1);# [K]
# for process 2-3
V3 = V2;# volume at stage 3, [m^3]
# since volume is constant in process 2-3 , so using P/T=constant, so
T3 = T2*(P3/P2);# temperature at stage 3, [K]
# for process 3-4
V4 = V1;# volume at stage 4
# using PV^(Gama)=constant for process 3-4
P4 = P3*(V3/V4)**(Gama);# pressure at stage2,. [kN/m^2]
T4 = T3*(V3/V4)**(Gama-1);# temperature at stage 4,[K]
print ' (a) P1 = ',P1,' kN/m^2, V1 = ',round(V1,3),' m^3, t1 = ',T1-273,' C,\n P2 = ',round(P2),' kN/m^2, V2 = ',round(V2,3),' m^3, t2 = ',round(T2-273),' C,\n P3 = ',round(P3),' kN/m^2, V3 = ',round(V3,3),' m^3, t3 = ',round(T3-273),' C,\n P4 = ',round(P4,1),' kN/m^2, V4 = ',round(V4,3),' m^3, t4 = ',round(T4-273),' C'
# (b)
TE = 1-(T4-T1)/(T3-T2);# thermal efficiency
print ' (b) The thermal efficiency is (percent) = ',round(TE*100)
# (c)
m = P1*V1/(R*T1);# mass os gas, [kg]
W = m*cv*((T3-T2)-(T4-T1));# work done, [kJ]
Wt = W*N/60;# workdone per minute, [kW]
print ' (c) The theoretical output is (kW) = ',round(Wt,1)
# (d)
Pm = W/(V1-V2);# mean effective pressure, [kN/m^2]
print ' (g) The mean effefctive pressure is (kN/m^2) = ',round(Pm,1)
# (e)
CE = (T3-T1)/T3;# carnot efficiency
print ' (e) The carnot efficiency is (percent) = ',CE*100
# End
```

In [11]:

```
#pg 467
print('Example 15.9');
# aim : To determine
# (a) the pressure and temperature at cycle process change points
# (b) the work done
# (c) the thermal efficiency
# (d) the work ratio
# (e) the mean effective pressure
# (f) the carnot efficiency
# given values
rv = 16.;# volume ratio of compression
P1 = 90.;# initial pressure , [kN/m^2]
T1 = 273.+40;# initial temperature, [K]
T3 = 273.+1400;# maximum temperature, [K]
cp = 1.004;# specific heat capacity at constant pressure, [kJ/kg K]
Gama = 1.4;# heat capacoty ratio
# solution
cv = cp/Gama;# specific heat capacity at constant volume, [kJ/kg K]
R = cp-cv;# gas constant, [kJ/kg K]
# for one kg of gas
V1 = R*T1/P1;# initial volume, [m^3]
# taking reference Fig. 15.22
# (a)
# for process 1-2
# using PV^(Gama)=constant for process 1-2
# also rv = V1/V2
P2 = P1*(rv)**(Gama);# pressure at stage2,. [kN/m^2]
T2 = T1*(rv)**(Gama-1);# temperature at stage 2, [K]
# for process 2-3
P3 = P2;# pressure at stage 3, [kN/m^2]
V2 = V1/rv;#[m^3]
# since pressure is constant in process 2-3 , so using V/T=constant, so
V3 = V2*(T3/T2);# volume at stage 3, [m^3]
# for process 1-4
V4 = V1;# [m^3]
P4 = P3*(V3/V4)**(Gama)
# since in stage 1-4 volume is constant, so P/T=constant,
T4 = T1*(P4/P1);# temperature at stage 4,[K]
print ' (a) P1 = ',P1,' kN/m^2, V1 = ',round(V1,3),' m^3, t1 = ',T1-273,' C,\n P2 = ',round(P2),' kN/m^2, V2 = ',round(V2,3),' m^3, t2 = ',round(T2-273),' C,\n P3 = ',round(P3),' kN/m^2, V3 = ',round(V3,3),' m^3, t3 = ',round(T3-273),' C,\n P4 = ',round(P4,1),' kN/m^2, V4 = ',round(V4,3),' m^3, t4 = ',round(T4-273),' C'
# (b)
W = cp*(T3-T2)-cv*(T4-T1);# work done, [kJ]
print ' (b) The work done is (kJ) = ',W
# (c)
TE = 1-(T4-T1)/((T3-T2)*Gama);# thermal efficiency
print ' (c) The thermal efficiency is (percent) = ',round(TE*100,1)
# (d)
PW = cp*(T3-T2)+R*(T3-T4)/(Gama-1);# positive work done
WR = W/PW;# work ratio
print ' (d) The work ratio is = ',round(WR,3)
# (e)
Pm = W/(V1-V2);# mean effective pressure, [kN/m^2]
print ' (e) The mean effefctive pressure is (kN/m^2) = ',round(Pm,1)
# (f)
CE = (T3-T1)/T3;# carnot efficiency
print ' (f) The carnot efficiency is (percent) = ',round(CE*100,1)
print 'value of t2 printed in the book is incorrect'
# End
```

In [12]:

```
#pg 470
print('Example 10');
# aim : To determine
# (a) the maximum temperature attained during the cycle
# (b) the thermal efficiency of the cycle
# given value
rva =7.5;# volume ratio of adiabatic expansion
rvc =15.;# volume ratio of compression
P1 = 98.;# initial pressure, [kn/m^2]
T1 = 273.+44;# initial temperature, [K]
P4 = 258.;# pressure at the end of the adiabatic expansion, [kN/m^2]
Gama = 1.4;# heat capacity ratio
# solution
# by seeing diagram
# for process 4-1, P4/T4=P1/T1
T4 = T1*(P4/P1);# [K]
# for process 3-4
T3 = T4*(rva)**(Gama-1);
print ' (a) The maximum temperature during the cycle is (C) = ',round(T3-273,1)
# (b)
# for process 1-2,
T2 = T1*(rvc)**(Gama-1);# [K]
n_the = 1-(T4-T1)/((Gama)*(T3-T2));# thermal efficiency
print ' (b) The thermal efficiency of the cycle is (percent) = ',round(n_the*100,1)
# End
```

In [13]:

```
#pg 471
print('Example 15.11');
# aim : To determine
# (a) the thermal efficiency of the cycle
# (b) the indicared power of the cycle
# given values
# taking basis one second
rv = 11.;# volume ratio
P1 = 96.;# initial pressure , [kN/m^2]
T1 = 273.+18;# initial temperature, [K]
Gama = 1.4;# heat capacity ratio
# solution
# taking reference Fig. 15.24
# (a)
Beta = 2;# ratio of V3 and V2
TE = 1-(Beta**(Gama)-1)/((rv**(Gama-1))*Gama*(Beta-1));# thermal efficiency
print ' (a) the thermal efficiency of the cycle is (percent) = ',round(TE*100,1)
# (b)
# let V1-V2=.05, so
V2 = .05*.1;# [m^3]
# from this
V1 = rv*V2;# [m^3]
V3 = Beta*V2;# [m^3]
V4 = V1;# [m^3]
P2 = P1*(V1/V2)**(Gama);# [kN/m^2]
P3 = P2;# [kn/m^2]
P4=P3*(V3/V4)**(Gama);# [kN/m^2]
# indicated power
W = P2*(V3-V2)+((P3*V3-P4*V4)-(P2*V2-P1*V1))/(Gama-1);# indicated power, [kW]
print ' (c) The indicated power of the cycle is (kW) = ',round(W,2)
# End
```

In [14]:

```
#pg 477
print('Example 15.12');
# aim : To determine
# (a) the pressure and temperature at the end of compression
# (b) the pressure and temperature at the end of the constant volume process
# (c) the temperature at the end of constant pressure process
# given values
P1 = 103.;# initial pressure, [kN/m^2]
T1 = 273.+22;# initial temperature, [K]
rv = 16.;# volume ratio of the compression
Q = 244.;#heat added, [kJ/kg]
Gama = 1.4;# heat capacity ratio
cv = .717;# heat capacity, [kJ/kg k]
# solution
# taking reference as Fig.15.26
# (a)
# for compression
# rv = V1/V2
P2 = P1*(rv)**Gama;# pressure at end of compression, [kN/m^2]
T2 = T1*(rv)**(Gama-1);# temperature at end of compression, [K]
print ' (a) The pressure at the end of compression is (MN/m^2) = ',round(P2*10**-3)
print ' The temperature at the end of compression is (C) = ',round(T2-273)
# (b)
# for constant volume process,
# Q = cv*(T3-T2), so
T3 = T2+Q/cv;# temperature at the end of constant volume, [K]
# so for constant volume, P/T=constant, hence
P3 = P2*(T3/T2);# pressure at the end of constant volume process, [kN/m^2]
print ' (b) The pressure at the end of constant volume process is (MN/m^2) = ',round(P3*10**-3,1)
print ' The temperature at the end of constant volume process is (C) = ',round(T3-273)
# (c)
S = rv-1;# stroke
# assuming
V3 = 1;# [volume]
#so
V4 = V3+S*.03;# [volume]
# also for constant process V/T=constant, hence
T4 = T3*(V4/V3);# temperature at the end of constant presure process, [k]
print ' (c) The temperature at the end of constant pressure process is (C) = ',round(T4-273)
# End
```

In [15]:

```
#pg 479
print('Example 15.13');
# aim : To determine
# (a) the pressure, volume and temperature at cycle process change points
# (b) the net work done
# (c) the thermal efficiency
# (d) the heat received
# (e) the work ratio
# (f) the mean effective pressure
# (g) the carnot efficiency
# given values
rv = 15.;# volume ratio
P1 = 97.*10**-3;# initial pressure , [MN/m^2]
V1 = .084;# initial volume, [m^3]
T1 = 273.+28;# initial temperature, [K]
T4 = 273.+1320;# maximum temperature, [K]
P3 = 6.2;# maximum pressure, [MN/m^2]
cp = 1.005;# specific heat capacity at constant pressure, [kJ/kg K]
cv = .717;# specific heat capacity at constant volume, [kJ/kg K]
# solution
# taking reference Fig. 15.27
# (a)
R = cp-cv;# gas constant, [kJ/kg K]
Gama = cp/cv;# heat capacity ratio
# for process 1-2
V2 = V1/rv;# volume at stage2, [m^3]
# using PV^(Gama)=constant for process 1-2
P2 = P1*(V1/V2)**(Gama);# pressure at stage2,. [MN/m^2]
T2 = T1*(V1/V2)**(Gama-1);# temperature at stage 2, [K]
# for process 2-3
# since volumee is constant in process 2-3 , so using P/T=constant, so
T3 = T2*(P3/P2);# volume at stage 3, [K]
V3 = V2;# volume at stage 3, [MN/m^2]
# for process 3-4
P4 = P3;# pressure at stage 4, [m^3]
# since in stage 3-4 P is constant, so V/T=constant,
V4 = V3*(T4/T3);# temperature at stage 4,[K]
# for process 4-5
V5 = V1;# volume at stage 5, [m^3]
P5 = P4*(V4/V5)**(Gama);# pressure at stage5,. [MN/m^2]
T5 = T4*(V4/V5)**(Gama-1);# temperature at stage 5, [K]
print ' (a) P1 = ',P1,' kN/m^2, V1 = ',round(V1,3),' m^3, t1 = ',T1-273,' C,\n P2 = ',round(P2),' kN/m^2, V2 = ',round(V2,6),' m^3, t2 = ',round(T2-273),' C,\n P3 = ',round(P3),' kN/m^2, V3 = ',round(V3,6),' m^3, t3 = ',round(T3-273),' C,\n P4 = ',round(P4,1),' kN/m^2, V4 = ',round(V4,6),' m^3, t4 = ',round(T4-273),' C \n P5 = ',round(P5,1),' kN/m^2, V5 = ',round(V5,3),' m^3, t5 = ',round(T5-273),' C'
# (b)
W = (P3*(V4-V3)+((P4*V4-P5*V5)-(P2*V2-P1*V1))/(Gama-1))*10**3;# work done, [kJ]
print ' (b) The net work done is (kJ) = ',round(W,1)
# (c)
TE = 1-(T5-T1)/((T3-T2)+Gama*(T4-T3));# thermal efficiency
print ' (c) The thermal efficiency is (percent) = ',round(TE*100,1)
# (d)
Q = W/TE;# heat received, [kJ]
print ' (d) The heat received is (kJ) = ',round(Q,1)
# (e)
PW = P3*(V4-V3)+(P4*V4-P5*V5)/(Gama-1)
WR = W*10**-3/PW;# work ratio
print ' (f) The work ratio is = ',round(WR,3)
# (e)
Pm = W/(V1-V2);# mean effective pressure, [kN/m^2]
print ' (e) The mean effective pressure is (kN/m^2) = ',round(Pm,1)
# (f)
CE = (T4-T1)/T4;# carnot efficiency
print ' (f) The carnot efficiency is (percent) = ',round(CE*100)
# End
```

In [16]:

```
#pg 487
print('Example 15.14');
# aim : To determine
# (a) the thermal efficiency
# (b) the heat received
# (c) the heat rejected
# (d) the net work
# (e) the work ratio
# (f) the mean effective pressure
# (g) the carnot efficiency
# given values
P1 = 101.;# initial pressure , [kN/m**2]
V1 = 14.*10**-3;# initial volume, [m**3]
T1 = 273.+15;# initial temperature, [K]
P3 = 1850.;# maximum pressure, [kN/m**2]
V2 = 2.8*10**-3;# compressed volume, [m**3]
Gama = 1.4;# heat capacity
R = .29;# gas constant, [kJ/kg k]
# solution
# taking reference Fig. 15.29
# (a)
# for process 1-2
# using PV**(Gama)=constant for process 1-2
P2 = P1*(V1/V2)**(Gama);# pressure at stage2,. [MN/m**2]
T2 = T1*(V1/V2)**(Gama-1);# temperature at stage 2, [K]
# for process 2-3
# since volumee is constant in process 2-3 , so using P/T=constant, so
T3 = T2*(P3/P2);# volume at stage 3, [K]
# for process 3-4
P4 = P1;
T4 = T3*(P4/P3)**((Gama-1)/Gama);# temperature
TE = 1-Gama*(T4-T1)/(T3-T2);# thermal efficiency
print ' (a) The thermal efficiency is (percent) = ',round(TE*100,1)
# (b)
cv = R/(Gama-1);# heat capacity at copnstant volume, [kJ/kg k]
m = P1*V1/(R*T1);# mass of gas, [kg]
Q1 = m*cv*(T3-T2);# heat received, [kJ/cycle]
print ' (b) The heat received is (kJ/cycle) = ',round(Q1,2)
# (c)
cp = Gama*cv;# heat capacity at constant at constant pressure, [kJ/kg K]
Q2 = m*cp*(T4-T1);# heat rejected, [kJ/cycle]
print ' (c) The heat rejected is (kJ/cycle) = ',round(Q2,2)
# (d)
W = Q1-Q2;# net work , [kJ/cycle]
print ' (d) The net work is (kJ/cycle) = ',round(W,2)
# (e)
# pressure is constant for process 1-4, so V/T=constant
V4 = V1*(T4/T1);# volume, [m**3]
V3 = V2;# for process 2-3
P4 = P1;# for process 1-4
PW = (P3*V3-P1*V1)/(Gama-1);# positive work done, [kJ/cycle]
WR = W/PW;# work ratio
print ' (e) The work ratio is = ',round(WR,3)
# (f)
Pm = W/(V4-V2);# mean effective pressure, [kN/m**2]
print ' (f) The mean effefctive pressure is (kN/m^2) = ',round(Pm,2)
# (g)
CE = (T3-T1)/T3;# carnot efficiency
print ' (g) The carnot efficiency is (percent) = ',round(CE*100,1)
print 'there is minor variation in answer reported in the book due to rounding off error'
# End
```

In [17]:

```
#pg 492
print('Example 15.15');
# aim : To determine
# (a) the net work done
# (b) the ideal thermal efficiency
# (c) the thermal efficiency if the process of generation is not included
from math import log
# given values
P1 = 110.;# initial pressure, [kN/m^2)
T1 = 273.+30;# initial temperature, [K]
V1 = .05;# initial volume, [m^3]
V2 = .005;# volume, [m^3]
T3 = 273.+700;# temperature, [m^3]
R = .289;# gas constant, [kJ/kg K]
cv = .718;# heat capacity, [kJ/kg K]
# solution
# (a)
m = P1*V1/(R*T1);# mass , [kg]
W = m*R*(T3-T1)*log(V1/V2);# work done, [kJ]
print ' (a) The net work done is (kJ) = ',round(W)
# (b)
n_the = (T3-T1)/T3;# ideal thermal efficiency
print ' (b) The ideal thermal efficiency is (percent) = ',round(n_the*100,1)
# (c)
V4 = V1;
V3 = V2;
T4 = T3;
T2 = T1;
Q_rej = m*cv*(T4-T1)+m*R*T1*log(V1/V2);# heat rejected
Q_rec = m*cv*(T3-T2)+m*R*T3*log(V4/V3);# heat received
n_th = (1-Q_rej/Q_rec);# thermal efficiency
print ' (c) the thermal efficiency if the process of regeneration is not included is (percent) = ',round(n_th*100,1)
# End
```

In [18]:

```
#pg 493
print('Example 15.16');
from math import log
# aim : To determine
# (a) the maximum temperature
# (b) the net work done
# (c) the ideal thermal efficiency
# (d) the thermal efficiency if the process of regeneration is not included
# given values
P1 = 100.;# initial pressure, [kN/m^2)
T1 = 273.+20;# initial temperature, [K]
V1 = .08;# initial volume, [m^3]
rv = 5;# volume ratio
R = .287;# gas constant, [kJ/kg K]
cp = 1.006;# heat capacity, [kJ/kg K]
V3_by_V2 = 2;
# solution
# (a)
# using Fig.15.33
# process 1-2 is isothermal
T2 = T1;
# since process 2-3 isisobaric, so V/T=constant
T3 = T2*(V3_by_V2);# maximumtemperature, [K]
print ' (a) The maximum temperature is (C) = ',T3-273
# (b)
m = P1*V1/(R*T1);# mass , [kg]
W = m*R*(T3-T1)*log(rv);# work done, [kJ]
print ' (b) The net work done is (kJ) = ',round(W,2)
# (c)
TE = (T3-T1)/T3;# ideal thermal efficiency
print ' (c) The ideal thermal efficiency is (percent) = ',TE*100
# (d)
T4 = T3;
T2 = T1;
Q_rej = m*cp*(T4-T1)+m*R*T1*log(rv);# heat rejected
Q_rec = m*cp*(T3-T2)+m*R*T3*log(rv);# heat received
n_th = (1-Q_rej/Q_rec);# thermal efficiency
print ' (d) the thermal efficiency if the process of regeneration is not included is (percent) = ',round(n_th*100)
# End
```

In [19]:

```
#pg 495
print('Example 15.17');
# aim : To determine
# (a) the net work done
# (b) thethermal efficiency
from math import log
# given values
m = 1.;# mass of air, [kg]
T1 = 273.+230;# initial temperature, [K]
P1 = 3450.;# initial pressure, [kN/m^2]
P2 = 2000.;# pressure, [kN/m^2]
P3 = 140.;# pressure, [kN/m^2]
P4 = P3;
Gama = 1.4; # heat capacity ratio
cp = 1.006;# heat capacity, [kJ/kg k]
# solution
T2 =T1;# isothermal process 1-2
# process 2-3 and 1-4 are adiabatic so
T3 = T2*(P3/P2)**((Gama-1)/Gama);# temperature, [K]
T4 = T1*(P4/P1)**((Gama-1)/Gama);# [K]
R = cp*(Gama-1)/Gama;# gas constant, [kJ/kg K]
Q1 = m*R*T1*log(P1/P2);# heat received, [kJ]
Q2 = m*cp*(T3-T4);# heat rejected
#hence
W = Q1-Q2;# work done
print ' (a) The net work done is (kJ) = ',round(W,1)
# (b)
TE = 1-Q2/Q1;# thermal efficiency
print ' (b) The thermal efficiency is (percent) = ',round(TE*100,1)
# End
```

In [20]:

```
#pg 497
print('Example 15.18');
# aim : To determine
# thermal eficiency
# carnot efficiency
from math import log
# given values
rv = 5.;# volume ratio
Gama = 1.4;# heat capacity ratio
# solution
# under given condition
TE = 1-(1/Gama*(2-1/rv**(Gama-1)))/(1+2*((Gama-1)/Gama)*log(rv/2));# thermal efficiency
print ' The thermal efficiency is (percent) = ',round(TE*100)
CE = 1-1/(2*rv**(Gama-1));# carnot efficiency
print ' The carnot efficiency is = ',round(CE*100,1)
# End
```