In [1]:

```
#pg 11
#calculate the work done
print 'Example 1.1'
# Given values
P = 700.; #pressure,[kN/m**2]
V1 = .28; #initial volume,[m**3]
V2 = 1.68; #final volume,[m**3]
#solution
W = P*(V2-V1);# # Formula for work done at constant pressure is, [kJ]
#results
print 'The Work done is (MJ) = ',W*10**-3
#End
```

In [2]:

```
#pg 13
#calculate the new volume
print 'Example 1.2'
#Given values
P1 = 138.; # initial pressure,[kN/m**2]
V1 = .112; #initial volume,[m**3]
P2 = 690; # final pressure,[kN/m**2]
Gama=1.4; # heat capacity ratio
# solution
# since gas is following, PV**1.4=constant,hence
V2 =V1*(P1/P2)**(1/Gama); # final volume, [m**3]
#results
print 'The new volume of the gas is (m^3) = ',round(V2,4)
#End
```

In [3]:

```
#pg 15
#calculate the work done by gas
print 'Example 1.3'
# Given values
P1 = 2070; # initial pressure, [kN/m^2]
V1 = .014; # initial volume, [m^3]
P2 = 207.; # final pressure, [kN/m^2]
n=1.35; # polytropic index
# solution
# since gas is following PV^n=constant
# hence
V2 = V1*(P1/P2)**(1/n); # final volume, [m^3]
# calculation of workdone
W=(P1*V1-P2*V2)/(1.35-1); # using work done formula for polytropic process, [kJ]
#results
print 'Final Volume (m^3) = ',round(V2,3)
print 'The Work done by gas during expansion is (kJ) = ',round(W,1)
#End
```

In [4]:

```
#pg 17
#calculate the final pressure and work done
print 'Example 1.4'
import math
# Given values
P1 = 100; # initial pressure, [kN/m^2]
V1 = .056; # initial volume, [m^3]
V2 = .007; # final volume, [m^3]
# To know P2
# since process is hyperbolic so, PV=constant
# hence
P2 = P1*V1/V2; # final pressure, [kN/m^2]
# calculation of workdone
W = P1*V1*math.log(V2/V1); # formula for work done in this process, [kJ]
#results
print ' The final pressure (kN/m^2) = ',P2
print ' Work done on the gas (kJ) = ',round(W,2)
#End
```

In [5]:

```
#pg 21
#calculate the heat required
print 'Example 1.5'
# Given values
m = 5.; # mass, [kg]
t1 = 15.; # inital temperature, [C]
t2 = 100.; # final temperature, [C]
c = 450.; # specific heat capacity, [J/kg K]
# solution
# using heat transfer equation,[1]
Q = m*c*(t2-t1); # [J]
#results
print 'The heat required (kJ) = ',round(Q*10**-3,2)
#End
```

In [7]:

```
#pg 22
print 'Example 1.6'
#Calculate the required heat transfer
# Given values
m_cop = 2.; # mass of copper vessel, [kg]
m_wat = 6.; # mass of water, [kg]
c_wat = 4.19; # specific heat capacity of water, [kJ/kg K]
t1 = 20.; # initial temperature, [C]
t2 = 90.; # final temperature, [C]
# From the table of average specific heat capacities
c_cop = .390; # specific heat capacity of copper,[kJ/kg k]
# solution
Q_cop = m_cop*c_cop*(t2-t1); # heat required by copper vessel, [kJ]
Q_wat = m_wat*c_wat*(t2-t1); # heat required by water, [kJ]
# since there is no heat loss,so total heat transfer is sum of both
Q_total = Q_cop+Q_wat ; # [kJ]
#results
print 'Required heat transfer to accomplish the change (kJ) = ',Q_total
#End
```

In [8]:

```
#pg 22
print('Example 1.7');
#calculate the final temperature
# Given values
m = 10.; # mass of iron casting, [kg]
t1 = 200.; # initial temperature, [C]
Q = -715.5; # [kJ], since heat is lost in this process
# From the table of average specific heat capacities
c = .50; # specific heat capacity of casting iron, [kJ/kg K]
# solution
# using heat equation
# Q = m*c*(t2-t1)
t2 = t1+Q/(m*c); # [C]
#results
print 'The final temperature is (C) = ',t2
# End
```

