# Chapter 7: USING ENTROPY

## Example 7.01, page: 149

In :
from __future__ import division
import math

# Initialization  of  Variable
T1 = 100 #degC

#calculations:
#from Table T-2
vg = 1.673 #m3/kg
vf = 1.0435E-3 #m3/kg
P = 1.014 #bar
#Work done per unit mass
Wm = P*(vg - vf)*100

#from Table T-2
sg = 7.3549 #kJ/kg-K
sf = 1.3069 #kJ/kg-K
T = T1 + 273.15
#Heat per unit mass
Qm = T*(sg-sf)

P=1.014;
vg=1.673;
vf=1.0435/1000;
T=373.15#temperature
sg=7.3549;
sf=1.3069;
k=P*(vg-vf)*10**5/1000;

#Results
print  "the work and heat transfer per unit mass are", Wm,"kJ/kg and", Qm,"kJ/kg respectively"

the work and heat transfer per unit mass are 169.5363891 kJ/kg and 2256.8112 kJ/kg respectively


## Example 7.02, page: 154

In :
from __future__ import division
import math

# Initialization  of  Variable
T1 = 100 #degC

#calculations:
#from table T-2
ug = 2506.5 #kJ/kg
uf = 418.94 #kJ/kg
#Work per unit mass
Wm = -1*(ug-uf)

#from table T-2
sg = 7.3549#kJ/kg-K
sf = 1.3069#kJ/kg-K
#entropy per unit mass
Sm = sg - sf

#Results
print  "the net work per unit mass is", round(Wm,2),"kJ/kg and the entropy produced per unit mass is",round(Sm,3),"kJ/kg-K"

the net work per unit mass is -2087.56 kJ/kg and the entropy produced per unit mass is 6.048 kJ/kg-K


## Example 7.03, page: 156

In :
from __future__ import division
import math

# Initialization  of  Variable
T = 10 #degF
P = 120 #lbf/in2

#calculations:
#from table T-6E
u1 = 94.68 #Btu/lb
u2s = 107.46 #Btu/lb
#minimum work input
Wmmin = u2s - u1

#Results
print  "the minimum theoretical work input required per unit of mass is", round(Wmmin,2),"Btu/lb"

the minimum theoretical work input required per unit of mass is 12.78 Btu/lb


## Example 7.04, page: 156

In :
from __future__ import division
import math

# Initialization  of  Variable
Tf = 293 #K
h = -0.171;
A = 1;
Tb = 300#temperature

#calculations:
W1dot = -60.0
Qdot = h*A*(Tb-Tf)
W2dot = Qdot-W1dot
#entropy rate
Sdot1 = -1*Qdot/Tb

#entropy rate
Sdot2 = -1*Qdot/Tf

#Results
print  "a) the rate of entropy production for 1st system is", round(Sdot1,3),"kW/K"
print  "b) the rate of entropy production for 2nd system is", round(Sdot2,4),"kW/K"

a) the rate of entropy production for 1st system is 0.004 kW/K
b) the rate of entropy production for 2nd system is 0.0041 kW/K


## Example 7.05, page: 159

In :
from __future__ import division
import math

# Initialization  of  Variable
P1 = 30 #bar
T1 = 400 #degC
V1 = 160 #m/s
T2 = 100 #degC
V2 = 100 #m/s
Tb = 350 #K
Wmdot  = 540 #kJ/kg

#calculations:
#from Table T-4
h1 = 3230.9 #kJ/kg
#from Table T-2
h2 = 2676.1 #kJ/kg
#heat tranfer rate
Qmdot = Wmdot + (h2 - h1) + (V2**2 - V1**2)/2000

#from Table T-4
s1 = 6.9212 #kJ/kg-K
#from Table T-2
s2 = 7.3549 #kJ/kg-K
#Entropy rate
Smdot = Qmdot/Tb + (s2 - s1)

#Results
print  "heat tranfer rate is", round(Qmdot,1),"kJ/kg"
print  "Entropy rate is", round(Smdot,4),"kJ/kg-K"
#answer wrong in book

heat tranfer rate is -22.6 kJ/kg
Entropy rate is 0.3691 kJ/kg-K


## Example 7.06, page: 160

In :
from __future__ import division
import math

# Initialization  of  Variable
T1 = 70 #degF
P1 = 5.1 #atm
P2 = 1 #atm
T2 = 175 #degF
T3 = 0 #degF
P3 = 1 #atm
R = 1.986/29.87 #Btu/lb-degR

