Chapter 07: Entropy

Ex7.1:pg-191

In [12]:
import math
T1 = 37.0 # Final water temperature in degree Celsius 
T2 = 35.0 # Initial water temperature in degree Celsius 
m = 1.0  # Mass of water in kg
cv = 4.187 # Specific heat capacity of water in kJ/kgK
print "\n Example 7.1"
S = m*cv*math.log((T1+273)/(T2+273))  # Change in entropy of the water
print "\n Change in entropy of the water is ",round(S,4) ," kJ/K"
#The answer provided in the textbook is wrong
 Example 7.1

 Change in entropy of the water is  0.0271  kJ/K

Ex7.2:pg-192

In [1]:
import math
# Part (a)
T1 = 273 # Initial temperature of water in Kelvin
T2 = 373 # Temperature of heat reservoir in Kelvin
m = 1 # Mass of water in kg
cv = 4.187 # Specific heat capacity of water

print "\n Example 7.2"
Ss = m*cv*math.log(T2/T1) # entropy change of water
Q = m*cv*(T2-T1) # Heat transfer 
Sr = -(Q/T2) # Entropy change of universe
S = Ss+Sr # Total entropy change

print "\n The entropy change of the universe is ",S ," kJ/K"

# Part (b)
T3 = 323 # Temperature of intermediate reservoir in K
Sw = m*cv*(math.log(T3/T1)+math.log(T2/T3)) # entropy change of water
Sr1 = -m*cv*(T3-T1)/T3 # Entropy change of universe
Sr2 = -m*cv*(T2-T3)/T2 # Entropy change of universe
Su = Sw+Sr1+Sr2 # Total entropy change
print "\n The entropy change of the universe is ",Su ," kJ/K"
#The answers vary due to round off error
 Example 7.2

 The entropy change of the universe is  -1.12252010724  kJ/K

 The entropy change of the universe is  -1.20940246848  kJ/K

Ex7.3:pg-193

In [2]:
import math
m = 1 # Mass of ice in kg

T1 = -5 # Initial temperature of ice in degree Celsius

T2 = 20# Atmospheric temperature in degree Celsius

T0 = 0# Phase change temperature of ice in degree Celsius

cp = 2.093 # Specific heat capacity of ice in kJ/kgK

cv = 4.187 # Specific heat capacity of water in kJ/kgK

lf = 333.3 # Latent heat of fusion in kJ/kgK



print "\n Example 7.3"

Q = m*cp*(T0-T1)+1*333.3+m*cv*(T2-T0) # Net heat transfer

Sa = -Q/(T2+273) # Entropy change of surrounding

Ss1 = m*cp*math.log((T0+273)/(T1+273)) # entropy change during 

Ss2 = lf/(T0+273) # Entropy change during phase change

Ss3 = m*cv*math.log((T2+273)/(T0+273)) # entropy change of water

St = Ss1+Ss2+Ss3 # total entropy change of ice to convert into water at atmospheric temperature

Su = St+Sa # Net entropy change of universe

print "\n The entropy change of the universe is ",Su ," kJ/K"



#The answer provided in the textbook is wrong

# Part (b)

S = St  # Entropy change of system

Wmin = (T2+273)*(S)-Q # minimum work required

print "\n The minimum work required is ",Wmin ," kJ"

#The answers vary due to round off error
 Example 7.3

 The entropy change of the universe is  -0.238182312568  kJ/K

 The minimum work required is  -69.7874175824  kJ

Ex7.7:pg-200

In [4]:
import math
P1 = 0.5 # Initial pressure in MPa

V1 = 0.2  # Initial volume in m**3

V2 = 0.05 # Final volume in m**3

n = 1.3 # Polytropic index



from scipy import integrate 

print "\n Example 7.7"

P2 = P1*(V1/V2)**n 

def f(p):
    y = ((P1*V1**n)/p)**(1/n) 
    return y
    

    
H, err = integrate.quad(f,P1,P2)   # H = H2-H1

U = H-(P2*V2-P1*V1) 
    
