In [1]:

```
# Given:-
T = 373.15 # temperature in kelvin
# From table A-2
p = 1.014*(10**5) # pressure in pascal
vg = 1.673
vf = 1.0435e-3
sg = 7.3549
sf = 1.3069
# Calculations
w = p*(vg-vf)*(10**(-3))
Q = T*(sg-sf)
# Results
print '-> The work per unit mass is',round(w,3),'KJ/kg.'
print '-> The heat transfer per unit mass is ',round(Q,2),'KJ/kg.'
```

In [2]:

```
# Given:-
# Assumptions:
"""
1. The water in the pistonâ€“cylinder assembly is a closed system.
2. There is no heat transfer with the surroundings.
3. The system is at an equilibrium state initially and finally. There is no
change in kinetic or potential energy between these two states."""
# From table A-2 at 100 degree celcius
ug = 2506.5 # in kj/kg
uf = 418.94 # in kj/kg
sg = 7.3549
sf = 1.3069
# Calculations:-
# From energy balance
W = -(ug-uf)
# From entropy balance
sigmabym = (sg-sf)
# Results
print '-> The net work per unit mass is ',round(W,2),'KJ/kg.'
print '-> The amount of entropy produced per unit mass is ',round(sigmabym,2),'kJ/kg.k.'
```

In [3]:

```
# Given:-
T1 = 273.0 # initial temperature of saturated vapor in kelvin
P2 = 0.7*(10**6) # final pressure in pascal
# From table A-10,
u1 = 227.06 # in kj/kg
# minimum theoretical work corresponds to state of isentropic compression
# From table A-12,
u2s = 244.32 # in kj/kg
# Calculations
Wmin = u2s-u1
# Results
print '-> The minimum theoretical work input required per unit mass of refrigerant is: ',round(Wmin,2),'kJ/kg.'
```

In [4]:

```
# Given :-
Qdot = -1.2 # in kilo watt
Tb = 300.0 # in kelvin
Tf = 293.0 # in kelvin
# Calculations
# Part (a)
# From entropy balance
sigmadot = -Qdot/Tb
# Part(b)
# From entropy balance
sigmadt = -Qdot/Tf
# Results
print '-> The rate of entropy production with gearbox as system is ',round(sigmadot,5),'kw/k.'
print '-> The rate of entropy production with gearbox + sorrounding as system is',round(sigmadt,5),'kw/k.'
```

In [5]:

```
# GIven:-
Tmi = 1200.0 # initial temperature of metal in kelvin
cm = 0.42 # specific heat of metal in KJ/kg.k
mm = 0.3 # mass of metal in kg
Twi = 300.0 # initial temperature of water in kelvin
cw = 4.2 # specific heat of water in KJ/Kg.k
mw = 9.0 # mass of water in kg
# Calculations
import math
# Part(a)
# Solving energy balance equation yields
Tf = (mw*(cw/cm)*Twi+mm*Tmi)/(mw*(cw/cm)+mm)
# Part (b)
# Solving entropy balance equation yields
sigma = mw*cw*math.log(Tf/Twi)+mm*cm*math.log(Tf/Tmi)
# Results
print '-> The final equilibrium temperature of the metal bar and the water is',round(Tf,2),' kelvin.'
print '-> The amount of entropy produced is:',round(sigma,2),'kJ/k.'
```

In [6]:

```
# Given:-
P1 = 30.0 # pressure of steam entering the turbine in bar
T1 = 400.0 # temperature of steam entering the turbine in degree celcius
V1 = 160.0 # velocity of steam entering the turbine in m/s
T2 = 100.0 # temperature of steam exiting in degree celcius
V2 = 100.0 # velocity of steam exiting in m/s
Wcvdot = 540.0 # work produced by turbine in kJ/kg of steam
Tb = 350.0 # temperature of the boundary in kelvin
# From table A-4 and table A-2
h1 = 3230.9 # specific enthalpy at entry in Kj/kg
h2 = 2676.1 # specific enthalpy at exit in kj/kg
# Calculations
# Reduction in mass and energy balance equations results in
Qcvdot = Wcvdot + (h2 - h1)+ (V2**2-V1**2)/(2*(10**3)) # heat transfer rate
# From table A-2
s2 = 7.3549 # in kj/kg.k
# From table A-4
s1 = 6.9212 # in kj/kg.k
# From entropy and mass balance equations
sigmadot = -(Qcvdot/Tb) + (s2-s1)
# Results
print '-> The rate at which entropy is produced within the turbine per kg of steam flowing is',round(sigmadot,2),'kJ/kg.k.'
```

