In [1]:

```
import math
## Example 2.1
print('Example 2.1\n\n');
print('Page No. 44\n\n');
## given
C= 35000.;## cost of boiler
C_grant=.25;## Capital grant available from goverment
E= -(C-(C_grant*C));## Net expenditure
Fs= 15250.;## Fuel Saving
r_i = 0.15;## interest
r_t = 0.55;## tax
a = ([0, E ,Fs ,0 ,E+Fs, r_i*(E+Fs) ,0 ])
bal_1 = a[4]+a[5]-a[6]## Total Balance after 1st year
c_all = 0.55;## capital allowance in 2nd year
C_bal= (bal_1+0+Fs+(-(c_all*E)));## Cash Balance after 2nd year
b = ([bal_1 ,0 ,Fs ,-(c_all*E) ,C_bal, r_i*C_bal, r_t*(Fs+(r_i*C_bal))]);
bal_2 = b[4]+b[5]-b[6]##Total Balance after 2nd year
c = ([bal_2, 0 ,Fs ,0 ,bal_2+Fs ,r_i*(bal_2+Fs) ,r_t*(Fs+(r_i*(bal_2+Fs)))])
bal_3= c[4]+c[5]-c[6]## Total Balance after 3rd year
if(bal_2>0):
print('Pay back period is of two year')
else:
print('Pay back period is of three year')
print'%s %.2f %s'%('Total saving at the end of second year is ',bal_2,' Pound\n');
print'%s %.2f %s'%('Total saving at the end of third year is ',bal_3,' Pound\n');
## Deviation in answer due to direct substitution
```

In [2]:

```
import math
## Example 2.2
print('Example 2.2');
print('Page No. 45');
## given
C= 35000.;## cost of boiler
C_grant=0.;## Capital grant available from goverment
E= -(C-(C_grant*C));## Net expenditure
Fs= 15250.;## Fuel Saving
r_i = 0.15;## interest
r_t = 0.55;## tax
a = ([0, E ,Fs ,0, E+Fs, r_i*(E+Fs) ,0 ])
bal_1 = a[4]+a[5]-a[6]## Total Balance after 1st year
c_all = 0.55;## capital allowance in 2nd year
C_bal= (bal_1+0+Fs+(-(c_all*E)));## Cash Balance after 2nd year
b = ([bal_1 ,0 ,Fs ,-(c_all*E), C_bal ,r_i*C_bal, r_t*(Fs+(r_i*C_bal))]);
bal_2 = b[4]+b[5]-b[6]##Total Balance after 2nd year
c = ([bal_2, 0 ,Fs ,0 ,bal_2+Fs, r_i*(bal_2+Fs) ,r_t*(Fs+(r_i*(bal_2+Fs)))])
bal_3= c[4]+c[5]-c[6]## Total Balance after 3rd year
if(bal_2>0):
print('pay back period is of two year')
else:
print('pay back period is of three year')
print'%s %.2f %s'%('Total saving at the end of second year is ',bal_2,' Pound');
print'%s %.2f %s'%('Total saving at the end of third year is ',bal_3,' Pound');
## Deviation in answer due to direct substitution
```

In [3]:

```
import math
## Example 2.3
print('Example 2.3');
print('Page No. 46');
## given
F= 350*10**3.;## fuel oils in gallons
Ci= 5000.;## cost of insulation of tanks
As= 7500.;##Annual Saving in Pound
if(As> Ci):
print("The investment has a pay-back period of less than 1 year");
else:
print("The investment has not a pay-back period of less than 1 year");
## Note- Since here pack back period is less than 1 year and the company is in profit so they can go with this fuel oil,
## although it can be noted that there are more problems handling heavy fuels oils
##and that the pay-back increases considerably the smaller the installation.
##So the company can changeover from oil to coal as a fuel.
```

In [4]:

```
import math
## Example 2.4
print('Example 2.4');
print('Page No. 47');
## given
F1= 500.*10**3;## fuel oil in gallons
F2= 500.*10**3;## coal in gallons in Pound
C1= 165.*10**3;## cost of oil per year in Pound
C2= 92.*10**3;## cost of an equivalent of coal in Pound
Ce= 100.*10**3;## capital cost of extra handling eqiupment
Cm= (Ce*0.2);## Maintenance , interest costs per year
As= C1-C2;## Annual Saving in Pound
print'%s %.2f %s'%('Annual Saving is ',As,' Pound')
if((2*As)> Ce):
print("Replacing an obsolete boiler plant is considerable");
else:
print("Replacing an obsolete boiler plant is not considerble");
```

In [5]:

```
import math
## Example 2.5
print('Example 2.5\n\n');
print('Page No. 49\n\n');
## given
F= 10.*10**3;## fuel oils in gallons
Cs= 2200.;## cost of maintaining tanks per year in Pound
Ci= 1850.;## cost of insulation of pipe in Pound
As= (Cs*.85);##company saving is 85 per cent to the cost
print'%s %.2f %s'%('Annual Saving on heating is ',As,' Pound\n')
if(As> Ci):
print("The investment has a pay-back period of less than 1 year");
else:
print("The investment has not a pay-back period of less than 1 year");
```

In [6]:

```
import math
## Example 2.6
print('Example 2.6\n\n');
print('Page No. 52\n\n');
## given
P1= 50.;## Dry saturated steam pressure in bar
P2= 0.5;## condenser pressure in bar
##By using the steam tables saturation temperature is obtained at given pressures
T1= 537.##The saturation temperatue in K at 50 bar
T2= 306.##The saturation temperatue in K at 0.5 bar
## For Carnot Cycle
n=(1.-(T2/T1))*100.;
print'%s %.2f %s'%('Efficiency percentage of Carnot Cycle is ',n,' \n')
## For Rankine Cycle
## By usins steam tables, the total heat and the sensibles heat and other remaining parameter has been calculated
h1= 2794.*10**3;##the total heat in dry steam at 50 bar in J/kg
d= 0.655;## dryness fraction
h2= 1725.*10**3;## the entropy at state 2 in J/kg
h3= 138.*10**3;## the sensible heat at 0.5 bar in J/kg
Vf= 1.03*10**-3;## volume of fluid im m^3,calculated from steam table
W= (Vf*(P1-P2))*10**5;## pump work in J/kg
E=(((h1-h2)-(W))/((h1-h3)-(W)))*100.;
print'%s %.2f %s'%('Efficiency percentage of Rankine Cycle is ',E,' \n')
```