W12 = -U 
    
print "\n Change in enthalpy is ",round(H*1e3,2)," kJ"
    
print "\n Change in internal energy is ",round(U*1000,2)," kJ"
    
print "\n The change in entropy and heat transfer are is ",0 ," kJ"
    
print "\n The work transfer during the process is ",round(W12*1000,2) ," kJ"
    
    #The answers vary due to round off error
    
    
 Example 7.7

 Change in enthalpy is  223.48  kJ

 Change in internal energy is  171.91  kJ

 The change in entropy and heat transfer are is  0  kJ

 The work transfer during the process is  -171.91  kJ

Ex7.8:pg-201

In [3]:
import math
from scipy import integrate 


Pa = 130.0 # Pressure at station A in kPa

Pb = 100.0# Pressure at station B in kPa

Ta = 50.0 # Temperature at station A in degree Celsius

Tb = 13.0# Temperature at station B in degree Celsius

cp = 1.005  # Specific heat capacity of air in kJ/kgK

x= lambda t:cp/t
y= lambda p:0.287/p

print "\n Example 7.8"

Sb,error = integrate.quad(x,Ta,Tb)#-
Sa,eror=integrate.quad(y,Pa,Pb) 

Ss=Sb-Sa
Ssur=0 
Su = Ss+Ssur

print "\n Change in the entropy of the universe is ",Su ," kJ/Kg K"

#The answers given in the book is wrong

print "\n As the change in entropy of the universe in the process A-B is negative \n so the flow must be from B-A"
 Example 7.8

 Change in the entropy of the universe is  -1.2785104723  kJ/Kg K

 As the change in entropy of the universe in the process A-B is negative 
 so the flow must be from B-A

Ex7.9:pg-202

In [5]:
import math
T1 = 300.0  # Inlet temperature of air in K

T2 = 330.0  # Exit temperature of first air stream in K

T3 = 270.0 # Exit temperature of second air stream in K

P1 = 4.0  # Pressure of inlet air stream in bar

P2 =1.0   # Pressure of first exit air stream in bar

P3 =1.0  # Pressure of second exit air stream in bar

cp = 1.0005  # Specific heat capacity of air in kJ/kgK

R = 0.287 # Gas constant



print "\n Example 7.9"

S21 = cp*math.log(T2/T1)-R*math.log(P2/P1)  # Entropy generation

S31 = cp*math.log(T3/T1)-R*math.log(P3/P1) # Entropy generation

Sgen = (1.0*S21) + (1.0*S31) # Total entropy generation

print "\n The entropy generated during the process is ",Sgen ," kW/K"

#The answers vary due to round off error



print "\n As the entropy generated is positive so such device is possible"
 Example 7.9

 The entropy generated during the process is  0.785677602261  kW/K

 As the entropy generated is positive so such device is possible

Ex7.10:pg-203

In [6]:
import math
A = 5*7 # Area of wall in m**2
k = 0.71# Thermal conductivity in W/mK 
L = 0.32 # Thickness of wall in m
Ti = 21 # Room temperature in degree Celsius 
To = 6 # Surrounding temperature in degree Celsius
print "\n Example 7.10"
Q = k*A*(Ti-To)/L  # Heat transfer
Sgen_wall = Q/(To+273) - Q/(Ti+273)  # Entropy generation in wall
print "\n The rate of heat transfer through the wall is ",Q ," W"
print "\n The rate of entropy through the wall is ",Sgen_wall ," W/K"
Tr = 27 # Inner surface temperature of wall in degree Celsius 
Ts = 2 # Outer surface temperature of wall in degree Celsius 
Sgen_total = Q/(Ts+273)-Q/(Tr+273) # Total entropy generation in process 
print "\n The rate of total entropy generation with this heat transfer process is ",Sgen_total ," W/K"
 Example 7.10

 The rate of heat transfer through the wall is  1164.84375  W

 The rate of entropy through the wall is  0.213013632873  W/K

 The rate of total entropy generation with this heat transfer process is  0.352982954545  W/K