In [7]:

```
# Given:-
T1 = 294.0 # entry temperature of air in kelvin
P1 = 5.1 # entry pressure of air in bars
T2 = 352.0 # exit temperature of hot stream in kelvin
P2 = 1.0 # exit pressure of hot stream in bars
T3 = 255.0 # exit temperature of cold stream in kelvin
P3 = 1.0 # exit pressure of cold stream in bars
cp = 1.0 # in kj/kg.k
# Calculations
import math
R = 8.314/28.97
se = 0.4*(cp*math.log((T2)/(T1))-R*math.log(P2/P1)) + 0.6*(cp*math.log((T3)/(T1))-R*math.log(P3/P1))
# specific entropy in kj/kg.k
# Results
print '-> Specific entropy in kj/kg.k = ',round(se,3),' KJ/kg.'
print '-> Since se > 0, the claim of the writer is true'
```

In [8]:

```
# Given:-
P1 = 3.5 # pressure of refrigerant entering the compressor in bars
T1 = 268.0 # temperature of refrigerant entering the compressor in kelvin
P2 = 14.0 # pressure of refrigerant entering the condenser in bars
T2 = 348.0 # temperature of refrigerant entering the condenser in kelvin
P3 = 14.0 # pressure of refrigerant exiting the condenser in bars
T3 = 301.0 # temperature of refrigerant exiting the condenser in kelvin
P4 = 3.5 # pressure of refrigerant after passing through expansion valve in bars
P5 = 1.0 # pressure of indoor return air entering the condenser in bars
T5 = 293.0 # temperature of indoor return air entering the condenser in kelvin
AV5 = 0.42 # volumetric flow rate of indoor return air entering the condenser in m^3/s
P6 = 1.0 # pressure of return air exiting the condenser in bar
T6 = 323.0 # temperature of return air exiting the condenser in kelvin
# Part(a)
# From table A-9
s1 = 0.9572 # in kj/kg.k
# Interpolating in table A-9
s2 = 0.98225 # in kj/kg.k
h2 = 294.17 # in kj/kg
# From table A-7
s3 = 0.2936 # in kj/kg.k
h3 = 79.05 # in kj/kg
h4 = h3 # since expansion through valve is throttling process
# From table A-8
hf4 = 33.09 # in kj/kg
hg4 = 246.00 # in kj/kg
sf4 = 0.1328 # in kj/kg.k
sg4 = 0.9431 # in kj/kg.k
cp = 1.005 # in kj/kg.k
# Calculations
import math
x4 = (h4-hf4)/(hg4-hf4) # quality at state 4
s4 = sf4 + x4*(sg4-sf4) # specific entropy at state 4
# CONDENSER!!
v5 = ((8314/28.97)*T5)/(P5*(10**5)) # specific volume at state 5
mairdot = AV5/v5
h6 = cp*T6
h5 = cp*T5
mrefdot = mairdot*(h6-h5)/(h2-h3)
deltaS65 = cp*math.log(T6/T5)-(8.314/28.97)*math.log(P6/P5) # change in specific entropy
sigmacond = (mrefdot*(s3-s2)) + (mairdot*(deltaS65))
# COMPRESSOR!!
sigmacomp = mrefdot*(s2-s1)
# VALVE!!
sigmavalve = mrefdot *(s4-s3)
# Results
print '-> The rates of entropy production for control volume enclosing the condenser is ',sigmacond,'kW/K.'
print '-> The rates of entropy production for control volume enclosing the compressor is ',sigmacomp,'kW/K.'
print '-> The rates of entropy production for control volume enclosing the expansion valve is ',sigmavalve,'kW/K.'
```

In [9]:

```
# Given:-
P1 = 1.00 # initial pressure in bar
T1 = 300.00 # initial temperature in kelvin
T2 = 650.00 # final temperature in kelvin
# Part(a)
# From table A-22
pr2 = 21.86
pr1 = 1.3860
k = 1.39 # From table A-20
# Calculations
p2 = P1*(pr2/pr1)
p2a = P1*((T2/T1)**(k/(k-1)))
# Results
print '-> P2 = ',p2,'bar.'
print '-> Part(b) IT software problem'
print '-> P2a = ',p2a,'bar.'
```

