summaryrefslogtreecommitdiff
path: root/Thermodynamics/Chapter7.ipynb
blob: a9e9200ab325007557f40500f29acd480d46dcc8 (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
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
{
 "metadata": {
  "name": "",
  "signature": "sha256:0bbd88c617eea37997c2d1895d18307cb6167940684ace795d89722f10167f53"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 7:COMBINED FIRST AND SECOND LAWS APPLICATION TO PROCESSES"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.1, Page No:316"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "p1=1; # Initial pressure of fluid in MPa\n",
      "T1=250; # Initial temperture of fluid in degree celcius\n",
      "V=0.28; # Volume of container in m^3\n",
      "p2=0.35; # Initial pressure of the fluid in MPa\n",
      "#   (a).Water\n",
      "v1=0.2327; # specific volume of vapour from steam table at state 1 in m^3/kg\n",
      "v2=v1; # constant volume process\n",
      "vf2=0.001079; vfg2=0.5232; #  specific volume of vapour from steam table at state 2 in m^3/kg\n",
      "\n",
      "#Calculation for (a)\n",
      "m=V/v1; # mass of steam\n",
      "x2=(v2-vf2)/vfg2; # quality of steam at state 2\n",
      "t2=138.88; # Final temperature of fluid in degree celcius (saturation temperature at p2)\n",
      "# following are the values taken from steam tables\n",
      "u1=2709.9; # specific internal energy at state 1 in kJ/kg\n",
      "s1=6.9247; # Specific entropy at state 1 in kJ/kg K\n",
      "uf2=582.95; ug2=2548.9; # specific internal energy at state 2 in kJ/kg\n",
      "sf2=1.7245; sg2=6.9405; # Specific entropy at state 2 in kJ/kg K\n",
      "u2=(1-x2)*uf2+x2*ug2; # specific internal energy at state 2 \n",
      "s2=(1-x2)*sf2+x2*sg2; # specific enropy  at state 2 \n",
      "Q=m*(u2-u1); # Heat transferred\n",
      "S21=m*(s2-s1); # Entropy change\n",
      "\n",
      "#Result for (a)\n",
      "print \"(a).Water\",\"Final Temperature = \",t2,\"oC\",\"\\nHeat transferred = \",round(Q,3),\"kJ   (answer mentioned in the textbook is wrong)\"\n",
      "print \"Entropy change = \",round(S21,3),\"kJ/kg K   (round off error)\"\n",
      "\n",
      "#Calculation for (b)\n",
      "#   (b).Air\n",
      "Cvo=0.7165; # Specific heat at constant volume in kJ/kg K\n",
      "R=0.287; # characteristic gas constant of air in kJ/kg K\n",
      "m=(p1*10**3*V)/(R*(T1+273)); # Mass of air\n",
      "T2=(p2/p1)*(273+T1); # Final temperature of air\n",
      "Q=m*Cvo*(T2-(T1+273)); # Heat transferred\n",
      "S21=m*Cvo*math.log (T2/(273+T1)); # Change in entropy\n",
      "\n",
      "#Result for (b)\n",
      "print \"\\n(b).Air\",\"Final Temperature = \",round(T2,0),\"oC\",\"\\nHeat transferred = \",round(Q,0),\"kJ   (roundoff error)\"\n",
      "print \"Entropy change = \",round(S21,3),\"kJ/kg K   (round off error)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a).Water Final Temperature =  138.88 oC \n",
        "Heat transferred =  -1512.051 kJ   (answer mentioned in the textbook is wrong)\n",
        "Entropy change =  -3.479 kJ/kg K   (round off error)\n",
        "\n",
        "(b).Air Final Temperature =  183.0 oC \n",
        "Heat transferred =  -454.0 kJ   (roundoff error)\n",
        "Entropy change =  -1.403 kJ/kg K   (round off error)\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.2, Page No:319"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "p1=1.0021; # Initial pressure of the fluid in MPa\n",
      "T1=180; # Initial temperature of the fluid in degree celcius\n",
      "m=0.5; # Mass of the fluid in kg\n",
      "p2=p1; # Constant pressure process\n",
      "#   (a).Steam\n",
      "x1=0.8; # Quality of the steam at state 1\n",
      "# Following are the values taken from steam table \n",
      "vf1=0.001127; vfg1=0.1929; # specific volume of the steam in m^3/kg\n",
      "hf1=763.2; hfg1=2015; # specific enthalpy in kJ/kg \n",
      "sf1=2.1396; sfg1=4.4460; # specific entropy in kJ/kg K\n",
      "\n",
      "#Calculation for (a)\n",
      "v1=vf1+x1*vfg1; # specific volume in m^3/kg\n",
      "h1=hf1+x1*hfg1; # specific enthalpy in kJ/kg \n",
      "s1=sf1+x1*sfg1; # specific entropy in kJ/kg K\n",
      "v2=2*v1; # Final volume of the fluid\n",
      "t2=410.5; # Final temperature of steam in degree celcius (from superheated steam table)\n",
      "h2=3286.4; # specific enthalpy in kJ/kg \n",
      "s2=7.525; # specific entropy in kJ/kg K\n",
      "S21=m*(s2-s1); # Change in entropy\n",
      "W=m*p1*10**3*(v2-v1); # Work done\n",
      "Q=m*(h2-h1); # Heat transferred\n",
      "\n",
      "#Result for (a)\n",
      "print \"(a).Steam\",\"Final Temperature = \",t2+273,\"K\",\"\\nChange in entropy = \",S21,\"kJ/K   (Error in textbook)\"\n",
      "print \"Work done = \",round(W,1),\"kJ\",\"\\nHeat transferred = \",Q,\"kJ\"\n",
      "\n",
      "#Calculation for (b)\n",
      "# (b).Air\n",
      "Cpo=1.0035; # Specific heat at constant pressure in kJ/kg K\n",
      "R=0.287; # characteristic gas constant of air in kJ/kg K\n",
      "V1=m*R*(T1+273)/(p1*10**3); # Initil volume\n",
      "V2=2*V1; # Final volume\n",
      "T2=(T1+273)*V2/V1; # Final temperature\n",
      "S21=m*Cpo*math.log (V2/V1); # Change in entropy\n",
      "W=p1*10**3*(V2-V1); # Work done\n",
      "Q=m*Cpo*(T2-(T1+273));# Heat transferred\n",
      "\n",
      "#Result for (b)\n",
      "print \"\\n(b).Air\",\"Final Temperature = \",T2,\"K\",\"\\nChange in entropy = \",round(S21,3),\"kJ/K\"\n",
      "print \"Work done = \",round(W,0),\"kJ\",\"\\nHeat transferred = \",round(Q,1),\"kJ\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a).Steam Final Temperature =  683.5 K \n",
        "Change in entropy =  0.9143 kJ/K   (Error in textbook)\n",
        "Work done =  77.9 kJ \n",
        "Heat transferred =  455.6 kJ\n",
        "\n",
        "(b).Air Final Temperature =  906.0 K \n",
        "Change in entropy =  0.348 kJ/K\n",
        "Work done =  65.0 kJ \n",
        "Heat transferred =  227.3 kJ\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.3, Page No:321"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "m=1.5; # Mass of the fluid in kg\n",
      "p1=1; # Initial pressure of fluid in bar\n",
      "T1=150; # Initial temperture of fluid in degree celcius\n",
      "v2=0.3; # Final specific volume in m^3/kg\n",
      "#   (a).Steam\n",
      "# Following are the values taken from steam table \n",
      "u1=2582.8; # specific internal energy in kJ/kg\n",
      "s1=7.6134; # specific entropy in kJ/kg K\n",
      "vf2=0.001091; vfg2=0.3917; # specific volume of the steam in m^3/kg\n",
      "sf2=1.8418; sfg2=4.9961; # specific entropy in kJ/kg K\n",
      "uf2=631.7; ufg2=1927.8; # specific internal energy in kJ/kg\n",
      "\n",
      "#Calculation for (a)\n",
      "x2=(v2-vf2)/vfg2; # Quality of steam at state 2\n",
      "s2=sf2+x2*sfg2; # specific entropy in kJ/kg K\n",
      "u2=uf2+x2*ufg2; # specific internal energy in kJ/kg\n",
      "S21=m*(s2-s1); # Change in entropy\n",
      "U21=m*(u2-u1); # Change in internal energy\n",
      "Q=(T1+273)*(S21); # Heat transferred\n",
      "W=Q-U21; # Work done\n",
      "\n",
      "#Result for (a)\n",
      "print \"(a).Steam\",\"\\nChange in internal energy = \",round(U21,0),\"kJ\"\n",
      "print \"Change in entropy = \",round(S21,4),\"kJ/K\",\"\\nWork done = \",round(W,1),\"kJ\",\"\\nHeat transferred = \",round(Q,1),\"kJ\"\n",
      "\n",
      "#Calculation for (b)\n",
      "#   (b).Air\n",
      "U21=0; # From fig 7.6\n",
      "R=0.287; # characteristic gas constant of air in kJ/kg K\n",
      "v1=(R*(T1+273))/(p1*10**2); # initial specific volume\n",
      "S21=m*R*math.log (v2/v1); # Change in entropy\n",
      "Q=(T1+273)*(S21); # Heat transferred\n",
      "W=Q; # Work done\n",
      "\n",
      "#Result for(b)\n",
      "print \"\\n(b).Air\",\"\\nChange in internal energy = \",round(U21,0),\"kJ\"\n",
      "print \"Change in entropy = \",round(S21,4),\"kJ/K\",\"\\nWork done = \",round(W,1),\"kJ\",\"\\nHeat transferred = \",round(Q,1),\"kJ\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a).Steam \n",
        "Change in internal energy =  -720.0 kJ\n",
        "Change in entropy =  -2.9386 kJ/K \n",
        "Work done =  -523.0 kJ \n",
        "Heat transferred =  -1243.0 kJ\n",
        "\n",
        "(b).Air \n",
        "Change in internal energy =  0.0 kJ\n",
        "Change in entropy =  -0.6018 kJ/K \n",
        "Work done =  -254.6 kJ \n",
        "Heat transferred =  -254.6 kJ\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.4, Page No:323"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "m=1.5; # Mass of the fluid in kg\n",
      "p1=1.6; # Initial pressure of fluid in MPa\n",
      "T1=250; # Initial temperture of fluid in degree celcius\n",
      "p2=150; # Initial pressure of the fluid in kPa\n",
      "#   (a).Steam\n",
      "# Following are the values taken from steam table \n",
      "# state 1 is superheated\n",
      "u1=2692.3; # specific internal energy in kJ/kg\n",
      "s1=6.6732; # specific entropy in kJ/kg K\n",
      "v1=0.14184; # specific volume of the steam in m^3/kg\n",
      "# State 2 is wet (s1=s2<sg2)\n",
      "T2=111.37; # Final temperature of steam in degree celcius\n",
      "sf2=1.4336; sfg2=5.7897; # specific entropy in kJ/kg K\n",
      "uf2=466.94; ufg2=2052.7; # specific internal energy in kJ/kg\n",
      "\n",
      "#Calculation for (a)\n",
      "x2=(s1-sf2)/sfg2; # Quality of steam at state 2\n",
      "u2=uf2+x2*ufg2; # specific internal energy in kJ/kg\n",
      "W=-m*(u2-u1);# Work done\n",
      "\n",
      "#Result for (a)\n",
      "print \"(a).Steam\",\"\\nFinal temperature of steam =\",T2+273,\"K\",\"\\nWork done = \",round(W,1),\"kJ\"\n",
      "\n",
      "#Calculation for (b)\n",
      "#   (b).Air\n",
      "Cvo=0.7165; # Specific heat at constant volume in kJ/kg K\n",
      "k=1.4; # index of reversible adiabatic process\n",
      "T2=(T1+273)*((p2*10**-3)/p1)**((k-1)/k); # Final temperature of air\n",
      "W=-m*Cvo*(T2-(T1+273)); # Work done\n",
      "\n",
      "#Result for (b)\n",
      "print \"(b).Air\",\"\\nFinal temperature of steam =\",round(T2,1),\"K\",\"\\nWork done = \",round(W,1),\"kJ\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a).Steam \n",
        "Final temperature of steam = 384.37 K \n",
        "Work done =  551.5 kJ\n",
        "(b).Air \n",
        "Final temperature of steam = 265.9 K \n",
        "Work done =  276.3 kJ\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "`Example 7.5, Page No:325"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "m=1.5; # Mass of the fluid in kg\n",
      "p1=1.6; # Initial pressure of fluid in MPa\n",
      "T1=250; # Initial temperture of fluid in degree celcius\n",
      "p2=150; # Initial pressure of the fluid in kPa\n",
      "n=1.25; # Index of polytropic process\n",
      "#   (a).Steam\n",
      "# Following are the values taken from steam table \n",
      "# state 1 is superheated\n",
      "u1=2692.3; # specific internal energy in kJ/kg\n",
      "s1=6.6732; # specific entropy in kJ/kg K\n",
      "v1=0.14184; # specific volume of the steam in m^3/kg\n",
      "\n",
      "#Calculation for (a)\n",
      "v2=v1*(p1/(p2*10**-3))**(1/n); # specific volume of the steam at state 2\n",
      "# State 2 is wet \n",
      "T2=111.37; # Final temperature of steam in degree celcius\n",
      "vf2=0.0010531; vfg2=1.1582; # specific volume of the steam in m^3/kg\n",
      "x2=(v2-vf2)/vfg2; # Quality of steam at state 2\n",
      "sf2=1.4336; sfg2=5.7897; # specific entropy in kJ/kg K\n",
      "uf2=466.94; ufg2=2052.7; # specific internal energy in kJ/kg\n",
      "s2=sf2+x2*sfg2; # specific entropy in kJ/kg K\n",
      "u2=uf2+x2*ufg2; # specific internal energy in kJ/kg\n",
      "W=m*((p2*v2)-(p1*10**3*v1))/(1-n); # Work done\n",
      "Q=m*(u2-u1)+W; # Heat ttransferred\n",
      "S21=m*(s2-s1); # Change in entropy\n",
      "\n",
      "#Result for (a)\n",
      "print \"(a).Steam\",\"\\nFinal Temperature = \",T2+273,\"K\",\"\\nChange in entropy = \",round(S21,1),\"kJ/K\"\n",
      "print \"Work done = \",round(W,0),\"kJ\",\"\\nHeat transferred = \",round(Q,0),\"kJ\"\n",
      "\n",
      "#Calculation for (b)\n",
      "#   (b).Air\n",
      "R=0.287; # characteristic gas constant of air in kJ/kg K\n",
      "Cvo=0.7165; # Specific heat at constant volume in kJ/kg K\n",
      "T2=(T1+273)*((p2*10**-3)/p1)**((n-1)/n); # Final temperature of air\n",
      "W=m*R*(T2-(T1+273))/(1-n); # Work done\n",
      "Q=m*Cvo*(T2-(T1+273))+W; # Heat transferred\n",
      "S21=m*(Cvo+R/(1-n))*math.log (T2/(T1+273)); # Change in entropy\n",
      "\n",
      "#Result for (b)\n",
      "print \"\\n(b).Air\",\"\\nFinal Temperature = \",round(T2,0),\"K\",\"\\nChange in entropy = \",round(S21,3),\"kJ/K\"\n",
      "print \"Work done = \",round(W,0),\"kJ\",\"\\nHeat transferred = \",round(Q,1),\"kJ\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a).Steam \n",
        "Final Temperature =  384.37 K \n",
        "Change in entropy =  -0.8 kJ/K\n",
        "Work done =  514.0 kJ \n",
        "Heat transferred =  -322.0 kJ\n",
        "\n",
        "(b).Air \n",
        "Final Temperature =  326.0 K \n",
        "Change in entropy =  0.306 kJ/K\n",
        "Work done =  340.0 kJ \n",
        "Heat transferred =  127.7 kJ\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.6, Page No:335"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "m=1; # Massflow rate of the steam in kg/s\n",
      "p1=3.5; # Pressure at inlet in MPa\n",
      "T1=400; # Temperature at inlet in degree celcius\n",
      "V1=250; # Velocity of stesm at inlet in m/s\n",
      "p2=50; # Pressure at outlet in kPa\n",
      "T2=100; # Temperature at outlet in degree celcius\n",
      "V2=30; # Velocity of stesm at outlet in m/s\n",
      "# For actual expansion in the turbine\n",
      "h1=3222.3; h2=2682.5; # specific enthalpy in kJ/kg at inlet and exit\n",
      "\n",
      "#Calculation\n",
      "wa=h1-h2+(V1**2-V2**2)/2000; # Work done\n",
      "W=m*wa; # Power output\n",
      "# For reversible adiabatic expansion\n",
      "# Following are the values taken from steam table \n",
      "s1=6.8405; # specific entropy in kJ/kg K\n",
      "s2s=s1; # Isentropic expansion\n",
      "sf2=1.091; sfg2=6.5029; # specific entropy in kJ/kg K\n",
      "hf2=340.49; hfg2=2305.4; # specific enthalpy in kJ/kg\n",
      "x2s=(s1-sf2)/sfg2; # Quality of steam at state 2\n",
      "h2s=hf2+x2s*hfg2; # specific enthalpy in kJ/kg\n",
      "ws=h1-h2s+(V1**2-V2**2)/2000; # Isentropic Work done\n",
      "eff_isen=wa/ws; # Isentropic efficiency of the turbine\n",
      "\n",
      "#Result\n",
      "print \"Power output of the turbine = \",round(W,0),\"kW   (Error in textbook)\"\n",
      "print \"Isentropic efficiency of the turbine = \",round(eff_isen*100,1),\"%   (Error in textbook)\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power output of the turbine =  571.0 kW   (Error in textbook)\n",
        "Isentropic efficiency of the turbine =  65.3 %   (Error in textbook)\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.7, Page No:336"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "m=1; # Massflow rate of the steam in kg/s\n",
      "p1=3.5; # Pressure at inlet in bar\n",
      "T1=160; # Temperature at inlet in degree celcius\n",
      "p2=1; # Pressure at outlet in bar\n",
      "Cpo=1.005; # Specific heat at constant pressure in kJ/kg K\n",
      "eff_isen=0.85; # Isentropic efficiency of the turbine\n",
      "k=1.4; # index of isentropic process\n",
      "\n",
      "#Calculation\n",
      "T2s=(T1+273)*(p2/p1)**((k-1)/k); # Final temperature after isentropic expansion\n",
      "Ws=m*Cpo*((T1+273)-T2s); # Isentropic power developed\n",
      "Wa=eff_isen*Ws; # Actual power developed\n",
      "T2=(T1+273)-(Wa/(m*Cpo)); # Final temperature after expansion\n",
      "\n",
      "#Result\n",
      "print \"Actual power developed =\",round(Wa,0),\"kW  (Error in textbook)\",\n",
      "print \"\\nFinal temperature after expansion = \",round(T2,1),\"K(Roundoff error)\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Actual power developed = 111.0 kW  (Error in textbook) \n",
        "Final temperature after expansion =  322.3 K(Roundoff error)\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.8, Page No: 339"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "m=0.05; # mass flowrate of Freon 12 in kg/s\n",
      "p1=300; # Pressure of Freon 12 at inlet in kpa\n",
      "t1=5; # Temperature of Freon 12 at inlet in degree celcius\n",
      "p2=1.2; # Pressure of Freon 12 at outlet in MPa\n",
      "t2=80; # Temperature of Freon 12 at outlet in degree celcius\n",
      "W=-2.3; # Power consumption of compressor in kW\n",
      "#   (a).Heat transfer from the body of compressor to environment\n",
      "# From  the table of properties of Freon 12\n",
      "h1= 190.8; h2=230.4; # specific enthalpy in kJ/kg \n",
      "s1=0.71; s2=0.7514 # specific entropy in kJ/kg K\n",
      "\n",
      "#Calculation for (a)\n",
      "Q=m*(h2-h1)+W; # Heat transfer \n",
      "\n",
      "#Result for (a)\n",
      "print \"(a).Heat transfer from the body of compressor to environment =\",Q,\"kW\"\n",
      "\n",
      "#Calculation for (b)\n",
      "#   (b).Adiabatic efficiency of the compressor\n",
      "# For adiabatic compression p2=1.2Mpa,s2s=s1\n",
      "t2s=61.7;# Temperature of Freon 12 at outlet in degree celcius\n",
      "h2s=216.14; # specific enthalpy in kJ/kg \n",
      "ws=(h2s-h1); # Reversible adiabatic work\n",
      "wa=W/m; # Actual work\n",
      "eff_com=abs (ws/wa); # Adiabatic efficiency\n",
      "\n",
      "#Result for (b)\n",
      "print \"\\n(b).Adiabatic efficiency of the compressor = \",round(eff_com*100,0),\"%\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a).Heat transfer from the body of compressor to environment = -0.32 kW\n",
        "\n",
        "(b).Adiabatic efficiency of the compressor =  55.0 %\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.9, Page No:340"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "p1=1; # Pressure of air at inlet of compressor in bar\n",
      "T1=30; # Temperature of air at inlet of compressor in degree celcius\n",
      "p2=12; # Delivery pressure of air in bar\n",
      "T2=400; # Temperature of air at inlet of compressor in degree celcius\n",
      "V2=90; # Velocity of air at exit in m/s\n",
      "w=3740; # Power input to compressor in kW\n",
      "k=1.4; # Index of reversible adiabatic process\n",
      "Cpo=1.0035; # Specific heat at constant pressure in kJ/kg K\n",
      "\n",
      "#Calculation\n",
      "wa=Cpo*(T2-T1)+V2**2/2000; # Actual specific work input\n",
      "m=w/wa; # Mass flow rate of air\n",
      "T2s=(T1+273)*(p2/p1)**((k-1)/k);# Isentropic discharge temperature\n",
      "ws=Cpo*(T2s-(T1+273))+V2**2/2000; # Isentropic work\n",
      "eff_com=ws/wa; # Isentrpic efficiency\n",
      "\n",
      "#Result\n",
      "print \"Isentropic discharge temperature = \",round(T2s,1),\"K\",\"\\nIsentrpic efficiency of compressor =\",round(eff_com*100,0),\"%\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Isentropic discharge temperature =  616.3 K \n",
        "Isentrpic efficiency of compressor = 85.0 %\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exapmle 7.10, Page No:344"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "p1=3; # Pressure of fluid at inlet in bar\n",
      "T1=150; # Temperature of fluid at inlet in degree celcius\n",
      "V1=90; # Velocity of fluid at inlet in m/s \n",
      "eff_nozzle=0.85; # Nozzle efficiency\n",
      "k=1.4; # Index of reversible adiabatic process\n",
      "p2=1/3*p1;\n",
      "#   (a).Steam\n",
      "# Following are taken from steam table\n",
      "h1=2761; # specific enthalpy in kJ/kg \n",
      "s1=7.0778;# specific entropy in kJ/kg K\n",
      "s2s=s1; # Isentropic process\n",
      "sf2s=1.3026; sfg2s=6.0568;# specific entropy in kJ/kg K\n",
      "hf2=417.46; hfg2=2258; # specific enthalpy in kJ/kg \n",
      "\n",
      "#Calculation for (a)\n",
      "x2s=(s2s-sf2s)/sfg2s; # Quality of steam\n",
      "h2s=hf2+x2s*hfg2;\n",
      "V2s=math.sqrt (2000*(h1-h2s)+V1**2); # Isentropic Velocity \n",
      "V2=math.sqrt (eff_nozzle) *V2s; # Actual nozzle exit velocity\n",
      "\n",
      "#Result for (a)\n",
      "print \"(a).Steam\",\"\\nActual nozzle exit velocity = \",round(V2,1),\"m/s   (round off error)\"\n",
      "\n",
      "#Calculation for (b)\n",
      "#   (b).Air\n",
      "Cpo=1.0035; # Specific heat at constant pressure in kJ/kg K\n",
      "T2s=(T1+273)*(p2/p1)**((k-1)/k); # Isentropic temperature\n",
      "V2s=math.sqrt ((2000*Cpo*((T1+273)-T2s))+V1**2); # Isentropic Velocity and (answer mentioned in the textbook is wrong)\n",
      "V2=math.sqrt (eff_nozzle) *V2s; # Actual nozzle exit velocity\n",
      "\n",
      "#Result for (b)\n",
      "print \"\\n(b).Air\",\"\\n Actual nozzle exit velocity = \",round(V2,1),\"m/s   (answer mentioned in the textbook is wrong)\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a).Steam \n",
        "Actual nozzle exit velocity =  575.1 m/s   (round off error)\n",
        "\n",
        "(b).Air \n",
        " Actual nozzle exit velocity =  448.7 m/s   (answer mentioned in the textbook is wrong)\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.11, Page No:348"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "p1=200; # Pressure of fluid at inlet in kPa\n",
      "T1=200; # Temperature of fluid at inlet in degree celcius\n",
      "V1=700; # Velocity of fluid at inlet in m/s \n",
      "V2=70; # Velocity of fluid at outlet in m/s \n",
      "#   (a).Reversible Adiabatic process\n",
      "# state of steam entering diffuser (superheated)\n",
      "h1=2870.5;# specific enthalpy in kJ/kg \n",
      "s1=7.5066; # specific entropy in kJ/kg K\n",
      "\n",
      "#Calculation for (a)\n",
      "h2=h1+(V1**2-V2**2)/2000; # From first and second laws\n",
      "s2=s1; # Isentropic peocess\n",
      "# From superheated table\n",
      "p2s=550; # Pressure of fluid at outlet in kPa\n",
      "T2=324; # Temperature of fluid at outlet in degree celcius\n",
      "\n",
      "#Result for (a)\n",
      "print \"(a).Reversible adiabatic process\",\"\\nPressure of fluid at outlet = \",p2s,\"kPa\"\n",
      "print \"Temperature of fluid at outlet =\",T2,\"oC\"\n",
      "\n",
      "#Calculation for (b)\n",
      "#   (b).Actual diffusion\n",
      "# for the same change in K.E, from first law\n",
      "h2=3113.1;# specific enthalpy in kJ/kg\n",
      "p2=400; # Actual exit pressure in kPa\n",
      "t2=322.4; # from superheated table in degree celcius\n",
      "eff_d=(p2-p1)/(p2s-p1); # Diffuser efficiency\n",
      "\n",
      "#Result for (b)\n",
      "print \"\\n(b).Actual diffusion\",\"\\nThe exit temperature =\",t2,\"oC\",\"\\nDiffuser efficiency = \",round(eff_d*100,0),\"%\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a).Reversible adiabatic process \n",
        "Pressure of fluid at outlet =  550 kPa\n",
        "Temperature of fluid at outlet = 324 oC\n",
        "\n",
        "(b).Actual diffusion \n",
        "The exit temperature = 322.4 oC \n",
        "Diffuser efficiency =  57.0 %\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.12, Page No:349"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "p1=1; # Pressure of fluid at inlet in bar\n",
      "T1=60; # Temperature of fluid at inlet in degree celcius\n",
      "p2=2.8; # Pressure of fluid at outlet in bar\n",
      "eff_d=0.80; # Diffuser efficiency\n",
      "k=1.4; # Index of reversible adiabatic process\n",
      "Cpo=1.0035; # Specific heat at constant pressure in kJ/kg K\n",
      "\n",
      "#Calculation\n",
      "#   (a).Actual Diffuser\n",
      "p2s=((p2-p1)/eff_d)+p1; # Isentropic pressure\n",
      "T2=(T1+273)*(p2s/p1)**((k-1)/k); # Exit temperature\n",
      "V1=math.sqrt (2000*Cpo*(T2-(T1+273))); # Initial Velocity\n",
      "\n",
      "#Result for (a)\n",
      "print \"(a).Actual Diffuser\",\"\\nTemperature of air leaving diffuser =\",round(T2,1),\"K\"\n",
      "print \"Initial Velocity =\",round(V1,1),\"m/s\"\n",
      "\n",
      "#Calculation for (b)\n",
      "#   (b).Reversible Adiabatic diffuser\n",
      "T2s=(T1+273)*(p2/p1)**((k-1)/k); # Isentropic exit temperature\n",
      "V1=math.sqrt (2000*Cpo*(T2s-(T1+273))); # Initial Velocity\n",
      "\n",
      "#Result for (b)\n",
      "print \"\\n(b).Reversible Adiabatic diffuser\",\"\\nTemperature of air leaving diffuser =\",round(T2s,0),\"K\"\n",
      "print \"Initial Velocity =\",round(V1,1),\"m/s\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a).Actual Diffuser \n",
        "Temperature of air leaving diffuser = 466.3 K\n",
        "Initial Velocity = 517.3 m/s\n",
        "\n",
        "(b).Reversible Adiabatic diffuser \n",
        "Temperature of air leaving diffuser = 447.0 K\n",
        "Initial Velocity = 478.1 m/s\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.13, Page No:350"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "m=18; # mass flow rate of air in kg/s\n",
      "p1=3.6; # Pressure of fluid at inlet of turbine in MPa\n",
      "T1=800; # Temperature of fluid at inlet of turbine in Kelvin\n",
      "V1=100; # Velocity of fluid at inlet of turbine in m/s \n",
      "V2=150; # Velocity of fluid at outlet of turbine in m/s\n",
      "W=3.6; # Power output of turbine in MW\n",
      "p3=1.01; # pressure at diffuser outlet in bar\n",
      "k=1.4; # Index of reversible adiabatic process\n",
      "Cpo=1.0035; # Specific heat at constant pressure in kJ/kg K\n",
      "\n",
      "#Calculation\n",
      "# (a)    Pressure at diffuser inlet\n",
      "T2=((Cpo*T1)-((W*10**3)/m+(V2**2-V1**2)/2000))/Cpo; # Temperature at outlet of turbine\n",
      "T3=(T2+273)+((V2**2)/(2*Cpo*10**3)); # Temperature of fluid at diffuser inlet\n",
      "p2=p3*((T2+273)/T3)**(k/(k-1)); #pressure at diffuser inlet\n",
      "\n",
      "#Result \n",
      "print \"(a).pressure at diffuser inlet =\",round(p2,3),\"bar\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a).pressure at diffuser inlet = 0.966 bar\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.14, Page No:351"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "T1=35; # Temperature of freon 12 before throttling in degree celcius\n",
      "T2=5; # Temperature of freon 12 after throttling in degree celcius\n",
      "# from property table of freon 12\n",
      "h1=69.49;# specific enthalpy in kJ/kg \n",
      "hf2=40.66; hfg2=148.86; # specific enthalpy in kJ/kg \n",
      "h2=h1; # throttling process\n",
      "\n",
      "#Calculation \n",
      "x2=(h2-hf2)/hfg2; # Quality of Freon 12 vapour\n",
      "\n",
      "#Result\n",
      "print \"Quality of Freon 12 vapour = \",round(x2,3)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Quality of Freon 12 vapour =  0.194\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.15, Page No:353"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "p2=276; # Pressure at inlet in kPa\n",
      "p=6.5; # gauge pressure at outlet in cm Hg\n",
      "T3=110; # Temperature at outlet in degree celcius\n",
      "pa=756; # Barometric pressure in mm Hg\n",
      "mc=760;# Mass of condensed steam in g\n",
      "ms=25; # Mass of separated water in g\n",
      "den=13600; # Density of mercury in kg/m^3\n",
      "g=9.81; # Acceleration due to gravity in m/s^2\n",
      "\n",
      "#Calculation\n",
      "z=(pa*10**-3)+(p*10**-2);# absolute pressure in m Hg\n",
      "p3=den*g*z; # Pressure after throttling\n",
      "h3=2697.4;# specific enthalpy in kJ/kg \n",
      "hf2=545.31; hfg2=2175.2; # specific enthalpy in kJ/kg \n",
      "x2=(h3-hf2)/hfg2; # Quality of steam\n",
      "x1=(mc/(mc+ms))*x2; # Quality of steam in the main line\n",
      "\n",
      "#Result\n",
      "print \"Quality of steam in the main line =\",round(x1,4),\"   (roundoff error)\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Quality of steam in the main line = 0.9579    (roundoff error)\n"
       ]
      }
     ],
     "prompt_number": 15
    }
   ],
   "metadata": {}
  }
 ]
}