1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
|
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Chapter 07: Entropy"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Ex7.1:pg-191"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
" Example 7.1\n",
"\n",
" Change in entropy of the water is 0.0271 kJ/K\n"
]
}
],
"source": [
"\n",
"import math\n",
"T1 = 37.0 # Final water temperature in degree Celsius \n",
"T2 = 35.0 # Initial water temperature in degree Celsius \n",
"m = 1.0 # Mass of water in kg\n",
"cv = 4.187 # Specific heat capacity of water in kJ/kgK\n",
"print \"\\n Example 7.1\"\n",
"S = m*cv*math.log((T1+273)/(T2+273)) # Change in entropy of the water\n",
"print \"\\n Change in entropy of the water is \",round(S,4) ,\" kJ/K\"\n",
"#The answer provided in the textbook is wrong\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Ex7.2:pg-192"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
" Example 7.2\n",
"\n",
" The entropy change of the universe is -1.12252010724 kJ/K\n",
"\n",
" The entropy change of the universe is -1.20940246848 kJ/K\n"
]
}
],
"source": [
"import math\n",
"# Part (a)\n",
"T1 = 273 # Initial temperature of water in Kelvin\n",
"T2 = 373 # Temperature of heat reservoir in Kelvin\n",
"m = 1 # Mass of water in kg\n",
"cv = 4.187 # Specific heat capacity of water\n",
"\n",
"print \"\\n Example 7.2\"\n",
"Ss = m*cv*math.log(T2/T1) # entropy change of water\n",
"Q = m*cv*(T2-T1) # Heat transfer \n",
"Sr = -(Q/T2) # Entropy change of universe\n",
"S = Ss+Sr # Total entropy change\n",
"\n",
"print \"\\n The entropy change of the universe is \",S ,\" kJ/K\"\n",
"\n",
"# Part (b)\n",
"T3 = 323 # Temperature of intermediate reservoir in K\n",
"Sw = m*cv*(math.log(T3/T1)+math.log(T2/T3)) # entropy change of water\n",
"Sr1 = -m*cv*(T3-T1)/T3 # Entropy change of universe\n",
"Sr2 = -m*cv*(T2-T3)/T2 # Entropy change of universe\n",
"Su = Sw+Sr1+Sr2 # Total entropy change\n",
"print \"\\n The entropy change of the universe is \",Su ,\" kJ/K\"\n",
"#The answers vary due to round off error"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Ex7.3:pg-193"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
" Example 7.3\n",
"\n",
" The entropy change of the universe is -0.238182312568 kJ/K\n",
"\n",
" The minimum work required is -69.7874175824 kJ\n"
]
}
],
"source": [
"import math\n",
"m = 1 # Mass of ice in kg\n",
"\n",
"T1 = -5 # Initial temperature of ice in degree Celsius\n",
"\n",
"T2 = 20# Atmospheric temperature in degree Celsius\n",
"\n",
"T0 = 0# Phase change temperature of ice in degree Celsius\n",
"\n",
"cp = 2.093 # Specific heat capacity of ice in kJ/kgK\n",
"\n",
"cv = 4.187 # Specific heat capacity of water in kJ/kgK\n",
"\n",
"lf = 333.3 # Latent heat of fusion in kJ/kgK\n",
"\n",
"\n",
"\n",
"print \"\\n Example 7.3\"\n",
"\n",
"Q = m*cp*(T0-T1)+1*333.3+m*cv*(T2-T0) # Net heat transfer\n",
"\n",
"Sa = -Q/(T2+273) # Entropy change of surrounding\n",
"\n",
"Ss1 = m*cp*math.log((T0+273)/(T1+273)) # entropy change during \n",
"\n",
"Ss2 = lf/(T0+273) # Entropy change during phase change\n",
"\n",
"Ss3 = m*cv*math.log((T2+273)/(T0+273)) # entropy change of water\n",
"\n",
"St = Ss1+Ss2+Ss3 # total entropy change of ice to convert into water at atmospheric temperature\n",
"\n",
"Su = St+Sa # Net entropy change of universe\n",
"\n",
"print \"\\n The entropy change of the universe is \",Su ,\" kJ/K\"\n",
"\n",
"\n",
"\n",
"#The answer provided in the textbook is wrong\n",
"\n",
"# Part (b)\n",
"\n",
"S = St # Entropy change of system\n",
"\n",
"Wmin = (T2+273)*(S)-Q # minimum work required\n",
"\n",
"print \"\\n The minimum work required is \",Wmin ,\" kJ\"\n",
"\n",
"#The answers vary due to round off error\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Ex7.7:pg-200"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
" Example 7.7\n",
"\n",
" Change in enthalpy is 223.48 kJ\n",
"\n",
" Change in internal energy is 171.91 kJ\n",
"\n",
" The change in entropy and heat transfer are is 0 kJ\n",
"\n",
" The work transfer during the process is -171.91 kJ\n"
]
}
],
"source": [
"import math\n",
"P1 = 0.5 # Initial pressure in MPa\n",
"\n",
"V1 = 0.2 # Initial volume in m**3\n",
"\n",
"V2 = 0.05 # Final volume in m**3\n",
"\n",
"n = 1.3 # Polytropic index\n",
"\n",
"\n",
"\n",
"from scipy import integrate \n",
"\n",
"print \"\\n Example 7.7\"\n",
"\n",
"P2 = P1*(V1/V2)**n \n",
"\n",
"def f(p):\n",
" y = ((P1*V1**n)/p)**(1/n) \n",
" return y\n",
" \n",
"\n",
" \n",
"H, err = integrate.quad(f,P1,P2) # H = H2-H1\n",
"\n",
"U = H-(P2*V2-P1*V1) \n",
" \n",
"W12 = -U \n",
" \n",
"print \"\\n Change in enthalpy is \",round(H*1e3,2),\" kJ\"\n",
" \n",
"print \"\\n Change in internal energy is \",round(U*1000,2),\" kJ\"\n",
" \n",
"print \"\\n The change in entropy and heat transfer are is \",0 ,\" kJ\"\n",
" \n",
"print \"\\n The work transfer during the process is \",round(W12*1000,2) ,\" kJ\"\n",
" \n",
" #The answers vary due to round off error\n",
" \n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Ex7.8:pg-201"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
" Example 7.8\n",
"\n",
" Change in the entropy of the universe is -1.2785104723 kJ/Kg K\n",
"\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\n"
]
}
],
"source": [
"\n",
"import math\n",
"from scipy import integrate \n",
"\n",
"\n",
"Pa = 130.0 # Pressure at station A in kPa\n",
"\n",
"Pb = 100.0# Pressure at station B in kPa\n",
"\n",
"Ta = 50.0 # Temperature at station A in degree Celsius\n",
"\n",
"Tb = 13.0# Temperature at station B in degree Celsius\n",
"\n",
"cp = 1.005 # Specific heat capacity of air in kJ/kgK\n",
"\n",
"x= lambda t:cp/t\n",
"y= lambda p:0.287/p\n",
"\n",
"print \"\\n Example 7.8\"\n",
"\n",
"Sb,error = integrate.quad(x,Ta,Tb)#-\n",
"Sa,eror=integrate.quad(y,Pa,Pb) \n",
"\n",
"Ss=Sb-Sa\n",
"Ssur=0 \n",
"Su = Ss+Ssur\n",
"\n",
"print \"\\n Change in the entropy of the universe is \",Su ,\" kJ/Kg K\"\n",
"\n",
"#The answers given in the book is wrong\n",
"\n",
"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\"\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Ex7.9:pg-202"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
" Example 7.9\n",
"\n",
" The entropy generated during the process is 0.785677602261 kW/K\n",
"\n",
" As the entropy generated is positive so such device is possible\n"
]
}
],
"source": [
"import math\n",
"T1 = 300.0 # Inlet temperature of air in K\n",
"\n",
"T2 = 330.0 # Exit temperature of first air stream in K\n",
"\n",
"T3 = 270.0 # Exit temperature of second air stream in K\n",
"\n",
"P1 = 4.0 # Pressure of inlet air stream in bar\n",
"\n",
"P2 =1.0 # Pressure of first exit air stream in bar\n",
"\n",
"P3 =1.0 # Pressure of second exit air stream in bar\n",
"\n",
"cp = 1.0005 # Specific heat capacity of air in kJ/kgK\n",
"\n",
"R = 0.287 # Gas constant\n",
"\n",
"\n",
"\n",
"print \"\\n Example 7.9\"\n",
"\n",
"S21 = cp*math.log(T2/T1)-R*math.log(P2/P1) # Entropy generation\n",
"\n",
"S31 = cp*math.log(T3/T1)-R*math.log(P3/P1) # Entropy generation\n",
"\n",
"Sgen = (1.0*S21) + (1.0*S31) # Total entropy generation\n",
"\n",
"print \"\\n The entropy generated during the process is \",Sgen ,\" kW/K\"\n",
"\n",
"#The answers vary due to round off error\n",
"\n",
"\n",
"\n",
"print \"\\n As the entropy generated is positive so such device is possible\"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Ex7.10:pg-203"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
" Example 7.10\n",
"\n",
" The rate of heat transfer through the wall is 1164.84375 W\n",
"\n",
" The rate of entropy through the wall is 0.213013632873 W/K\n",
"\n",
" The rate of total entropy generation with this heat transfer process is 0.352982954545 W/K\n"
]
}
],
"source": [
"import math\n",
"A = 5*7 # Area of wall in m**2\n",
"k = 0.71# Thermal conductivity in W/mK \n",
"L = 0.32 # Thickness of wall in m\n",
"Ti = 21 # Room temperature in degree Celsius \n",
"To = 6 # Surrounding temperature in degree Celsius\n",
"print \"\\n Example 7.10\"\n",
"Q = k*A*(Ti-To)/L # Heat transfer\n",
"Sgen_wall = Q/(To+273) - Q/(Ti+273) # Entropy generation in wall\n",
"print \"\\n The rate of heat transfer through the wall is \",Q ,\" W\"\n",
"print \"\\n The rate of entropy through the wall is \",Sgen_wall ,\" W/K\"\n",
"Tr = 27 # Inner surface temperature of wall in degree Celsius \n",
"Ts = 2 # Outer surface temperature of wall in degree Celsius \n",
"Sgen_total = Q/(Ts+273)-Q/(Tr+273) # Total entropy generation in process \n",
"print \"\\n The rate of total entropy generation with this heat transfer process is \",Sgen_total ,\" W/K\"\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.11"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
|