summaryrefslogtreecommitdiff
path: root/Basic_And_Applied_Thermodynamics_by_P._K._Nag/Chapter16.ipynb
blob: bd0ffde7d82ec5cd44c0a1f83c3bb51d803a5f49 (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
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 16:Reactive Systems"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex16.2:pg-675"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 16.2\n",
      "\n",
      "\n",
      " K is  0.314529177004  atm\n",
      "\n",
      " Epsilon is  0.611607081035\n",
      "\n",
      " The heat of reaction is  60974.6120608  kJ/kg mol\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "eps_e = 0.27  # Constant\n",
    "P = 1.0 # Atmospheric pressure in bar\n",
    "K = (4*eps_e**2*P)/(1-eps_e**2) \n",
    "P1 = 100.0/760.0 # Pressure in Pa\n",
    "eps_e_1 = math.sqrt((K/P1)/(4.0+(K/P1)))\n",
    "T1 = 318.0 # Temperature in K\n",
    "T2 = 298.0# Temperature in K\n",
    "R = 8.3143 # Gas constant\n",
    "K1 = 0.664 # dissociation constant at 318K\n",
    "K2 = 0.141# dissociation constant at 298K\n",
    "dH = 2.30*R*((T1*T2)/(T1-T2))*(math.log10(K1/K2))\n",
    "print \"\\n Example 16.2\\n\"\n",
    "print \"\\n K is \",K ,\" atm\"\n",
    "print \"\\n Epsilon is \",eps_e_1\n",
    "print \"\\n The heat of reaction is \",dH ,\" kJ/kg mol\"\n",
    "#The answers vary due to round off error\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex16.3:pg-675"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 16.3\n",
      "\n",
      "\n",
      " Equilibrium constant is  1.61983471074\n",
      "\n",
      " Gibbs function change is  -4812.22485358 J/gmol\n"
     ]
    }
   ],
   "source": [
    "v1 = 1.0 # Assumed\n",
    "v2 = v1# Assumed \n",
    "v3 = v2 # Assumed\n",
    "v4 = v2# Assumed\n",
    "e = 0.56 # Degree of reaction\n",
    "P = 1.0 # Dummy\n",
    "T = 1200.0 # Reaction temperature in K\n",
    "R = 8.3143 # Gas constant\n",
    "x1 = (1-e)/2.0 # \n",
    "x2 = (1-e)/2.0\n",
    "x3 = e/2.0 \n",
    "x4 = e/2.0\n",
    "K = (((x3**v3)*(x4**v4))/((x1**v1)*(x2**v2)))*P**(v3+v4-v1-v2) # Equilibrium constant\n",
    "dG = -R*T*math.log(K) #Gibbs function change\n",
    "\n",
    "print \"\\n Example 16.3\\n\"\n",
    "print \"\\n Equilibrium constant is \",K\n",
    "print \"\\n Gibbs function change is \",dG ,\"J/gmol\"\n",
    "#The answers vary due to round off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex16.5:pg-678"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 16.5\n",
      "\n",
      "\n",
      " The value of equillibrium constant is  0.755668681281  atm\n"
     ]
    }
   ],
   "source": [
    "Veo = 1.777 # Ve/Vo\n",
    "e = 1.0-Veo # Degree of dissociation\n",
    "P = 0.124 # in atm\n",
    "K = (4*e**2*P)/(1.0-e**2)\n",
    "\n",
    "print \"\\n Example 16.5\\n\"\n",
    "print \"\\n The value of equillibrium constant is \",K ,\" atm\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex16.6:pg-680"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 16.6\n",
      "\n",
      "\n",
      " Cp is  4.48364424966  J/g mol K\n"
     ]
    }
   ],
   "source": [
    "v1 = 1.0 # Assumed\n",
    "v2 = 0 # Assumed\n",
    "v3 = 1.0 # Assumed\n",
    "v4 = 1.0/2.0# Assumed\n",
    "dH = 250560.0 # Enthalpy change in j/gmol\n",
    "e = 3.2e-03 # Constant\n",
    "R = 8.3143 # Gas constant\n",
    "T = 1900.0 # Reaction temperature\n",
    "Cp = ((dH**2)*(1+e/2)*e*(1+e))/(R*T**2*(v1+v2)*(v3+v4))\n",
    "print \"\\n Example 16.6\\n\"\n",
    "print \"\\n Cp is \",Cp ,\" J/g mol K\"\n",
    "#The answers vary due to round off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex16.7:pg-681"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 16.7\n",
      "\n",
      "\n",
      " The composition of fuel is  14.7645650439  percent Hydrogen and  85.2354349561  percent Carbon\n",
      "\n",
      " Air fuel ratio is  23.9829146049\n",
      "\n",
      " Percentage of excess air used is  67.2268907563  percent\n"
     ]
    }
   ],
   "source": [
    "\n",
    "a = 21.89 # stochiometric coefficient\n",
    "y = 18.5 # stochiometric coefficient\n",
    "x = 8.9 # stochiometric coefficient\n",
    "PC = 100*(x*12)/((x*12)+(y)) # Carbon percentage\n",
    "PH = 100-PC # Hydrogen percentage\n",
    "AFR = ((32*a)+(3.76*a*28))/((12*x)+y) #Air fuel ratio\n",
    "EAU = (8.8*32)/((21.89*32)-(8.8*32)) # Excess air used\n",
    "\n",
    "print \"\\n Example 16.7\\n\"\n",
    "print \"\\n The composition of fuel is \",PH ,\" percent Hydrogen and \",PC ,\" percent Carbon\"#The answer provided in the textbook is wrong\n",
    "print \"\\n Air fuel ratio is \",AFR\n",
    "print \"\\n Percentage of excess air used is \",EAU*100 ,\" percent\"\n",
    "#The answers vary due to round off error\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex16.8:pg-682"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 16.8\n",
      "\n",
      "\n",
      " Heat transfer per kg mol of fuel is  -965198.0  kJ\n",
      "\n",
      " Q_cv is  -890324.0  kJ\n"
     ]
    }
   ],
   "source": [
    "hf_co2 = -393522.0 # Enthalpy of reaction in kJ/kg mol\n",
    "hf_h20 = -285838.0# Enthalpy of reaction in kJ/kg mol\n",
    "hf_ch4 = -74874.0# Enthalpy of reaction in kJ/kg mol\n",
    "D = hf_co2 + (2*hf_h20) #Heat transfer \n",
    "QCV = D-hf_ch4 # Q_cv\n",
    "\n",
    "print \"\\n Example 16.8\\n\"\n",
    "print \"\\n Heat transfer per kg mol of fuel is \",D ,\" kJ\"\n",
    "print \"\\n Q_cv is \",QCV ,\" kJ\"\n",
    "#The answers vary due to round off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex16.9:pg-683"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 16.9 \n",
      "\n",
      "\n",
      " Fuel consumption rate is  38.5131749981  kg/h\n"
     ]
    }
   ],
   "source": [
    "# Below values are taken from table\n",
    "Hr = -249952+(18.7*560)+(70*540)\n",
    "Hp = 8*(-393522+20288)+9*(-241827+16087)+6.25*14171+70*13491\n",
    "Wcv = 150.0 # Energy out put from engine in kW\n",
    "Qcv = -205.0 # Heat transfer from engine in kW\n",
    "n = (Wcv-Qcv)*3600/(Hr-Hp)\n",
    "print \"\\n Example 16.9 \\n\"\n",
    "print \"\\n Fuel consumption rate is \",n*114 ,\" kg/h\"\n",
    "#The answers vary due to round off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex16.11:pg-684"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 16.11 \n",
      "\n",
      "\n",
      " Reversible work is  47139  kJ/kg\n",
      "\n",
      " Increase in entropy during combustion is  3699.6688  kJ/kg mol K\n",
      "\n",
      " Irreversibility of the process  25056.8559091  kJ/kg\n",
      "\n",
      " Availability of products of combustion is  22082.1440909  kJ/kg\n"
     ]
    }
   ],
   "source": [
    "# Refer table 16.4 for values\n",
    "T0 = 298.0 # Atmospheric temperature in K\n",
    "Wrev = -23316-3*(-394374)-4*(-228583) # Reversible work in kJ/kg mol\n",
    "Wrev_ = Wrev/44 # Reversible work in kJ/kg\n",
    "Hr = -103847 # Enthalpy of reactants in kJ/kg\n",
    "T = 980.0 # Through trial and error\n",
    "Sr = 270.019+20*205.142+75.2*191.611 # Entropy of reactants\n",
    "Sp = 3*268.194 + 4*231.849 + 15*242.855 + 75.2*227.485 # Entropy of products\n",
    "IE = Sp-Sr # Increase in entropy\n",
    "I = T0*3699.67/44 # Irreversibility\n",
    "Si = Wrev_ - I# Availability of products of combustion \n",
    "\n",
    "print \"\\n Example 16.11 \\n\"\n",
    "print \"\\n Reversible work is \",Wrev_ ,\" kJ/kg\"\n",
    "print \"\\n Increase in entropy during combustion is \",Sp-Sr ,\" kJ/kg mol K\"\n",
    "print \"\\n Irreversibility of the process \",I ,\" kJ/kg\"\n",
    "print \"\\n Availability of products of combustion is \",Si ,\" kJ/kg\"\n",
    "#The answers vary due to round off error\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex16.12:pg-685"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 6.12\n",
      "\n",
      "\n",
      " The chemical energy of carbon is   410541.588354  kJ/k mol\n",
      "\n",
      " The chemical energy of hydrogen is   235211.889921  kJ/k mol\n",
      "\n",
      " The chemical energy of methane is   821580.156423  kJ/k mol\n",
      "\n",
      " The chemical energy of Carbon monoxide is   275364.910207  kJ/k mol\n",
      "\n",
      " The chemical energy of liquid methanol is   716698.69005  kJ/k mol\n",
      "\n",
      " The chemical energy of nitrogen is   691.0909601  kJ/k mol\n",
      "\n",
      " The chemical energy of Oxygen is   3946.64370597  kJ/k mol\n",
      "\n",
      " The chemical energy of Carbon dioxide is   20108.2320604  kJ/k mol\n",
      "\n",
      " The chemical energy of Water is   5.21177422707  kJ/k mol\n"
     ]
    }
   ],
   "source": [
    "\n",
    "T0 = 298.15 # Environment temperature in K\n",
    "P0 = 1 # Atmospheric pressure in bar\n",
    "R = 8.3143# Gas constant\n",
    "xn2 = 0.7567  # mole fraction of nitrogen\n",
    "xo2 = 0.2035 # mole fraction of oxygen\n",
    "xh2o = 0.0312 # mole fraction of water\n",
    "xco2 = 0.0003# mole fraction of carbon dioxide\n",
    "# Part (a)\n",
    "g_o2 = 0 # Gibbs energy of oxygen\n",
    "g_c = 0 # Gibbs energy of carbon\n",
    "g_co2 = -394380  # Gibbs energy of carbon dioxide\n",
    "A = -g_co2 + R*T0*math.log(xo2/xco2) # Chemical energy\n",
    "\n",
    "# Part (b)\n",
    "g_h2 = 0 # Gibbs energy of hydrogen\n",
    "g_h2o_g = -228590# # Gibbs energy of water\n",
    "B = g_h2 + g_o2/2 - g_h2o_g + R*T0*math.log(xo2**0.5/xh2o)\n",
    "# Chemical energy\n",
    "# Part (c)\n",
    "g_ch4 = -50790 # Gibbs energy of methane\n",
    "C = g_ch4 + 2*g_o2 - g_co2 - 2*g_h2o_g + R*T0*math.log((xo2**2)/(xco2*xh2o))\n",
    "# Chemical energy\n",
    "# Part (d)\n",
    "g_co = -137150# # Gibbs energy of carbon mono oxide\n",
    "D =  g_co + g_o2/2 - g_co2 + R*T0*math.log((xo2**0.5)/xco2)\n",
    "# Chemcal energy\n",
    "# Part (e)\n",
    "g_ch3oh = -166240 # Gibbs energy of methanol\n",
    "E = g_ch3oh + 1.5*g_o2 - g_co2 - 2*g_h2o_g + R*T0*math.log((xo2**1.5)/(xco2*(xh2o**2)))\n",
    "# Chemical energy\n",
    "# Part (f)\n",
    "F = R*T0*math.log(1/xn2)\n",
    "# Chemical energy\n",
    "# Part (g)\n",
    "G = R*T0*math.log(1/xo2)\n",
    "# Chemical energy\n",
    "# Part (h)\n",
    "H = R*T0*math.log(1/xco2)\n",
    "# Chemical energy\n",
    "# Part (i)\n",
    "g_h2o_l = -237180 #  Gibbs energy of liquid water\n",
    "I = g_h2o_l - g_h2o_g + R*T0*math.log(1/xh2o)\n",
    "# Chemical energy\n",
    "print \"\\n Example 6.12\\n\"\n",
    "print \"\\n The chemical energy of carbon is  \",A ,\" kJ/k mol\"\n",
    "print \"\\n The chemical energy of hydrogen is  \",B ,\" kJ/k mol\"\n",
    "print \"\\n The chemical energy of methane is  \",C ,\" kJ/k mol\"\n",
    "print \"\\n The chemical energy of Carbon monoxide is  \",D ,\" kJ/k mol\"\n",
    "print \"\\n The chemical energy of liquid methanol is  \",E ,\" kJ/k mol\"\n",
    "print \"\\n The chemical energy of nitrogen is  \",F ,\" kJ/k mol\"\n",
    "print \"\\n The chemical energy of Oxygen is  \",G ,\" kJ/k mol\"\n",
    "print \"\\n The chemical energy of Carbon dioxide is  \",H ,\" kJ/k mol\"\n",
    "print \"\\n The chemical energy of Water is  \",I ,\" kJ/k mol\"\n",
    "#The answers vary due to round off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex16.13:pg-686"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 6.13\n",
      "\n",
      "\n",
      " The rate of heat transfer from the engine =  -4.33120060702  kW,\n",
      " The second law of efficiency of the engine =  13.3396896634  percent\n"
     ]
    }
   ],
   "source": [
    "# Environmet\n",
    "T0 = 298.15 # Environment temperature in K\n",
    "P0 = 1.0 # Atmospheric pressure in atm\n",
    "R = 8.3143# Gas constant\n",
    "xn2 = 0.7567  # mole fraction of nitrogen\n",
    "xo2 = 0.2035 # mole fraction of oxygen\n",
    "xh2o = 0.0312 # mole fraction of water\n",
    "xco2 = 0.0003# mole fraction of carbon dioxide\n",
    "xother = 0.0083 # Mole fraction of other gases\n",
    "# Liquid octane\n",
    "t1 = 25.0 # Temperature of liquid octane in degree centigrade\n",
    "m = 0.57 # Mass flow rate in kg/h\n",
    "T2 = 670 # Temperature of combustion product at exit in K\n",
    "x1 = 0.114 # Mole fraction of CO2\n",
    "x2 = .029 # Mole fraction of CO\n",
    "x3 = .016 # Mole fraction of O2\n",
    "x4 = .841 # Mole fraction of N2\n",
    "Wcv = 1 # Power developed by the engine in kW\n",
    "print \"\\n Example 6.13\\n\"\n",
    "# By carbon balance \n",
    "b = 55.9 \n",
    "# By hydrogen balace\n",
    "c=9\n",
    "# By oxygen balance\n",
    "a = 12.58\n",
    "Qcv = Wcv- 3845872*(.57/(3600*114.22))\n",
    "E = 5407843.0 # Chemical exergy of C8H18\n",
    "nII = Wcv/(E*.57/(3600*114.22))\n",
    "print \"\\n The rate of heat transfer from the engine = \",Qcv ,\" kW,\\n The second law of efficiency of the engine = \",nII*100 ,\" percent\""
   ]
  }
 ],
 "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
}