In [9]:

```
#pg 23
#calculate the specific heat capacity
print('Example 1.8');
# Given values
m = 4.; # mass of the liquid, [kg]
t1 = 15.; # initial temperature, [C]
t2 = 100.; # final temperature, [C]
Q = 714.; # [kJ],required heat to accomplish this change
# solution
# using heat equation
# Q=m*c*(t2-t1)
# calculation of c
c=Q/(m*(t2-t1)); # heat capacity, [kJ/kg K]
#results
print 'The specific heat capacity of the liquid is (kJ/kg K) = ',c
#End
```

In [10]:

```
#pg 27
#calculate the energy rejected by the engine
print('Example 1.9');
# Given values
m_dot = 20.4; # mass flowrate of petrol, [kg/h]
c = 43.; # calorific value of petrol, [MJ/kg]
n = .2; # Thermal efficiency of engine
# solution
m_dot = 20.4/3600; # [kg/s]
c = 43*10**6; # [J/kg]
# power output
P_out = n*m_dot*c; # [W]
# power rejected
P_rej = m_dot*c*(1-n); # [W]
P_rej = P_rej*60*10**-6; # [MJ/min]
#results
print 'The power output of the engine is (kJ) = ',round(P_out*10**-3,1)
print 'The energy rejected by the engine is (MJ/min) = ',round(P_rej,1)
#End
```

In [11]:

```
#pg 28
print('Example 1.10');
#calculate the thermal efficiency
# Given values
m_dot = 3.045; # use of coal, [tonne/h]
c = 28; # calorific value of the coal, [MJ/kg]
P_out = 4.1; # output of turbine, [MW]
# solution
m_dot = m_dot*10**3/3600; # [kg/s]
P_in = m_dot*c; # power input by coal, [MW]
n = P_out/P_in; # thermal efficiency formula
#results
print 'Thermal efficiency of the plant = ',round(n,3)
#End
```

In [13]:

```
#pg 29
#calculate the power output of the engine
print('Example 1.11');
# Given values
v = 50.; # speed, [km/h]
F = 900.; # Resistance to the motion of a car
# solution
v = v*10**3/3600; # [m/s]
Power = F*v; # Power formula, [W]
print 'The power output of the engine (kW) = ',Power*10**-3
# End
```

In [14]:

```
#pg 31
#calculate the power output from the engine
print('Example 1.12');
# Given values
V = 230.; # volatage, [volts]
I = 60.; # current, [amps]
n_gen = .95; # efficiency of generator
n_eng = .92; # efficiency of engine
# solution
P_gen = V*I; # Power delivered by generator, [W]
P_gen=P_gen*10**-3; # [kW]
P_in_eng=P_gen/n_gen;#Power input from engine,[kW]
P_out_eng=P_in_eng/n_eng;#Power output from engine,[kW]
#results
print 'The power output from the engine (kW) = ',round(P_out_eng,2)
# End
```

In [15]:

```
#pg 32
#calculate the current taken by heater
print('Example 1.13');
# Given values
V = 230.; # Voltage, [volts]
W = 4.; # Power of heater, [kW]
# solution
# using equation P=VI
I = W/V; # current, [K amps]
#results
print 'The current taken by heater (amps) = ',round(I*10**3,1)
# End
```

In [16]:

```
#pg 32
#calculate the mass of coal burnt
print('Example 1.14');
# Given values
P_out = 500.; # output of power station, [MW]
c = 29.5; # calorific value of coal, [MJ/kg]
r=.28;
# solution
# since P represents only 28 percent of energy available from coal
P_coal = P_out/r; # [MW]
m_coal = P_coal/c; # Mass of coal used, [kg/s]
m_coal = m_coal*3600; # [kg/h]
#After one hour
m_coal = m_coal*1*10**-3; # [tonne]
#results
print 'Mass of coal burnt by the power station in 1 hour (tonne) = ',round(m_coal,0)
# End
```