#calculations:
m1dot = 1
m2dot = 0.4
m3dot = 0.6

#temps in Rankine
T1r = ((T1-32)*5/9 + 273)*1.8
T2r = ((T2-32)*5/9 + 273)*1.8
T3r = ((T3-32)*5/9 + 273)*1.8
#assumptions
Wdot = 0
Qdot = 0
Cp = 0.24  #Btu/lb-degR
#
h1 = Cp*T1r
h2 = Cp*T2r
h3 = Cp*T3r
#Sa = s2 - s1 and Sb = s3 - s1
Sa = Cp*math.log(T2r/T1r) - R*math.log(P2/P1)
Sb = Cp*math.log(T3r/T1r) - R*math.log(P3/P1)
#
a = m2dot*Cp*(T1 - T2) + m3dot*Cp*(T1 - T3)
#Specific Enthalpy
Sm1dot = m2dot*Sa + m3dot*Sb

#Results
if (a == 0):
print "a)with the given data the conservation of mass and energy principles are satisfied."
else:
print "a)with the given data the conservation of mass and energy principles are not satisfied."
print "b)changes in specific entropy are", round(Sm1dot,4)," Btu/lb-degR, thus  second  law  of  thermodynamics  is  also  conserved"

a)with the given data the conservation of mass and energy principles are satisfied.
b)changes in specific entropy are 0.1053  Btu/lb-degR, thus  second  law  of  thermodynamics  is  also  conserved


## Example 7.07, page: 162

In :
from __future__ import division
import math

# Initialization  of  Variable
T1 = -5 #degC
P1 = 3.5 #bar
T2 = 75 #degC
P2 = 14 #bar
P3 = 14 #Bar
T3 = 28 #degC
P4 = 3.5 #bar
T5 = 20 #degC
P5 = 1 #bar
AV5 = 0.42 #m3/s
T6 = 50 #degC
P6 = 1 #bar
R = 8.314/28.97 #kJ/kg-K

#calculations:
Cp = 1.005 #kJ/kg-K
#from Table T-14,
s1 = 0.9572 #kJ/kg-K
s2 = 0.98225 #kJ/kg-K
h2 = 294.17 #kJ/kg
#from Table T-12
s3 = 0.2936 #kJ/kg-K
h3 = 79.05 #kJ/kg
#From Table T-14
h4 = h3
hf4 = 33.09 #kJ/kg
hfg4 = 212.91 #kJ/kg
sf4 = 0.1328 #kJ/kg-K
sg4 = 0.9431 #kJ/kg-K
#Quality at 4
x4 = (h4 - hf4)/hfg4
#Specific Entropy at 4
s4 = sf4 + x4*(sg4 - sf4)

#mass flow rate of air
mairdot = AV5*P5*100/(R*(T5 + 273))
#ref mass rate
mrefdot = mairdot*Cp*(T6 - T5)/(h2 - h3)
#change in specific entropy
s6_s5 = Cp*math.log((T6 + 273)/(T5 + 273)) - R*math.log(P6/P5)
#entropy balance for condensor
Sdotcond = mrefdot*(s3 - s2) + mairdot*s6_s5
#entropy balance for Compressor
Sdotcomp = mrefdot*(s2-s1)
#entropy balance for valve
Sdotvalve = mrefdot*(s4-s3)

#Results
print  "the entropy production rates for control volumes enclosing the condenser is", round(Sdotcond,6),"kW/K"
print  "the entropy production rates for control volumes enclosing the compressor is", round(Sdotcomp,6),"kW/K"
print  "the entropy production rates for control volumes enclosing the valve is", round(Sdotvalve,6),"kW/K"
#answer wrong in book

the entropy production rates for control volumes enclosing the condenser is 0.000724 kW/K
the entropy production rates for control volumes enclosing the compressor is 0.001754 kW/K
the entropy production rates for control volumes enclosing the valve is 0.000988 kW/K


## Example 7.08, page: 165

In :
from __future__ import division
import math

# Initialization  of  Variable
P1 = 1 #atm
T1 = 540 #degR
T2 = 1160 #degR
Tm = 850 #degR

#calculations:
#from table T-9E, Pr values are
Pr2 = 21.18
Pr1 = 1.3860
P2a = P1*Pr2/Pr1

#from table T-10E
k = 1.39
P2b = P1*(T2/T1)**(k/(k-1))

