summaryrefslogtreecommitdiff
path: root/Thermodynamics_An_Engineering_Approach/Chapter13.ipynb
blob: 936d90ae944c947275938299e50745dd8b2a071e (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
{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 13: Gas Mixtures"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13-1 ,Page No.683"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "mO2=3.0;#moles of oxygen\n",
      "mN2=5.0;#moles of nitrogen\n",
      "mCH4=12.0;#moles of methane\n",
      "\n",
      "#molecular masses in kg\n",
      "MO2=32.0;\n",
      "MN2=28.0;\n",
      "MCH4=16.0;\n",
      "\n",
      "#constants used\n",
      "Ru=8.314;#in kJ/kg - K\n",
      "\n",
      "#calculations\n",
      "\n",
      "#part - a\n",
      "mm=mO2+mN2+mCH4;\n",
      "mfO2=mO2/mm;\n",
      "mfN2=mN2/mm;\n",
      "mfCH4=mCH4/mm;\n",
      "print'mass fraction of oxygen is %f'%round(mfO2,2);\n",
      "print'mass fraction of nitrogen is %f'%round(mfN2,2);\n",
      "print'mass fraction of methane is %f'%round(mfCH4,2);\n",
      "\n",
      "#part - b\n",
      "NO2=mO2/MO2;\n",
      "NN2=mN2/MN2;\n",
      "NCH4=mCH4/MCH4;\n",
      "Nm=NO2+NN2+NCH4;\n",
      "yO2=NO2/Nm;\n",
      "yN2=NN2/Nm;\n",
      "yCH4=NCH4/Nm;\n",
      "print'mole fraction of oxygen is %f'%round(yO2,3);\n",
      "print'mole fraction of nitrogen is %f'%round(yN2,3);\n",
      "print'mole fraction of methane is %f'%round(yCH4,3);\n",
      "\n",
      "#part - c\n",
      "Mm=mm/Nm;\n",
      "print'average molecular mass %f kg/kmol'%round(Mm,1);\n",
      "Rm=Ru/Mm;\n",
      "print'gas constant of mixture %f kJ/kg - K'%round(Rm,3)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "mass fraction of oxygen is 0.150000\n",
        "mass fraction of nitrogen is 0.250000\n",
        "mass fraction of methane is 0.600000\n",
        "mole fraction of oxygen is 0.092000\n",
        "mole fraction of nitrogen is 0.175000\n",
        "mole fraction of methane is 0.734000\n",
        "average molecular mass 19.600000 kg/kmol\n",
        "gas constant of mixture 0.425000 kJ/kg - K\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13-2 ,Page No.687"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "NN2=2.0;#moles of nitrogen\n",
      "NCO2=6.0;#moles of carbon dioxide\n",
      "Tm=300.0;#temperature of gases in K\n",
      "Pm=15000.0;#pressure of gases in kPa\n",
      "\n",
      "#constants used\n",
      "Ru=8.314;#in kJ/kmol - K\n",
      "\n",
      "#calculations\n",
      "\n",
      "#part - a\n",
      "Nm=NN2+NCO2;\n",
      "Vm=Nm*Ru*Tm/Pm;\n",
      "print'the volume of the tank on the basis of the ideal-gas equation of state %f m^3'%round(Vm,3);\n",
      "\n",
      "#part - b\n",
      "#from Table A-1\n",
      "#for nitrogen\n",
      "TcrN=126.2;\n",
      "PcrN=3390;\n",
      "#for Carbondioxide\n",
      "TcrC=304.2;\n",
      "PcrC=7390;\n",
      "yN2=NN2/Nm;\n",
      "yCO2=NCO2/Nm;\n",
      "Tcr=yN2*TcrN+yCO2*TcrC;\n",
      "Pcr=yN2*PcrN+yCO2*PcrC;\n",
      "Tr=Tm/Tcr;\n",
      "Pr=Pm/Pcr;\n",
      "#from Fig A-15b\n",
      "Zm=0.49;\n",
      "Vm=Zm*Nm*Ru*Tm/Pm;\n",
      "print'the volume of the tank on the basis Kay\u2019s rule %f m^3'%round(Vm,3);\n",
      "\n",
      "#part - c\n",
      "#for nitrogen\n",
      "TrN=Tm/TcrN;\n",
      "PrN=Pm/PcrN;\n",
      "#from Fig A-15b\n",
      "Zn=1.02;\n",
      "#for Carbondioxide\n",
      "TrC=Tm/TcrC;\n",
      "PcrC=Pm/PcrC;\n",
      "#from Fig A-15b\n",
      "Zc=0.3;\n",
      "Zm=yN2*Zn+yCO2*Zc;\n",
      "Vm=Zm*Nm*Ru*Tm/Pm;\n",
      "print'the volume of the tank on the basis compressibility factors and Amagat\u2019s law %f m^3'%round(Vm,3);\n",
      "\n",
      "#part - d\n",
      "VRN=(Vm/NN2)/(Ru*TcrN/PcrN);\n",
      "VRC=(Vm/NCO2)/(Ru*TcrC/PcrC);\n",
      "#from Fig A-15b\n",
      "Zn=0.99;\n",
      "Zc=0.56;\n",
      "Zm=yN2*Zn+yCO2*Zc;\n",
      "Vm=Zm*Nm*Ru*Tm/Pm;\n",
      "#When the calculations are repeated we obtain 0.738 m3 after the second iteration, 0.678 m3 after the third iteration, and 0.648 m3 after the fourth iteration.\n",
      "Vm=0.648;\n",
      "print'compressibility factors and Dalton\u2019s law the volume of the tank on the basis %f m^3'%round(Vm,3);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the volume of the tank on the basis of the ideal-gas equation of state 1.330000 m^3\n",
        "the volume of the tank on the basis Kay\u2019s rule 0.652000 m^3\n",
        "the volume of the tank on the basis compressibility factors and Amagat\u2019s law 0.639000 m^3\n",
        "compressibility factors and Dalton\u2019s law the volume of the tank on the basis 0.648000 m^3\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13-3 ,Page No.691"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "mN=4.0;#mass of nitrogen in kg\n",
      "T1N=20.0;#temperature of nitrogen in K\n",
      "P1N=150.0;#pressure of nitrogen in kPa\n",
      "mO=7.0;#mass of oxygen in kg\n",
      "T1O=40.0;#temperature of oxygen in K\n",
      "P1O=100.0;#pressure of oxygen in kPa\n",
      "\n",
      "#molecular masses in kg\n",
      "MO=32.0;\n",
      "MN=28.0;\n",
      "\n",
      "#constants used\n",
      "Ru=8.314;#in kJ/kg - K\n",
      "\n",
      "#from Table A-2a\n",
      "CvN=0.743;\n",
      "CvO=0.658;\n",
      "\n",
      "#calculations\n",
      "\n",
      "#part - a\n",
      "#Ein - Eout = dEsystem\n",
      "# (m*cv*dT)N2 + (m*cv*dT)= 0;\n",
      "Tm= (mN*CvN*T1N+ mO*CvO*T1O)/(mN*CvN+mO*CvO);\n",
      "print'the mixture temperature %f C'%round(Tm,1);\n",
      "\n",
      "#part - b\n",
      "NO=mO/MO;\n",
      "NN=mN/MN;\n",
      "Nm=NO+NN;\n",
      "VO=NO*Ru*(T1O+273)/P1O;\n",
      "VN=NN*Ru*(T1N+273)/P1N;#Exergy Destruction during Mixing of Ideal Gases\n",
      "Vm=VO+VN;\n",
      "Pm=Nm*Ru*(Tm+273)/Vm;  \n",
      "print'the mixture pressure after equilibrium has been established %f kPa'%round(Pm,1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the mixture temperature 32.200000 C\n",
        "the mixture pressure after equilibrium has been established 114.500000 kPa\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13-4 ,Page No.692"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import log\n",
      "\n",
      "#given data\n",
      "NO=3.0;#moles of oxygen \n",
      "NC=5.0;#moles of carbondioxide\n",
      "T0=25+273.0;#temperature of gasses in K\n",
      "\n",
      "#constants used\n",
      "Ru=8.314;#in kJ/kg - K\n",
      "\n",
      "#calculations\n",
      "Nm=NO+NC;\n",
      "yO=NO/Nm;\n",
      "yC=NC/Nm;\n",
      "#dSm= -Ru*(NO*log(yO)+NC*log(yC))\n",
      "Sm=-Ru*(NO*log(yO)+NC*log(yC));\n",
      "print'the entropy change %f kJ/K'%round(Sm);\n",
      "Xdestroyed=T0*Sm/1000;\n",
      "print'exergy destruction associated %f MJ'%round(Xdestroyed,1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the entropy change 44.000000 kJ/K\n",
        "exergy destruction associated 13.100000 MJ\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13-5 ,Page No.694"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "T1=220;#intial temperature in K\n",
      "T2=160;#final temperature in K\n",
      "Pm=10;#pressure of air in MPa\n",
      "yN=0.79;#mole fraction of nitrogen\n",
      "yO=0.21;#mole fractions of oxygen\n",
      "\n",
      "\n",
      "#critical properties\n",
      "#for Nitrogen\n",
      "TcrN=126.2;\n",
      "PcrN=3.39;\n",
      "#for Oxygen\n",
      "TcrO=154.8;\n",
      "PcrO=5.08;\n",
      "\n",
      "#constants used\n",
      "Ru=8.314;#in kJ/kg - K\n",
      "\n",
      "#from Tables A-18 & 19\n",
      "#at T1\n",
      "h1N=6391;\n",
      "h1O=6404;\n",
      "#for T2\n",
      "h2N=4648;\n",
      "h2O=4657;\n",
      "\n",
      "#calculations\n",
      "#part - a\n",
      "qouti=yN*(h1N-h2N)+yO*(h1O-h2O);\n",
      "print'the heat transfer during this process using the ideal-gas approximation %i kJ/kmol'%round(qouti);\n",
      "\n",
      "#part - b\n",
      "Tcrm=yN*TcrN+yO*TcrO;\n",
      "Pcrm=yN*PcrN+yO*PcrO;\n",
      "Tr1=T1/Tcrm;\n",
      "Tr2=T2/Tcrm;\n",
      "Pr=Pm/Pcrm;\n",
      "#at these values we get\n",
      "Zh1=1;\n",
      "Zh2=2.6\n",
      "qout=qouti-Ru*Tcrm*(Zh1-Zh2);\n",
      "print'the heat transfer during this process using Kay\u2019s rule %i kJ/kmol'%round(qout);\n",
      "\n",
      "#part - c\n",
      "#for nitrogen\n",
      "TrN1=T1/TcrN;\n",
      "TrN2=T2/TcrN;\n",
      "PrN=Pm/PcrN;\n",
      "#from Fig A-15b\n",
      "Zh1n=0.9;\n",
      "Zh2n=2.4;\n",
      "#for Oxygen\n",
      "TrO1=T1/TcrO;\n",
      "TrO2=T2/TcrO;\n",
      "PcrO=Pm/PcrO;\n",
      "#from Fig A-15b\n",
      "Zh1O=1.3;\n",
      "Zh2O=4.0;\n",
      "#from Eq 12-58\n",
      "h12N=h1N-h2N-Ru*TcrN*(Zh1n-Zh2n);# h1 - h2 for nitrogen\n",
      "h12O=h1O-h2O-Ru*TcrO*(Zh1O-Zh2O);# h1 - h2 for oxygen\n",
      "qout=yN*h12N+yO*h12O;\n",
      "print'the heat transfer during this process using Amagat\u2019s law %i kJ/kmol'%round(qout);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the heat transfer during this process using the ideal-gas approximation 1744 kJ/kmol\n",
        "the heat transfer during this process using Kay\u2019s rule 3502 kJ/kmol\n",
        "the heat transfer during this process using Amagat\u2019s law 3717 kJ/kmol\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13-6 ,Page No.705"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import log\n",
      "\n",
      "#13.6 (d) answer not matching as float datatype is giving more accurate answer in comparison to textbook that has given approximate due to rounding off to two decimal places\n",
      "\n",
      "#given data\n",
      "mfs=0.0348;#salinity mass fraction\n",
      "mfw=1-mfs;\n",
      "T0=288.15;#temperature of sea water in K\n",
      "\n",
      "#constants used\n",
      "Mw=18;\n",
      "Ms=58.44;\n",
      "Rw=0.4615;\n",
      "pm=1028;\n",
      "Ru=8.314;\n",
      "\n",
      "#calculations\n",
      "#part - a\n",
      "Mm=1/((mfs/Ms)+(mfw/Mw));\n",
      "yw=mfw*Mm/Mw;\n",
      "ys=1-yw;\n",
      "print'the mole fraction of the water is %f'%round(yw,4);\n",
      "print'the mole fraction of the saltwater is %f'%round(ys,5);\n",
      "\n",
      "#part - b\n",
      "wmin=-Ru*T0*(ys*log(ys)+yw*log(yw));\n",
      "wm=wmin/Mm;\n",
      "print'the minimum work input required to separate 1 kg of seawater completely into pure water and pure salts %f kJ'%round(wm,2);\n",
      "\n",
      "#part - c\n",
      "wmin=Rw*T0*log(1/yw);\n",
      "print'the minimum work input required to obtain 1 kg of fresh water from the sea %f kJ'%round(wmin,2);\n",
      "\n",
      "#part - d\n",
      "Pmin=pm*Rw*T0*log(1/yw);\n",
      "print'the minimum gauge pressure that the seawater must be raised if fresh water is to be obtained by reverse osmosis using semipermeable membranes %i kPa'%round(Pmin)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the mole fraction of the water is 0.989000\n",
        "the mole fraction of the saltwater is 0.010980\n",
        "the minimum work input required to separate 1 kg of seawater completely into pure water and pure salts 7.850000 kJ\n",
        "the minimum work input required to obtain 1 kg of fresh water from the sea 1.470000 kJ\n",
        "the minimum gauge pressure that the seawater must be raised if fresh water is to be obtained by reverse osmosis using semipermeable membranes 1510 kPa\n"
       ]
      }
     ],
     "prompt_number": 1
    }
   ],
   "metadata": {}
  }
 ]
}