summaryrefslogtreecommitdiff
path: root/Thermodynamics_An_Engineering_Approach/Chapter15.ipynb
blob: c167fe7309a22851f0c17de35a1fbc11db73d67d (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
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 15: Chemical Reactions"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15-1 ,Page No.755"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "nO2i=20;#intial moles of air \n",
      "nC8H18i=1;#intial moles octane\n",
      "\n",
      "#from Table A-1\n",
      "Mair=29;\n",
      "MC=12;\n",
      "MH=2;\n",
      "\n",
      "#calculations\n",
      "# Chemical Reaction\n",
      "# C8H18 + 20(O2+3.76N2)= xCO2 + yH2O +  zO2 + wN2\n",
      "#by elemental balance of moles\n",
      "x=8;\n",
      "y=18/2;\n",
      "z=20*2-2*x-y;\n",
      "w=20*3.76;\n",
      "print'kmoles of CO2 %i'%x;\n",
      "print'kmoles of H2O %i'%y;\n",
      "print'kmoles of O2 %f'%round(z,1);\n",
      "print'kmoles of N2 %f'%round(w,1);\n",
      "#thus equn becomes\n",
      "# C8H18 + 20(O2+3.76N2)= 8CO2 + 9H2O +  7.5O2 +75.2N2\n",
      "AF=nO2i*4.76*Mair/(x*MC + y*MH);\n",
      "print'air-fuel ratio of combustion process %f kg air/kg fuel'%round(AF,1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "kmoles of CO2 8\n",
        "kmoles of H2O 9\n",
        "kmoles of O2 15.000000\n",
        "kmoles of N2 75.200000\n",
        "air-fuel ratio of combustion process 24.200000 kg air/kg fuel\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15-2 ,Page No.757"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "P=100;#total pressure in kPa\n",
      "\n",
      "#from Table A-1\n",
      "Mair=29.0;\n",
      "MC=12.0;\n",
      "MH=2.0;\n",
      "\n",
      "#calculations\n",
      "#Chemical reaction\n",
      "#C2H6 +  1.2at(1O2 +  3.76) =2CO2 +  3H2O +  0.2athO2 + (1.2*3.76)athN2\n",
      "#ath is the stoichiometric coefficient for air\n",
      "#Oxygen balance gives\n",
      "# 1.2ath = 2 + 1.5 + 0.2ath\n",
      "ath=(2+1.5)/(1.2-0.2);\n",
      "AF=(1.2*ath)*4.76*Mair/(2*MC+3*MH);\n",
      "print'air-fuel ratio of combustion process %f kg air/kg fuel'%round(AF,1);\n",
      "#C2H6 + 4.2(O2 + 3.76N2)  = 2CO2 + 3H2O + 0.7O2 + 15.79N2;\n",
      "Nprod=2+3+0.7+15.79;\n",
      "#for dew point water vapour condenses\n",
      "Nv=3;\n",
      "Pv=Nv/Nprod*P;\n",
      "#at this Pv\n",
      "Tdp=52.3;\n",
      "print'the dew-point %f C'%Tdp\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "air-fuel ratio of combustion process 19.300000 kg air/kg fuel\n",
        "the dew-point 52.300000 C\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15-3 ,Page No.758"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "P=101.325;#total pressure in kPa\n",
      "RH=0.8;#realtive humidity\n",
      "T1=20;#tempearture of air in C\n",
      "\n",
      "#from Table A-4\n",
      "Psat=2.3392;\n",
      "\n",
      "#calculations\n",
      "#consedering 1 kmol of fuel\n",
      "# 0.72CH4 + 0.09H2 + 0.14N2 + 0.02O2 + 0.03CO2 +  ath(O2 + 3.76N2) = xCO2 + yH2O + zN2\n",
      "#element balance\n",
      "x=0.72+0.03\n",
      "y=(0.72*4+0.09*2)/2;\n",
      "ath=x+y/2-0.02-0.03;\n",
      "z=0.14+3.76*ath;\n",
      "Pv=RH*Psat;\n",
      "# Nv,air = Pv,air/Ptotal * Ntotal\n",
      "Nvair=Pv/P*6.97/(1-(Pv/P));\n",
      "#0.72CH4 + 0.09H2 + 0.14N2 + 0.02O2 + 0.03CO2 +  1.465(O2 + 3.76N2) + 0.131H20 = 0.75CO2 + 1.661H2O + 5.648N2\n",
      "Pvprod=1.661/8.059*P;\n",
      "#at this Pvprod\n",
      "Tdp=60.9;\n",
      "print'the dew-point %f C'%Tdp"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the dew-point 60.900000 C\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15-4 ,Page No.760"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "Pprod=100;#total pressure in kPa\n",
      "\n",
      "#from Table A-1\n",
      "Mair=29;\n",
      "MC=12;\n",
      "MH=2;\n",
      "\n",
      "#from Table A-4\n",
      "Psat=3.1698;\n",
      "\n",
      "#calculations\n",
      "#consedering 100 kmol of dry products\n",
      "# xC8H18 + a (O2 + 3.76N2) = 10.02CO2 + 0.88C0 + 84.48N2 + bH20\n",
      "#from mass balamces\n",
      "a=83.48/3.76;\n",
      "x=(0.88+10.02)/8;\n",
      "b=18*x/2;\n",
      "# 1.36C8H18 + 22.2 (O2 + 3.76N2) = 10.02CO2 + 0.88C0 + 84.48N2 + 12.24H20\n",
      "# 1 mol conversion\n",
      "# C8H18 + 16.32 (O2 + 3.76N2) = 7.37CO2 + 4.13C0 + 61.38N2 + 9H20\n",
      "AF= 16.32*4.76*Mair/(8*MC+9*MH);\n",
      "print'air-fuel ratio of combustion process %f kg air/kg fuel'%round(AF,2);\n",
      "# C8H18 + ath (O2 + 3.76N2) = 8CO2 + 9H2O + 3.76athN2\n",
      "ath=8+4.5;\n",
      "Pth=16.32/ath*4.76/4.76*100;\n",
      "print'percentage of theoretical air is %i'%round(Pth);\n",
      "Nprod=7.37+0.65+4.13+61.98+9;\n",
      "# Nv/Nprod = Pv/Pprod\n",
      "Pv=Psat;\n",
      "Nw= (Nprod*Pv-9*Pprod)/(Pv-Pprod);\n",
      "print'the amount of H2O that condenses as the products %f kmol'%round(Nw,2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "air-fuel ratio of combustion process 19.760000 kg air/kg fuel\n",
        "percentage of theoretical air is 131\n",
        "the amount of H2O that condenses as the products 6.570000 kmol\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15-5 ,Page No.764"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#there is a difference in the answer due to approximation in the textbook\n",
      "\n",
      "#given data\n",
      "T=25;#temperature of octane in C\n",
      "\n",
      "#from Table A-6\n",
      "HCO2=-393520;\n",
      "HH2O=-285830;\n",
      "HC8H18=-249950;\n",
      "\n",
      "#calculations\n",
      "# C8H18 + ath (O2 + 3.76N2) = 8CO2 + 9H2O + 3.76athN2\n",
      "#N2 and O2 are stable elements, and thus their enthalpy of formation is zero\n",
      "#hc = Hprod - Hreact\n",
      "hc= 8*HCO2 + 9*HH2O - HC8H18;\n",
      "print'the enthalpy of combustion of liquid octane %i kJ/kmol'%hc\n",
      "print 'or %i kJ/kg C8H18'%round(hc/114,0)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the enthalpy of combustion of liquid octane -5470680 kJ/kmol\n",
        "or -47989 kJ/kg C8H18\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15-6 ,Page No.767"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "mfuel=0.05;#mass flow rate in kg/min\n",
      "\n",
      "#from Table A-1\n",
      "Mair=29;\n",
      "MC=12;\n",
      "MH=2;\n",
      "\n",
      "#calculation\n",
      "#stochiometric reaction\n",
      "#C3H8 + ath(O2 + 3.76N2) = 3CO2 + 4H2O + 3.76athN2\n",
      "#O2 balance\n",
      "ath=3+5;\n",
      "#50 percent excess air and some CO in the products\n",
      "#C3H8 + 7.5(O2 + 3.76N2) = 2.7CO2 + 0.3CO + 4H2O + 2.65O2+ 28.2N2\n",
      "AF=7.5*4.76*Mair/(3*MC+4*MH);\n",
      "mair=AF*mfuel;\n",
      "print'the mass flow rate of air %f kg air/min'%round(mair,2);\n",
      "#from property tables\n",
      "#C3H8 designated as p\n",
      "hfp=-118910;\n",
      "#oxygen as o\n",
      "hfo=0;\n",
      "ho280=8150;\n",
      "ho298=8682;\n",
      "ho1500=49292;\n",
      "#nitrogen as n\n",
      "hfn=0;\n",
      "hn280=8141;\n",
      "hn298=8669;\n",
      "hn1500=47073;\n",
      "#water as w\n",
      "hfw=-241820;\n",
      "hw298=9904;\n",
      "hw1500=57999;\n",
      "#carbondioxode as c\n",
      "hfc=-393520;\n",
      "hc298=9364;\n",
      "hc1500=71078;\n",
      "#carbon monoxide as co\n",
      "hfco=-110530;\n",
      "hco298=8669;\n",
      "hco1500=47517;\n",
      "qout=1*(hfp)+7.5*(hfo+ho280-ho298)+28.2*(hfn+hn280-hn298)-2.7*(hfc+hc1500-hc298)-0.3*(hfco+hco1500-hco298)-4*(hfw+hw1500-hw298)-2.65*(hfo+ho1500-ho298)-28.2*(hfn+hn1500-hn298);\n",
      "#for kg of propane\n",
      "qout=qout/44;\n",
      "Qout=mfuel*qout/60;\n",
      "print'the rate of heat transfer from the combustion chamber %f kW'%round(Qout,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the mass flow rate of air 1.180000 kg air/min\n",
        "the rate of heat transfer from the combustion chamber 6.890000 kW\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15-7 ,Page No.769"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#the 0.175% error in last part is due to the approximation in the textbook\n",
      "\n",
      "#given data\n",
      "Preact=1.0;#total pressure in kPa\n",
      "Treact=77+460.0;#reaction temperature in R\n",
      "Tprod=1800.0;#final temperature in R\n",
      "\n",
      "#constants used\n",
      "Ru=1.986;\n",
      "\n",
      "#calculation\n",
      "#CH4 + 3O2 = CO2 + 2H2O + O2\n",
      "Nreact=4;\n",
      "Nprod=4;\n",
      "Pprod=Preact*Nprod/Nreact*Tprod/Treact;\n",
      "print'the final pressure in the tank %f atm'%round(Pprod,2);\n",
      "#from std. values of heat of formation and ideal gasses in Appendix\n",
      "#CH4 as m\n",
      "hfm=-32210.0;\n",
      "#O2 as o\n",
      "hfo=0;\n",
      "h537o=3725.1;\n",
      "h1800o=13485.8;\n",
      "#water as w\n",
      "hfw=-104040.0;\n",
      "h537w=4528.0;\n",
      "h1800w=15433.0\n",
      "#carbondioxide as c\n",
      "hfc=-169300.0;\n",
      "h537c=4027.5;\n",
      "h1800c=18391.5;\n",
      "Qout=1*(hfm-Ru*Treact)+3*(hfo-Ru*Treact)-1*(hfc+h1800c-h537c-Ru*Tprod)-2*(hfw+h1800w-h537w-Ru*Tprod)-1*(hfo+h1800o-h537o-Ru*Tprod);\n",
      "print'the heat transfer during this process %i Btu/lbmol'%round(Qout)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the final pressure in the tank 3.350000 atm\n",
        "the heat transfer during this process 309269 Btu/lbmol\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15-8 ,Page No.771"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#this invovles EES hence the below code explains a approach with approximation\n",
      "\n",
      "#calculations\n",
      "\n",
      "#part - a\n",
      "#C8H18 + 12.5 (O2 + 3.76N2) = 8CO+ 9H2O + 47N2\n",
      "#from std. values of heat of formation and ideal gasses in Appendix\n",
      "#octane as oc\n",
      "hfoc=-249950.0;\n",
      "#oxygen as o\n",
      "hfo=0;\n",
      "h298o=8682.0;\n",
      "#nitrogen as n\n",
      "hfn=0;\n",
      "h298n=8669.0;\n",
      "#water as w\n",
      "hfw=-241820.0;\n",
      "h298w=9904.0;\n",
      "#carbondioxide as c\n",
      "hfc=-393520.0;\n",
      "h298c=9364.0;\n",
      "#x refers to 8hCO2 + 9hH20 + 47hN2\n",
      "xac=1*(hfoc)+8*(h298c-hfc)+9*(h298w-hfw)+47*(h298n-hfn);\n",
      "#from EES the Tprod is determined by trial and error\n",
      "#at 2400K\n",
      "x2400=5660828.0;\n",
      "#at 2350K\n",
      "x2350=5526654.0;\n",
      "#the actual value of x is xac and T can be determined by interpolation\n",
      "Tprod=(xac-x2350)*(2400.0-2350.0)/(x2400-x2350)+2350.0;\n",
      "print'adiabatic flame temperature for complete combustion with 100 percent theoretical air %i K'%round(Tprod);\n",
      "\n",
      "#part - b\n",
      "#C8H18 + 50 (O2 + 3.76N2) = 8CO+ 9H2O + 37.5O2 + 188N2\n",
      "#solved similarly using EES and approximation and interpolation\n",
      "#similarly we can solve the part - c \n",
      "#the above concept is applied\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "adiabatic flame temperature for complete combustion with 100 percent theoretical air 2395 K\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15-9 ,Page No.776"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#from Table A-26E\n",
      "#Gibbs function of formation at 77\u00b0F\n",
      "gfc=0;#for carbon\n",
      "gfo=0;#for oxygen\n",
      "gfco=-169680;#for carbondioxide\n",
      "\n",
      "#calculations\n",
      "# C + O2 = CO2\n",
      "Wrev=1*gfc+1*gfo-1*gfco;\n",
      "print'the reversible work for this process %i Btu'%round(Wrev) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the reversible work for this process 169680 Btu\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15-10 ,Page No.777"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import log\n",
      "\n",
      "#given values\n",
      "T0=298;#combustion chamber temperature in K\n",
      "\n",
      "#contansts used \n",
      "Ru=8.314;#in kJ/kmol K\n",
      "\n",
      "#calculations\n",
      "# CH4 + 3(O2 + 3.76N2)  = CO2 + 2H2O + O2 + 11.28N2\n",
      "#from std. values of heat of formation and ideal gasses in Appendix\n",
      "#methane as m\n",
      "hfm=-74850;\n",
      "#oxygen as o\n",
      "hfo=0;\n",
      "h298o=8682;\n",
      "#nitrogen as n\n",
      "hfn=0;\n",
      "h298n=8669;\n",
      "#water as w\n",
      "hfw=-241820;\n",
      "h298w=9904;\n",
      "#carbondioxide as c\n",
      "hfc=-393520;\n",
      "h298c=9364;\n",
      "#x refers to hCO2 + 2hH2O + 11.28hN2\n",
      "xac=1*(hfm)+1*(h298c-hfc)+2*(h298w-hfw)+11.28*(h298n-hfn);\n",
      "#from EES the Tprod is determined by trial and error\n",
      "Tprod=1789;\n",
      "print'the temperature of the products %i K'%round(Tprod);\n",
      "#entropy calculations by using table A-26\n",
      "#Si = Ni*(si - Ruln yiPm\n",
      "#reactants\n",
      "Sm=1*(186.16-Ru*log(1*1));\n",
      "So=3*(205.04-Ru*log(0.21*1));\n",
      "Sn=11.28*(191.61-Ru*log(.79*1));\n",
      "Sreact=Sm+So+Sn;\n",
      "#products\n",
      "Nt=1+2+1+11.28;#total moles\n",
      "yc=1/Nt;\n",
      "yw=2/Nt;\n",
      "yo=1/Nt;\n",
      "yn=11.28/Nt;\n",
      "Sc=1*(302.517-Ru*log(yc*1));\n",
      "Sw=2*(258.957-Ru*log(yw*1));\n",
      "So=1*(264.471-Ru*log(yo*1));\n",
      "Sn=11.28*(247.977-Ru*log(yn*1));\n",
      "Sprod=Sc+Sw+So+Sn;\n",
      "Sgen=Sprod-Sreact;\n",
      "print'exergy destruction %i kJ/kmol - K'%round(Sgen);\n",
      "Xdestroyed=T0*Sgen/1000;#factor of 1000 for converting kJ to MJ\n",
      "print'%i MJ/kmol'%round(Xdestroyed);\n",
      "#This process involves no actual work. Therefore, the reversible work and energy destroyed are identical\n",
      "Wrev=Xdestroyed;\n",
      "print'the reversible work %i MJ/kmol'%round(Wrev)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the temperature of the products 1789 K\n",
        "exergy destruction 966 kJ/kmol - K\n",
        "288 MJ/kmol\n",
        "the reversible work 288 MJ/kmol\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15-11 ,Page No.778"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import log\n",
      "\n",
      "#given values\n",
      "Tsurr=298;#temperature of surroundings in K\n",
      "\n",
      "#contansts used \n",
      "Ru=8.314;#in kJ/kmol K\n",
      "\n",
      "#calculations\n",
      "\n",
      "#part - a\n",
      "# CH4 + 3(O2 + 3.76N2)  = CO2 + 2H2O + O2 + 11.28N2\n",
      "#The amount of water vapor that remains in the products is determined as in Example 15\u20133\n",
      "Nv=0.43;#moles of water vapour\n",
      "Nw=1.57;#moles of water in liquid\n",
      "#hf values\n",
      "#methane as m\n",
      "hfm=-74850;\n",
      "#carbondioxide as c\n",
      "hfc=-393520;\n",
      "#water vapour as v\n",
      "hfv=-241820;\n",
      "#water in liquid as w\n",
      "hfw=-285830;\n",
      "Qout=1*hfm-1*hfc-Nv*hfv-Nw*hfw;\n",
      "print'Qout = %i kJ/kmol'%round(Qout)\n",
      "\n",
      "#part - b\n",
      "#entropy calculations by using table A-26\n",
      "#Si = Ni*(si - Ruln yiPm\n",
      "#reactants\n",
      "Sm=1*(186.16-Ru*log(1*1));\n",
      "So=3*(205.04-Ru*log(0.21*1));\n",
      "Sn=11.28*(191.61-Ru*log(.79*1));\n",
      "Sreact=Sm+So+Sn;\n",
      "#products\n",
      "Nt=Nv+1+1+11.28;#total moles\n",
      "yw=1;\n",
      "yc=1/Nt;\n",
      "yv=Nv/Nt;\n",
      "yo=1/Nt;\n",
      "yn=11.28/Nt;\n",
      "Sw=Nw*(69.92-Ru*log(yw*1));\n",
      "Sc=1*(213.80-Ru*log(yc*1));\n",
      "Sv=Nv*(188.83-Ru*log(yv*1));\n",
      "So=1*(205.04-Ru*log(yo*1));\n",
      "Sn=11.28*(191.61-Ru*log(yn*1));\n",
      "Sprod=Sc+Sw+So+Sn+Sv;\n",
      "Sgen=Sprod-Sreact+Qout/Tsurr;\n",
      "print'Sgen = %i kJ/kmol - K'%round(Sgen);\n",
      "Xdestroyed=Tsurr*Sgen/1000;#factor of 1000 for converting kJ to MJ\n",
      "print'exergy destruction %i MJ/kmol'%round(Xdestroyed);\n",
      "#This process involves no actual work. Therefore, the reversible work and energy destroyed are identical\n",
      "Wrev=Xdestroyed;\n",
      "print'the reversible work %i MJ/kmol'%round(Wrev)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Qout = 871406 kJ/kmol\n",
        "Sgen = 2746 kJ/kmol - K\n",
        "exergy destruction 818 MJ/kmol\n",
        "the reversible work 818 MJ/kmol\n"
       ]
      }
     ],
     "prompt_number": 4
    }
   ],
   "metadata": {}
  }
 ]
}