In [10]:

```
# Given:-
m1 = 5.00 # initial mass in kg
P1 = 5.00 # initial pressure in bar
T1 = 500.00 # initial temperature in kelvin
P2 = 1.00 # final pressure in bar
# From table A-22
pr1 = 8.411
# Using this value of pr2 and interpolation in table A-22
T2 = 317.00 # in kelvin
# Calculations
pr2 = (P2/P1)*pr1
m2 = (P2/P1)*(T1/T2)*m1
# Results
print '-> The amount of mass remaining in the tank is ',m2,'kg.'
print 'and its temperature is ',T2,'kelvin.'
```

In [11]:

```
# Given:-
P1 = 1.00 # inlet pressure in bar
T1 = 593.00 # inlet temperature in kelvin
P2 = 1.00 # exit pressure in bar
eta =0.75 # turbine efficiency
# From table A-4
h1 = 3105.6 # in Kj/kg
s1 = 7.5308 # in kj/kg.k
# From table A-4 at 1 bar
h2s = 2743.00 # in kj/kg
# Calculations
w = eta*(h1 - h2s)
# Result
print '-> The work developed per unit mass of steam flowing through is ',w,'kJ/kg.'
```

In [12]:

```
# Given:-
P1 = 3.00 # pressure of air entering in bar
T1 = 390.00 # temperature of air entering in kelvin
P2 = 1.00 # pressure of exit air
Wcvdot = 74.00 # work developed in kj/kg
# From table A-22,at 390k
h1 = 390.88 # in kj/kg
pr1 = 3.481
# From interpolation table A-22
h2s = 285.27 # in kj/kg
# calculations
pr2 = (P2/P1)*pr1
Wcvdots = h1 - h2s
eta = Wcvdot/Wcvdots
# Result
print '-> The turbine efficiency is ',round(eta,4),'.'
```

In [13]:

```
# Given:-
P1 = 1.00 # pressure of entering steam in Mpa
T1 = 593.00 # temperature of entering steam in kelvin
V1 = 30.00 # velocity of entering steam in m/s
P2 = 0.3 # pressure of exit steam in Mpa
T2 = 453.00 # temperature of exit steam in kelvin
# From table A-4, at T1 = 593 kelvin and P1 = 1 Mpa;
# and at T2 = 453 kelvin and P2 = .3 Mpa
h1 = 3093.9 # in kj/kg
s1 = 7.1962 # in kj/kg.k
h2 = 2823.9 # in kj/kg
# Interpolating in table A-4
h2s = 2813.3 # in kj/kg
# Calculations
V2squareby2 = h1 - h2 + (V1**2)/2000
V2squareby2s = h1 - h2s + (V1**2)/2000
eta = V2squareby2/V2squareby2s
# Results
print '-> The nozzle efficiency is ',round(eta,4),'.'
```

In [14]:

```
# Given:-
# From table A-9
h1 = 249.75 # in kj/kg
h2 = 294.17 # in kj/kg
mdot = 0.07 # in kg/s
# From table A-9
s1 = 0.9572 # in Kj/Kg.k
h2s = 285.58 # in kj/kg
# Calculations
wcvdot = -(mdot*(h2-h1))
eta = (h2s-h1)/(h2-h1)
# Results
print '-> The power in is',wcvdot,'KW.'
print '-> The isentropic efficiency is ',round(eta,3),'.'
```

In [15]:

```
# Given:-
P1 = 1.00 # pressure of entering air in bar
T1 = 293.00 # temperature of entering air in kelvin
P2 = 5.00 # pressure of exit air in bar
n = 1.3
R = 8.314/28.97
# From table A-22
h1 = 293.17 # in kj/kg
h2 = 426.35 # in kj/kg
# Calculations
T2 = T1*((P2/P1)**((n-1)/n)) # in kelvin
wcvdot=((n*R)/(n-1))*(T1-T2) # in kj/kg
Qcvdot= wcvdot + (h2-h1) # in kj/kg
# Results
print '-> The work per unit mass passing through the device is',round(wcvdot,2),'kJ/kg.'
print '-> The heat transfer per unit mass is ',round(Qcvdot,2),'kJ/kg.'
```