#Results
print "a) Final Pressure using Pr data is", round(P2a,2),"atm"
print "b) Final Pressure using a constant value for the specific heat ratio k is", round(P2b,2),"atm"

a) Final Pressure using Pr data is 15.28 atm
b) Final Pressure using a constant value for the specific heat ratio k is 15.26 atm


## Example 7.09, page: 169

In :
from __future__ import division
import math

#Initialization  of  Variable
P1 = 5 #bar
T1 = 320 #degC
P2 = 1 #bar
nt = 0.75 #isentropic efficiency

#calculations:
#from table T-4
h1 = 3105.6 #kJ/kg
s1 = 7.5308 #kJ/kg-K
s2s = s1
h2s = 2743.0 #kJ/kg
# work developed perunit mass
Wmdot = nt*(h1-h2s)

#Results
print  "work developed per unit mass of steam flowing through the turbine is", round(Wmdot,2),"kJ/kg"

work developed per unit mass of steam flowing through the turbine is 271.95 kJ/kg


## Example 7.10, page: 170

In :
from __future__ import division
import math

# Initialization  of  Variable
P1 = 3 #bar
T1 = 390 #K
P2 = 1 #bar
Wmdot = 74 #kJ/kg

#calculations:
#from table T-9
h1 = 390.88 #kJ/kg
Pr1 = 3.481
PrT2s = P2*Pr1/P1

h2s = 285.27 #kJ/kg
Wmdots = h1 - h2s
#efficiency
nt = Wmdot/Wmdots

#Results
print "the turbine efficiency is", round(nt*100,0),"%"

the turbine efficiency is 70.0 %


## Example 7.11, page: 171

In :
from __future__ import division
import math

# Initialization  of  Variable
P1 = 140 #lbf/in2
T1 = 600 #degF
V1 = 100 #ft/s
P2 = 40 #lbf/in2
T2 = 350 #degF

#calculations:
#assumption
Wdot = 0
#from Table T-4E
h1 = 1326.4 #Btu/lb
s1 = 1.7191 #Btu/lb-degR
h2 = 1211.8 #Btu/lb

#actual specific kinetic energy at the exit
#KE = (V2**2)/2
KE = h1 - h2 + (V1**2)/(2*32.2*778)

#from Table T-4E
S2s = s1
h2s = 1202.3 #Btu/lb-degR
#specific kinetic energy at the exit for an isentropic expansion
#KEs = ((V2**2)/2)s
KEs = h1 - h2s + (V1**2)/(2*32.2*778)

#efficiency
n_nozzle = KE/KEs

#Results
print  "the nozzle efficiency",round(n_nozzle*100,1),"%"

the nozzle efficiency 92.4 %


## Example 7.12, page: 171

In :
from __future__ import division
import math

# Initialization  of  Variable
P1 = 3.5 #bar
T1 = -5 #degC
P2 = 14 #bar
T2 = 75 #degC
mdot = 0.07 #kg/s

#calculations:
#from Table T-14
h1 = 249.75 #kJ/kg
h2 = 294.17 #kJ/kg
s1 = 0.9572 #kJ/kg-K
s2s = s1
h2s = 285.58 #kJ/kg

#the compressor power
Wdot = mdot*(h1-h2)

#isentropic compressor efficiency
nc = (h2s - h1)/(h2 - h1)

#Results
print  "the compressor power is", round(Wdot,2),"kW and isentropic efficiency is",round(nc*100,0),"%"

the compressor power is -3.11 kW and isentropic efficiency is 81.0 %


## Example 7.13, page: 174

In :
from __future__ import division
import math

# Initialization  of  Variable
P1 = 1 #bar
T1 = 20 #degC
P2 = 5 #bar
n = 1.3
R = 8.314/28.97 #kJ/kg-K

#calculations:
T2 = (T1+273)*(P2/P1)**((n-1)/n) - 273
#Work per unit mass
Wmdot = -1*(n*R/(n-1))*(T2-T1)

#from Table T-9
h1 = 293.17 #kJ/kg
h2 = 426.35 #kJ/kg
#heat transfer per unit of mass
Qmdot = Wmdot + h2 - h1

#Results
print  "Work Per unit mass is", round(Wmdot,1),"kJ/kg and heat transfer per unit of mass is", round(Qmdot,0),"kJ/kg"
#Answer wrong in book

Work Per unit mass is -163.9 kJ/kg and heat transfer per unit of mass is -31.0 kJ/kg