summaryrefslogtreecommitdiff
path: root/Thermodynamics_An_Engineering_Approach/Chapter8.ipynb
blob: e91e1b788b416ea2367a2b31bc5e1fc58a7f7dbd (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
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 8: Exergy: A Measure of Work Potential"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8-1 ,Page No.426"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi\n",
      "\n",
      "# given data\n",
      "D=12.0;#diameter of rotor in m\n",
      "V=10.0;#average velocity in m/s\n",
      "\n",
      "# density of air at 25C & 1atm\n",
      "p=1.18;\n",
      "\n",
      "#calculations\n",
      "ke=(V**2)/2/1000;#factor of 1000 for converting J into kJ\n",
      "m=p*pi*(D**2)*V/4.0; \n",
      "MP=m*(ke);\n",
      "print'Maximum power %f kW'%round(MP,1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum power 66.700000 kW\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8-2 ,Page No.427"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given values\n",
      "TH=2000.0;#temperature of large furnace in R\n",
      "T0=77+460.0;#temperature of enviroment in R\n",
      "Qin=3000.0;#heat rate in Btu/sec\n",
      "\n",
      "#calculation\n",
      "nth=1-(T0/TH);\n",
      "Wmax=nth*Qin;\n",
      "Wmax=round(Wmax)\n",
      "print'the rate of energy flow %i Btu/s'%round(Wmax)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the rate of energy flow 2195 Btu/s\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8-3 ,Page No.429"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "Tsink=300.0;#temperature of sink in K\n",
      "Tsource=1200.0;#temperature of source in K\n",
      "Qin=500.0;#heat rate in kJ/s\n",
      "Wuout=180;#power output in W\n",
      "\n",
      "#calculations\n",
      "Wrev=(1-Tsink/Tsource)*Qin;\n",
      "print'The reversible power %i kW'%round(Wrev);\n",
      "I=Wrev-Wuout;\n",
      "print'the irreversiblity rate %i kW'%round(I)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The reversible power 375 kW\n",
        "the irreversiblity rate 195 kW\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8-4 ,Page No.429"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from scipy.integrate import quad \n",
      "from pylab import *\n",
      "\n",
      "#given data\n",
      "m=500.0;#mass of iron block in kg\n",
      "T1=473.0;#temperature of iron block in K\n",
      "T0=300.0;#temperature of surrondings in K\n",
      "\n",
      "\n",
      "#from Table A-3\n",
      "cavg=0.45;\n",
      "\n",
      "#calculations\n",
      "def intgrnd1(T): \n",
      " return ((1-T0/T)*(-m*cavg))#intergrant\n",
      "Wrev, err = quad(intgrnd1,T1,T0) ;\n",
      "Qtotal=m*cavg*(T1-T0);\n",
      "print'The reversible power %i kJ'%round(Wrev);\n",
      "Wu=0;\n",
      "I=Wrev-Wu;\n",
      "print'the irreversiblity rate %i kJ'%round(I)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The reversible power 8191 kJ\n",
        "the irreversiblity rate 8191 kJ\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8-5 ,Page No.431"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "Wrev=8191.0;#reversible work from Ex - 8.4\n",
      "Wtotal=38925.0;#total work is equivalent to total heat lost to heat engine from Ex - 8.4\n",
      "TL=278.0;#outdoor temperature in K\n",
      "TH=300.0;#temperature of house in K\n",
      "\n",
      "#calculations\n",
      "Wrm=Wtotal-Wrev;#work remaining\n",
      "COPHP=1/(1-TL/TH);\n",
      "Wd=COPHP*Wrev;#work delivered\n",
      "PS=Wd+Wrm;\n",
      "PS=round(PS/1000);#factor of 1000 for converting kJ into MJ\n",
      "print'Maximum amount of heat that can be supplied %i MJ'%PS"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum amount of heat that can be supplied 142 MJ\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8-6 ,Page No.434"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "COP=1.0;# the efficiency that the dealer is referring to is the first law efficiency, meaning that for each unit of electric energy (work) consumed, the heater will supply the house with 1 unit of energy (heat). That is,the advertised heater has a COP of 1\n",
      "TL=283.0;#outdoor temperature in K\n",
      "TH=294.0;#indoor temperature in K\n",
      "\n",
      "#calculations\n",
      "COPHP=1/(1-TL/TH);\n",
      "nII=COP/COPHP;\n",
      "print'the second law efficiency %f'%round(nII,3)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the second law efficiency 0.037000\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8-7 ,Page No.438"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import log\n",
      "\n",
      "#given data\n",
      "P1=1000.0;#pressure of compressed air in KPa\n",
      "V=200.0;#volumne of rigid tank in m^3\n",
      "T1=300.0;#temperature of enviroment in K\n",
      "T0=T1;#state of air in tank\n",
      "P0=100.0;#pressure of enviroment in KPa\n",
      "\n",
      "#constants used\n",
      "R=0.287;#in kPa m^3/kg K\n",
      "\n",
      "#calculations\n",
      "m1=P1*V/(R*T1);\n",
      "O1=R*T0*(P0/P1-1)+R*T0*log(P1/P0);# O refers to exergy\n",
      "X1=m1*O1/1000;#factor of 1000 for converting kJ into MJ\n",
      "print'work obtained %i MJ'%round(X1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "work obtained 281 MJ\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8-8 ,Page No.439"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "T0=20+273;#temperature of enviroment in K\n",
      "P1=0.14;#intail pressure in MPa\n",
      "T1=-10;#intail temperature in K\n",
      "P2=0.8;#final pressure in MPa\n",
      "T2=50;#final temperature in K\n",
      "\n",
      "#the properties of refrigerant\n",
      "#at inlet\n",
      "h1=246.36;\n",
      "s1=0.9724;\n",
      "#at outlet\n",
      "h2=286.69;\n",
      "s2=0.9802;\n",
      "dO=h2-h1-T0*(s2-s1);# O refers to exergy\n",
      "print'the exergy change of the refrigerant %i kJ/kg'%round(dO)\n",
      "wmin=dO;\n",
      "print'the minimum work input that needs to be supplied is %i kJ/kg'%wmin"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the exergy change of the refrigerant 38 kJ/kg\n",
        "the minimum work input that needs to be supplied is 38 kJ/kg\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8-10 ,Page No.447"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given values\n",
      "Q=1035.0;#rate of heat transfer in W\n",
      "T0=273.0;#outdoor temperature in C\n",
      "Tin=293.0;#inner wall surface temperature in K\n",
      "Tout=278.0;#outer wall surface temperature in K\n",
      "T1=300.0;#indoor temperature in C\n",
      "\n",
      "#calculations\n",
      "#Xin - Xout - Xdestroyed = dX/dt\n",
      "Xdestroyed=Q*(1-T0/Tin)-Q*(1-T0/Tout);\n",
      "Xdestroyed=round(Xdestroyed);\n",
      "print'the rate of exergy destroyed %i W'%round(Xdestroyed);\n",
      "#the total rate of exergy destroyed\n",
      "Xdestroyed=Q*(1-T0/T1)-Q*(1-T0/T0);\n",
      "print'the total of exergy destroyed %f W'%round(Xdestroyed,1);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the rate of exergy destroyed 52 W\n",
        "the total of exergy destroyed 93.100000 W\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8-11 ,Page No.448"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "m=0.05;#mass of steam in kg\n",
      "P1=1000;#intial pressure in MPa\n",
      "T1=300+273;#intial temperature in K\n",
      "P2=200;#final pressure in MPa\n",
      "T2=150+273;#final temperature in K\n",
      "P0=100;#pressure of surroundings in KPa\n",
      "T0=25+273;#temperature of surroundings in K\n",
      "Qout=2;#heat losses in kJ\n",
      "\n",
      "#from Table A-6 & A-4\n",
      "u1=2793.7;\n",
      "v1=0.25799;\n",
      "s1=7.1246;\n",
      "u2=2577.1;\n",
      "v2=0.95986;\n",
      "s2=7.2810;\n",
      "u0=104.83;\n",
      "v0=0.00103;\n",
      "s0=0.3672;\n",
      "\n",
      "#calculations\n",
      "X1=m*(u1-u0-T0*(s1-s0)+P0*(v1-v0));\n",
      "X2=m*(u2-u0-T0*(s2-s0)+P0*(v2-v0));\n",
      "print'exergy of intial state %i kJ'%round(X1);\n",
      "print'exergy of final state %f kJ'%round(X2,1);\n",
      "dX=X2-X1;\n",
      "print'exergy change in system %f kJ'%round(dX,1);\n",
      "Wout=-Qout-m*(u2-u1);\n",
      "Wu=Wout-P0*m*(v2-v1);\n",
      "Xdestroyed=X1-X2-Wu;\n",
      "print'the exergy destroyed %f kJ'%round(Xdestroyed,1);\n",
      "nII=Wu/(X1-X2);\n",
      "print'second law efficiency of this process is %f'%round(nII,3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "exergy of intial state 35 kJ\n",
        "exergy of final state 25.400000 kJ\n",
        "exergy change in system -9.700000 kJ\n",
        "the exergy destroyed 4.300000 kJ\n",
        "second law efficiency of this process is 0.551000\n"
       ]
      }
     ],
     "prompt_number": 42
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8-12 ,Page No.451"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from scipy.integrate import quad \n",
      "from pylab import *\n",
      "\n",
      "#given data\n",
      "m=2.0;#mass of air in lbm\n",
      "T0=70+460.0;#intial temperature in R\n",
      "P1=20.0;#intial pressure in psia\n",
      "T1=70+460.0;#temperature of surroundings in R\n",
      "T2=130+460.0;#final temperature in R\n",
      "\n",
      "#constants used\n",
      "Cv=0.172;#in Btu/lbm - F\n",
      "\n",
      "#calculations\n",
      "Xdestroyed=T0*m*Cv*log(T2/T1);\n",
      "print'exergy destroyed %f Btu'%round(Xdestroyed,1);\n",
      "def intgrnd1(T): \n",
      " return ((1-T0/T)*m*Cv)#intergrant\n",
      "Wrev, err = quad(intgrnd1,T1,T2) ;\n",
      "print'the reversible work %f Btu'%round(Wrev,1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "exergy destroyed 19.600000 Btu\n",
        "the reversible work 1.100000 Btu\n"
       ]
      }
     ],
     "prompt_number": 45
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8-13 ,Page No.453"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "T0=20+273.0;#temperature of surrounding in K\n",
      "P0=100.0;#pressure of surrounding in kPa\n",
      "Tiw=30+273.0;#temperature of water in K\n",
      "mw=100.0;#mass of water in kg\n",
      "Tii=350+273.0;#temperature of block in K\n",
      "mi=5.0;#mass of block in kg\n",
      "\n",
      "#constants used(Table A-3)\n",
      "cw=4.18;#specific heat of water in kJ/kg C\n",
      "ci=0.45;#specific heat of iron in kJ/kg C\n",
      "\n",
      "#calculations\n",
      "Tfk=(mi*ci*Tii+mw*cw*Tiw)/(mw*cw+mi*ci);\n",
      "Tfc=Tfk-273;#in C\n",
      "print'the final equilibrium temperature %f C'%round(Tfc,1);\n",
      "X1i=mi*ci*(Tii-T0-T0*log(Tii/T0));\n",
      "X1w=mw*cw*(Tiw-T0-T0*log(Tiw/T0));\n",
      "X1t=X1i+X1w;#total exergy \n",
      "print'intial exergy of combined systems %i kJ'%round(X1t);\n",
      "X2i=mi*ci*(Tfk-T0-T0*log(Tfk/T0));\n",
      "X2w=mw*cw*(Tfk-T0-T0*log(Tfk/T0));\n",
      "X2t=X2i+X2w;#total exergy \n",
      "print'intial exergy of combined systems %f kJ'%round(X2t,1);\n",
      "Xdestroyed=X1t-X2t;\n",
      "print'the wasted work %f kJ'%round(Xdestroyed,1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the final equilibrium temperature 31.700000 C\n",
        "intial exergy of combined systems 315 kJ\n",
        "intial exergy of combined systems 95.800000 kJ\n",
        "the wasted work 219.100000 kJ\n"
       ]
      }
     ],
     "prompt_number": 46
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8-14 ,Page No.455"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "TR=1200.0;#temperature of furnace \n",
      "T0=300;#temperature of surrounding in K\n",
      "P0=100;#pressure of surrounding in kPa\n",
      "Tsys=400.0;#temperature of argon in K\n",
      "P1=350;#temperature of argon in K\n",
      "V1=0.01;#intail volumne in m^3\n",
      "V2=2*V1;#final volumne\n",
      "\n",
      "#calculations\n",
      "W=P1*V1*log(V2/V1);\n",
      "Wsurr=P0*(V2-V1);\n",
      "Wu=W-Wsurr;\n",
      "print'the useful work output %f kJ'%round(Wu,2);\n",
      "# Qin - W = m*Cv*dT, Since dt=0\n",
      "Q=W;\n",
      "Sgen=Q/Tsys-Q/TR;\n",
      "Xdestroyed=T0*Sgen;\n",
      "print'the exergy destroyed %f kJ/K'%round(Xdestroyed,2);\n",
      "Wrev=T0*Q/Tsys-Wsurr+(1-T0/TR)*Q;\n",
      "print'the reversible work is done in the process %f kJ'%round(Wrev,2);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the useful work output 1.430000 kJ\n",
        "the exergy destroyed 1.210000 kJ/K\n",
        "the reversible work is done in the process 2.640000 kJ\n"
       ]
      }
     ],
     "prompt_number": 48
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8-15 ,Page No.460"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculation error in textbook in part - b which changes all the following answers\n",
      "\n",
      "#given data\n",
      "m=8.0;#mass flow rate in kg/s\n",
      "T0=298.0;#temperature of surrounding in K\n",
      "P0=100.0;#pressure of surrounding in kPa\n",
      "P1=3000.0;#inlet pressure in kPa\n",
      "T1=450.0;#inlet temperature in K\n",
      "P2=200.0;#outlet pressure in kPa\n",
      "T2=150.0;#outlet temperature in K\n",
      "Qout=300.0;#heat rate in kW\n",
      "\n",
      "#from Table A-6 and A-4\n",
      "h1=3344.9;\n",
      "s1=7.0856;\n",
      "h2=2769.1;\n",
      "s2=7.2810;\n",
      "h0=104.83;\n",
      "s0=0.3672;\n",
      "\n",
      "#calculations\n",
      "# Ein = Eout\n",
      "Wout=m*(h1-h2)-Qout;\n",
      "Wout=round(Wout)\n",
      "print'the actual power output %i kW'%Wout\n",
      "# Xin = Xout\n",
      "Wrev=m*(h1-h2)-(T0*(s1-s2));\n",
      "Wrev=round(Wrev);\n",
      "print'the maximum possible work output %i kW'%Wrev;\n",
      "nII=Wout/Wrev;\n",
      "print'second law efficiency is %f'%round(nII,3);\n",
      "Xdestroyed=Wrev-Wout;\n",
      "print'the exergy destroyed %i kW'%round(Xdestroyed);\n",
      "X1=h1-h0-T0*(s1-s0);\n",
      "print'the exergy of the steam at inlet conditions %i kJ/kg'%round(X1);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the actual power output 4306 kW\n",
        "the maximum possible work output 4665 kW\n",
        "second law efficiency is 0.923000\n",
        "the exergy destroyed 359 kW\n",
        "the exergy of the steam at inlet conditions 1238 kJ/kg\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8-16 ,Page No.462"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "T0=70+460;#temperature of surroundings in R\n",
      "T1=50;#temperature of water in F\n",
      "T2=240;#temperature of steam in F\n",
      "T3=130;#outlet temperature in F\n",
      "#as dicussed in example 7-20\n",
      "m1=300;#mass flow rate of water in lbm/min\n",
      "m2=22.7;#mass flow rate of steam in lbm/min\n",
      "m3=322.7;#outlet mass flow rate  in lbm/min\n",
      "\n",
      "#from steam tables\n",
      "h1=18.07;\n",
      "s1=0.03609;\n",
      "h2=1162.3;\n",
      "s2=1.7406;\n",
      "h3=97.99;\n",
      "s3=0.18174;\n",
      "\n",
      "#calculations\n",
      "Wrev=m1*(h1-T0*s1)+m2*(h2-T0*s2)-m3*(h3-T0*s3);\n",
      "Wrev=round(Wrev);\n",
      "print'the reversible power %i Btu/min'%round(Wrev)\n",
      "Xdestroyed=Wrev;\n",
      "print'the rate of exergy destruction %i Btu/min'%Xdestroyed\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the reversible power 4588 Btu/min\n",
        "the rate of exergy destruction 4588 Btu/min\n"
       ]
      }
     ],
     "prompt_number": 56
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8-17 ,Page No.463"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "V=200.0;#volumne of rigid tank in m^3\n",
      "P1=100.0;#intial surroundings in kPa\n",
      "P2=1000.0;#final pressure in kPa\n",
      "P0=100.0;#pressure of surroundings in kPa\n",
      "T=300.0;#temperature of surroundings in K\n",
      "\n",
      "#constants used\n",
      "R=0.287;#in kPa m^3/kg K\n",
      "\n",
      "#calculations\n",
      "#Xin - Xout = Xdestroyed = X2 - X1\n",
      "m2=P2*V/(R*T);\n",
      "X2=R*T*(log(P2/P0)+P0/P2-1);\n",
      "Wrev=m2*X2/1000;\n",
      "Wrev=round(Wrev);\n",
      "print'Work requirement %i MJ'%Wrev\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Work requirement 281 MJ\n"
       ]
      }
     ],
     "prompt_number": 58
    }
   ],
   "metadata": {}
  }
 ]
}