In [1]:

```
print 'Example 2.1'
#calculate the Change in total energy
# Given values
Q = 2500; # Heat transferred into the system, [kJ]
W = 1400; # Work transferred from the system, [kJ]
# solution
# since process carried out on a closed system, so using equation [4]
del_E = Q-W; # Change in total energy, [kJ]
# results
print 'The Change in total energy is, del_E (kJ) = ',del_E
if del_E >= 0:
print 'Since del_E is positive, so there is an increase in total energy'
else:
print 'Since del_E is negative, so there is an decrease in total energy'
print "There is mistake in the book's results unit"
# End
```

In [2]:

```
print 'Example 2.2'
#calculate the heat transfer
# Given values
del_E = 3500.; # Increase in total energy of the system, [kJ]
W = -4200.; # Work transfer into the system, [kJ]
# solution
# since process carried out on a closed system, so using equation [3]
Q = del_E+W;# [kJ]
# results
print 'The Heat transfer is, Q (kJ) = ',Q
if Q >=0:
print 'Since Q > 0, so heat is transferred into the system'
else:
print 'Since Q < 0, so heat is transferred from the system'
# End
```

In [4]:

```
print 'Example 2.3'
#calculate the Work done
# Given values
Q = -150; # Heat transferred out of the system, [kJ/kg]
del_u = -400; # Internal energy decreased ,[kJ/kg]
# solution
# using equation [3],the non flow energy equation
# Q=del_u+W
W = Q-del_u; # [kJ/kg]
# results
print 'The Work done is, W (kJ/kg) = ',W
if W >=0:
print 'Since W > 0, so Work done by the engine per kilogram of working substance'
else:
print 'Since W < 0, so Work done on the engine per kilogram of working substance'
# End
```

In [7]:

```
print 'Example 2.4'
#calculate the power output and workdone
# Given values
m_dot = 4.; # fluid flow rate, [kg/s]
Q = -40.; # Heat loss to the surrounding, [kJ/kg]
# At inlet
P1 = 600.; # pressure ,[kn/m**2]
C1 = 220.; # velocity ,[m/s]
u1 = 2200.; # internal energy, [kJ/kg]
v1 = .42; # specific volume, [m**3/kg]
# At outlet
P2 = 150.; # pressure, [kN/m**2]
C2 = 145.; # velocity, [m/s]
u2 = 1650.; # internal energy, [kJ/kg]
v2 = 1.5; # specific volume, [m**3/kg]
# solution
# for steady flow energy equation for the open system is given by
# u1+P1*v1+C1**2/2+Q=u2+P2*v2+C2**2/2+W
# hence
W = (u1-u2)+(P1*v1-P2*v2)+(C1**2/2-C2**2/2)*10**-3+Q; # [kJ/kg]
P_out = W*m_dot; # power out put from the system, [kW]
# results
print 'workdone is, W (kJ/kg) = ',W
if W >= 0:
print 'Since W>0, so Power is output from the system'
else:
print 'Since W<0, so Power is input to the system'
# Hence
print 'The power output from the system is (kW) = ',P_out
# End
```

In [1]:

```
print 'Example 2.5'
#calculate the temperature rise
# Given values
del_P = 154.45; # pressure difference across the die, [MN/m**2]
rho = 11360.; # Density of the lead, [kg/m**3]
c = 130; # specific heat capacity of the lead, [J/kg*K]
# solution
# since there is no cooling and no externel work is done, so energy balane becomes
# P1*V1+U1=P2*V2+U2 ,so
# del_U=U2-U1=P1*V1-P2*V2
# also, for temperature rise, del_U=m*c*t, where, m is mass; c is specific heat capacity; and t is temperature rise
# Also given that lead is incompressible, so V1=V2=V and assuming one m**3 of lead
# using above equations
t = del_P/(rho*c)*10**6 ;# temperature rise [C]
# results
print 'The temperature rise of the lead is (C) = ',round(t,1)
# End
```

In [9]:

```
print 'Example 2.6'
#calculate the power developed, exit velocity and inlet area
# Given values
m_dot = 4.5; # mass flow rate of air, [kg/s]
Q = -40.; # Heat transfer loss, [kJ/kg]
del_h = -200.; # specific enthalpy reduce, [kJ/kg]
C1 = 90; # inlet velocity, [m/s]
v1 = .85; # inlet specific volume, [m**3/kg]
v2 = 1.45; # exit specific volume, [m**3/kg]
A2 = .038; # exit area of turbine, [m**2]
# solution
# part (a)
# At inlet, by equation[4], m_dot=A1*C1/v1
A1 = m_dot*v1/C1;#inlet area, [m**2]
print '(a) The inlet area is, A1 (m^2) = ',A1
# part (b),
# At outlet, since mass flow rate is same, so m_dot=A2*C2/v2, hence
C2 = m_dot*v2/A2; # Exit velocity,[m/s]
print '(b) The exit velocity is, C2 (m/s) = ',round(C2,2)
# part (c)
# using steady flow equation, h1+C1**2/2+Q=h2+C2**2/2+W
W = -del_h+(C1**2/2-C2**2/2)*10**-3+Q; # [kJ/kg]
# Hence power developed is
P = W*m_dot;# [kW]
print '(c) The power developed by the turbine system is (kW) = ',round(P,2)
# End
```