summaryrefslogtreecommitdiff
path: root/Thermodynamics:_From_concepts_to_applications/Chapter9_1.ipynb
blob: f2acb74eb985d5a2ab417d26729fd9edde3de718 (plain)
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
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
{
 "metadata": {
  "name": "",
  "signature": "sha256:15fd1db156f91825255a086dbc12ea12cb6caac30db6feed49ee7e31d29fef8c"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter9-Applications of the second law of thermodynamics"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example1-pg 152"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate final temperatures and total entropy\n",
      "##changeinitialisation of variables\n",
      "p1= 3.##changeMpa\n",
      "p2= 0.2 ##changeMpa\n",
      "V1= 0.6 ##changem^3\n",
      "V2= 1.##changem^3\n",
      "M= 28. ##changegms\n",
      "R= 8.314 ##changeJ/mol K\n",
      "T= 400. ##changeC\n",
      "T1= 150. ##changeC\n",
      "k= 1.4\n",
      "p3= 1.25 ##changeMpa\n",
      "##changeCALCULATIONS\n",
      "m1= p1*V1*10*10*10*M/(R*(273.15+T))\n",
      "m2= p2*V2*10*10*10*M/(R*(273.15+T1))\n",
      "p4= (p1*V1+p2*V2)/(V1+V2)\n",
      "T2= (math.pow(p4/p1,k-1)/k)*(273.15+T)\n",
      "m3= p3*V1*M*10*10*10/(R*T2)\n",
      "dm= m1-m3\n",
      "m4= m2+dm\n",
      "T4= p3*10*10*10*V2/((R/M)*m4)\n",
      "S= (R/M)*(m2*((k/(k-1))*math.log(T4/(273.15+T1))-math.log(p3/p2))+dm*((k/(k-1))*math.log(T4/(273.15+T))-math.log(p3/p1)))\n",
      "##changeRESULTS\n",
      "print'%s %.1f %s'%('final temperature =',T2,'K')\n",
      "print'%s %.1f %s'%('final temperature =',T4,'K')\n",
      "print'%s %.4f %s'%('Total entropy =',S,'KJ/K')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "final temperature = 338.8 K\n",
        "final temperature = 1340.2 K\n",
        "Total entropy = 2.5525 KJ/K\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example2-pg156"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate work of the pump\n",
      "##initialisation of variables\n",
      "m= 10000 ##kg/h\n",
      "P= 2.5 ##Mpa\n",
      "P1= 100 ##kPa\n",
      "v= 0.001003 ##m^3\n",
      "##CALCULATIONS\n",
      "W= -m*v*(P*10*10*10-P1)/3600\n",
      "##RESULTS\n",
      "print'%s %.3f %s'%(' work of the pump =',W,'kW')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " work of the pump = -6.687 kW\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example3-pg 158"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "##initialisation of variables\n",
      "m= 4. ##kg/s\n",
      "R= 8.314 ##J/mol K\n",
      "M= 29. ##gms\n",
      "k= 1.4\n",
      "T1= 27. ##C\n",
      "p2= 1800. ##kPa\n",
      "p1= 105. ##kPa\n",
      "n= 1.22\n",
      "cp= 1.4 ##Jmol K\n",
      "##CALCULATIONS\n",
      "T2= (273.15+T1)*(p2/p1)**((n-1)/n)\n",
      "W= m*k*(R/M)*((273.15+T1)/(k-1))*(1-(p2/p1)**((k-1)/k))\n",
      "Q= -m*R*(273.15+T1)*math.log(p2/p1)/M\n",
      "W1= m*(R/M)*n*((273.15+T1)/(n-1))*(1-(p2/p1)**((n-1)/n))\n",
      "Q1= m*(R/M)*(n-k)*(T2-T1-273.15)/((n-1)*(k-1))\n",
      "T3= (273.15+T1)*(p2/p1)**((k-1)/(2*k))\n",
      "Q2= m*cp*(R/M)*(T1+273.15-T3)/(k-1)\n",
      "##RESULTS\n",
      "print'%s %.1f %s'%('heat removed in adiabatic compression =',W,'kW')\n",
      "print'%s %.1f %s'%('heat removed in isothermal compression =',Q,'kW')\n",
      "print'%s %.1f %s'%('heat removed in polytropic process =',Q1,'kW')\n",
      "print'%s %.2f %s'%('heat removed in adiabatic compression in two stages =',Q2,'kW')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "heat removed in adiabatic compression = -1508.5 kW\n",
        "heat removed in isothermal compression = -978.1 kW\n",
        "heat removed in polytropic process = -471.2 kW\n",
        "heat removed in adiabatic compression in two stages = -603.21 kW\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example4-pg 161"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate enthalpy and entropy\n",
      "##initialisation of variables\n",
      "h1= 3422.25 ##kJ/kg\n",
      "m= 8. ##kg/s\n",
      "s2= 7.3755 ##kJ/kg K\n",
      "s1= 6.8803 ##kJ/kg K\n",
      "e= 0.8\n",
      "h2s= 2496.8 ##kJ/kg\n",
      "##CALCULATIONS\n",
      "h2= h1+e*(h2s-h1)\n",
      "W= m*(h1-h2)\n",
      "S= s2-s1\n",
      "##RESULTS\n",
      "print'%s %.1f %s'%('Enthalpy  =',W,'kW')\n",
      "print'%s %.4f %s'% ('Entropy =',S,'kJ/kg K')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Enthalpy  = 5922.9 kW\n",
        "Entropy = 0.4952 kJ/kg K\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example5-pg162"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "calculate volume flow rate into composser and volume flow rate out composser and heat and work \n",
      "##initialisation of variables\n",
      "m= 0.2 ##kg/s\n",
      "v1= 1.0803 ##m^3/kg\n",
      "T= 200 ##C\n",
      "s2= 5.8041 ##kJ/kg K\n",
      "s1= 7.5066 ##kJ/kg K\n",
      "h1= 2328.1 ##kJ/kg\n",
      "h2= 2654.4 ##kJ/kg\n",
      "##CALCULATIONS\n",
      "V1= m*v1\n",
      "V2= 0.1*V1\n",
      "Q= m*(273.15+T)*(s2-s1)\n",
      "W= Q-m*(h1-h2)\n",
      "##RESULTS\n",
      "print'%s %.4f %s'%('volume flow rate into composser =',V1,'m^3')\n",
      "print'%s %.4f %s'%('volume flow rate out of composser  =',V2,'m^3')\n",
      "print'%s %.1f %s'%('Heat  =',Q,'kJ')\n",
      "print'%s %.1f %s'%(' Work  =',W,'kJ')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "volume flow rate into composser = 0.2161 m^3\n",
        "volume flow rate out of composser  = 0.0216 m^3\n",
        "Heat  = -161.1 kJ\n",
        " Work  = -95.8 kJ\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example6-pg164"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate volume flow rate out and into the composser and work and heat\n",
      "##initialisation of variables\n",
      "m1= 0.2 ##kg/s\n",
      "v1= 1.0803 ##m^3/kg\n",
      "P= 200 ##kPa\n",
      "T= 200 ##C\n",
      "s1= 5.8041 ##kJ.kg K\n",
      "s2= 7.5066 ##kJ/kg K\n",
      "h1= 2870.5 ##kJ/kg\n",
      "h2= 2495.9 ##kJ/kg\n",
      "##CALCULATIONS\n",
      "V1= m1*v1\n",
      "V2= 0.1*V1\n",
      "Q= m1*(273.15+T)*(s1-s2)\n",
      "W= m1*((h1-h2)-(273.15+T)*(s2-s1))\n",
      "##RESULTS\n",
      "print'%s %.4f %s'% ('volume flow rate into composser =',V1,'m^3/s')\n",
      "print'%s %.4f %s'%('volume flow rate out of composser  =',V2,'m^3/s') \n",
      "print'%s %.1f %s'%('Work  =',W,'kW')\n",
      "print'%s %.1f %s'%('Heat  =',Q,'kW')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "volume flow rate into composser = 0.2161 m^3/s\n",
        "volume flow rate out of composser  = 0.0216 m^3/s\n",
        "Work  = -86.2 kW\n",
        "Heat  = -161.1 kW\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example7-pg166"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate rate of transfer\n",
      "##initialisation of variables\n",
      "e= 0.82\n",
      "m= 5 ##kg/s\n",
      "T3= 450 ##C\n",
      "T1= 200 ##C\n",
      "##CALCULATIONS\n",
      "Q= e*m*1.0035*(T3-T1)\n",
      "##RESULTS\n",
      "print'%s %.1f %s'%('rate of transfer =',Q,'kW')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "rate of transfer = 1028.6 kW\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example8-pg 166"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate heat at given enthalpy\n",
      "##initialisation of variables\n",
      "h1= 174.076 ##kJ/kg\n",
      "h3= 74.527 ##kJ/kg\n",
      "h4= 8.854 ##kJ/kg\n",
      "m= 0.8 ##kg\n",
      "e= 0.85\n",
      "##CALCULATIONS\n",
      "h2= h1+h3-h4\n",
      "Q= m*(h2-h1-23)\n",
      "Q1= e*Q\n",
      "##RESULTS\n",
      "print'%s %.2f %s'%('Heat =',Q,'kW')\n",
      "print'%s %.2f %s'%('Heat =',Q1,'kW')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat = 34.14 kW\n",
        "Heat = 29.02 kW\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example9-pg 167"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate enthalpy and entropy change\n",
      "##initialisation of variables\n",
      "W= 2000. ##kW\n",
      "m= 2. ##kg/s\n",
      "h1= 3023.5 ##kJ/kg\n",
      "s2= 5.6106 ##kJ/kg K\n",
      "s1= 6.7664 ##kJ/kg K\n",
      "##CALCULATIONS\n",
      "h2= h1-(W/m)\n",
      "S=s2-s1\n",
      "##RESULTS\n",
      "print'%s %.1f %s'% ('enthalpy =',h2,'kJ/kg')\n",
      "print'%s %.4f %s'%('entropy change =',S,'kJ/kg K')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "enthalpy = 2023.5 kJ/kg\n",
        "entropy change = -1.1558 kJ/kg K\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example10-pg 168"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate enthalpy and entropy change\n",
      "##initialisation of variables\n",
      "m1= 1 ##kg\n",
      "h1= 2967.6 ##kJ/kg\n",
      "h2= 83.96 ##kJ/kg\n",
      "m2= 10\n",
      "s1= 7.5166 ##kJ/kg K\n",
      "s2= 0.2966 ##kJ/kg K\n",
      "s3= 1.1654 ##kJ/kg K\n",
      "##CALCULATIONS\n",
      "h3= (m1*h1+m2*h2)/(m1+m2)\n",
      "S= -m1*s1-m2*s2+(m1+m2)*s3\n",
      "##RESULTS\n",
      "print'%s %.1f %s'% ('enthalpy =',h3,'kJ/kg')\n",
      "print'%s %.4f %s'%('entropy change =',S,'kJ/kg K')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "enthalpy = 346.1 kJ/kg\n",
        "entropy change = 2.3368 kJ/kg K\n"
       ]
      }
     ],
     "prompt_number": 1
    }
   ],
   "metadata": {}
  }
 ]
}