summaryrefslogtreecommitdiff
path: root/Applied_Thermodynamics_by_Onkar_Singh/Chapter6.ipynb
blob: d100fbbeec5f2b7af6af6f0e2d99521a98bcd08c (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
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
{
 "metadata": {
  "name": "",
  "signature": "sha256:4c5adc7ff722a4bfcaaad47e052db064cf85c767ab3f0fe6ba8aa04ddc1a515a"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 6: Thermodynamic Properties of Pure Substance"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2, page no. 182"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable Declaration: \n",
      "p1 = 10 #Pressure at which steam is entering(in MPa):\n",
      "p2 = 0.05 #Pressure at which steam is coming out(in MPa):\n",
      "T = 100 #Temperature of the steam(inC):\n",
      "h2 = 2682.5 #Enthalpy of superheated steam at 0.05 MPa and 100 C(in kJ/kg): #From steam tables:\n",
      "hf10 = 1407.56\n",
      "hfg10 = 1317.1\n",
      "\n",
      "#Calculation:\n",
      "h1 = h2 #Due to throttling:\n",
      "x1 = (h1-hf10)/hfg10 #Dryness fraction:\n",
      "\n",
      "#Results:\n",
      "print \"Dryness fraction: \",round(x1,3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Dryness fraction:  0.968\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3, page no. 183"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable Declaration: \n",
      "p = 12 #Pressure(in MPa):\n",
      "v = 0.017 #Specific volume(in m**3/kg):\n",
      "h = 2848 #Enthaply(in kJ/kg):\n",
      "\n",
      "#Calculation:\n",
      "u = h-p*10**3*v #Internal energy(in kJ/kg):\n",
      "\n",
      "#Results:\n",
      "print \"Internal energy: \",round(u),\"KJ/Kg\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Internal energy:  2644.0 KJ/Kg\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4, page no. 183"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "  \n",
      "from math import log\n",
      "\n",
      "#Variable Declaration: \n",
      "m = 5      #Mass of steam(in kg):\n",
      "p = 2    #Pressure(in MPa):\n",
      "Tss = 300+273.15 #Temperature of superheated steam(in K):\n",
      "Cps = 2.1  #Specific heat of super heated steam(in kJ/kg.K):\n",
      "Cpw = 4.18  #Specific heat of water(in kJ/kg.K):\n",
      "hfg = 1890.7  #From steam tables:\n",
      "\n",
      "#Calculations:\n",
      "Tsat = 212.42+273.15  #Saturation temperature(in K):\n",
      "s = Cpw*log(Tsat/273.15)+hfg/Tsat+Cps*log(Tss/Tsat) #Entropy of unit mass of superheated steam with reference to absolute zero(in kJ/kg.K):\n",
      "S = m*s    #Entropy of 5 kg of steam(in kJ/K):\n",
      "\n",
      "#Result:\n",
      "print \"Entropy of steam: \",round(S,2),\"KJ/K\"\t"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Entropy of steam:  33.23 KJ/K\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5, page no. 183"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable Declaration:\n",
      "Tb = 110 #Boiling point(in\u00c2\u00b0C):\n",
      "p =  143.27 #Pressure at which it boils(in kPa): #From steam table:\n",
      "Tsat =  108.866 #From steam table this temperature(in \u00c2\u00b0C): #Boiling point at this depth  =  Tsat at 138.365\n",
      "\n",
      "#Calculation:\n",
      "p1 = p-9.81*0.50 #Pressure at 50 cm depth(in kPa):\n",
      "\n",
      "#Result:\n",
      "print \"Boiling point :\",round(Tsat,2),\"\u00b0C\"\t\t\t\t"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Boiling point : 108.87 \u00b0C\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6, page no. 184"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable Declaration: \n",
      "T = 100 #Temperature of the water vapor mixture(in \u00c2\u00b0C):\n",
      "V = 0.5 #Volume of the rigid vessel(in m**3):\n",
      "v2 = 0.003155 #Specific volume at state 2(in m**3/kg): #From steam tables:\n",
      "vf = 0.001044\n",
      "vg = 1.6729\n",
      "\n",
      "#Calculations:\n",
      "v1 = v2 #Specific volume at state 1(in m**3/kg):\n",
      "x1 = (v1-vf)/vg #Dryness fraction:\n",
      "m = V/v2 #Total mass of fluid(in kg):\n",
      "v = m*vf #Volume of water(in m**3):\n",
      "\n",
      "#Results:\n",
      "print \"Mass of water :\",round(m,2),\"Kg\" \n",
      "print \"Volume of water :\",round(v,4),\"m**3\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mass of water : 158.48 Kg\n",
        "Volume of water : 0.1655 m**3\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7, page no. 184"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable Declaration: \n",
      "p = 2 #Pressure(in MPa):\n",
      "T = 500+273.15 #Temperature(in K):\n",
      "\n",
      "#Calculation:\n",
      "s = T #Slope of isobar:(dh/ds)at constant pressure = T:\n",
      "\n",
      "#Result:\n",
      "print \"Slope :\",s"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Slope : 773.15\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8, page no. 185"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable Declaration: \n",
      "x = 0.10 #Dryness fraction:\n",
      "p = 0.15 #Pressure(in MPa):\n",
      "hf  =  467.11 #From steam tables:(at 0.15 MPa):\n",
      "hg  =  2693.6\n",
      "vf  =  0.001053\n",
      "vg  =  1.1593\n",
      "sf  =  1.4336\n",
      "sg  =  7.2233\n",
      "\n",
      "#Calculations:\n",
      "h = hf+x*(hg-hf) #Enthalpy(in kJ/kg):\n",
      "v = vf+x*(vg-vf) #Specific volume(in m**3/kg):\n",
      "s = sf+x*(sg-sf) #Entropy(in kJ/kg.K):\n",
      "\n",
      "#Results:\n",
      "print \"Enthalpy :\",h,\"KJ/Kg\"\n",
      "print \"Specific volume :\",v,\"m**3/kg\"\n",
      "print \"Entropy :\",s,\"KJ/Kg.K\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Enthalpy : 689.759 KJ/Kg\n",
        "Specific volume : 0.1168777 m**3/kg\n",
        "Entropy : 2.01257 KJ/Kg.K\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9, page no. 185"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable Declaration: \n",
      "#Initial State:\n",
      "p1 = 1 #Pressure(in MPa):\n",
      "V1 = 0.05 #Volume(in m**3):\n",
      "x1 = 0.80 #Dryness fraction:\n",
      "#Final state:\n",
      "p2 = 1 #Pressure(in MPa):\n",
      "V2 = 0.2 #Volume(in m**3):\n",
      "\n",
      "#From steam table:(at state 1):\n",
      "vf  =  0.001127                 #(m3/kg) \n",
      "vg  =  0.19444                  #(m3/kg)\n",
      "uf  =  761.68                   #(kJ/kg)\n",
      "ufg  =  1822                    #(kJ/kg)\n",
      "\n",
      "#Calculations:\n",
      "W = p1*10**3*(V2-V1) #Work done(in kJ):\n",
      "v1 = vf+x1*(vg-vf) #Specific volume at state 1(in m**3/kg):\n",
      "m = V1/v1 #Mass of system(in kg):\n",
      "v2 = V2/m #Specific volume at state 2(in m**3/kg):\n",
      "Tf = 1077.61 #Temperature at final state(in C):\n",
      "u2 = 4209.6 #Internal energy at final state(at 1077.61 C):\n",
      "u1 = uf+x1*ufg #Internal energy at initial state(in kJ/kg):\n",
      "Q = m*(u2-u1)+W #Heat added(in kJ):\n",
      "\n",
      "#Results:\n",
      "print \"Heat added :\",round(Q,2),\"kJ\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat added : 788.83 kJ\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10, page no. 186"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable Declaration: \n",
      "p1 = 800 #Presure of the steam(in kPa):\n",
      "T = 200 #Temperature(in \u00b0C)\n",
      "Tsat = 170.43 #Saturation temp(in \u00b0C): \n",
      "#From steam tables:\n",
      "v1 = 0.2404 #Specific volume(in m**3/kg):\n",
      "vgI = 0.2168\n",
      "vgII = 0.2428\n",
      "TI = 175\n",
      "TII = 170\n",
      "PI = 892\n",
      "PII = 791.7\n",
      "\n",
      "#Calculations:\n",
      "T2 = TI - (TI-TII)*(v1-vgI)/(vgII-vgI) #Final temperature after interpolation (in \u00b0C):\n",
      "p2 = PI - (PI-PII)*(v1-vgI)/(vgII-vgI) #Final pressure after interpolation (in kPa):\n",
      "\n",
      "#Results:\n",
      "print \"Pressure :\",round(p2,2),\"kPa\"\n",
      "print \"Temperature :\",round(T2,2),\"\u00b0C\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure : 800.96 kPa\n",
        "Temperature : 170.46 \u00b0C\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 11, page no. 187"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable Declaration: \n",
      "T = 30 #Temperature of water(in C):\n",
      "p = 200 #Pressure(in kPa):\n",
      "p1 = 4.25 #Corresponding pressure at 30 C(in kPa): #From steam tables:\n",
      "v1 = 0.001004 #Specific volume(in m**3):\n",
      "\n",
      "#Calculations:\n",
      "dh = v1*(p-p1) #Enthalpy change(in kJ/kg):\n",
      "\n",
      "#Result:\n",
      "print \"Enthalpy change :\",dh,\"KJ/Kg\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Enthalpy change : 0.196533 KJ/Kg\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12, page no. 187"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "  \n",
      "#Variable Declaration: \n",
      "V1 = 3./5*2 #Volume occupied by water(in m**3):\n",
      "V2 = 2./5*2 #Volume occupied by steam(in m**3):\n",
      "#From steam table\n",
      "vf  =  0.001091 #(m**3/kg) \n",
      "vg  =  0.3928 #(m**3/kg)\n",
      "\n",
      "#Calculations:\n",
      "mf = V1/vf #Mass of water(in kg):\n",
      "mg = V2/vg #Mass of steam(in kg):\n",
      "mt = mf+mg #Total mass(in kg):\n",
      "x = mg/mt #Dryness fraction:\n",
      "\n",
      "#Results:\n",
      "print \"Mass :\",round(mt,2),\"kg\"\n",
      "print \"Quality :\",round(x,6)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mass : 1101.95 kg\n",
        "Quality : 0.001848\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13, page no. 188"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable Declaration: \n",
      "p = 4 #Pressure of the steam(in MPa):\n",
      "T1 = 300  #Temperature of steam entering(in \u00b0C):\n",
      "T2 = 50  #Temperature of steam at turbine exit(in \u00b0C):\n",
      "#From steam tables:\n",
      "h1 = 2886.2                 #kJ/kg \n",
      "s1 = 6.2285                 #kJ/kg.K\n",
      "hf  =  209.33               #kJ/kg\n",
      "sf  =  0.7038               #kJ/kg.K\n",
      "hfg  =  2382.7              #kJ/kg\n",
      "sfg  =  7.3725              #kJ/kg.K\n",
      "\n",
      "#Calculation:\n",
      "s2 = s1  #Assumed\n",
      "x2 = round((s2-sf)/sfg,4)   #Dryness fraction:\n",
      "h2 = hf+x2*hfg #Enthalpy at state 2(in kJ/kg):\n",
      "W = h1-h2  #Turbine work(in kJ/kg):\n",
      "\n",
      "#Results:\n",
      "print \"Turbine output: \",round(W,2),\"kJ/kg\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Turbine output:  891.27 kJ/kg\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14, page no. 188"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable Declaration: \n",
      "m1 = 100 #Mass of steam(in kg):\n",
      "p1 = 100 #Initial pressure(in kPa):\n",
      "p2 = 1000 #Final pressure(in kPa):\n",
      "x1 = 0.5 #Dryness fraction:\n",
      "p3 = 2000 #Pressure of dry saturated steam(in kPa):\n",
      "\n",
      "#From steam tables:\n",
      "hf100kPa  =  417.46                     #kJ/kg \n",
      "uf100kPa  =  417.36                     #kJ/kg\n",
      "vf100kPa  =  0.001043                   #m**3/kg\n",
      "hfg100kPa  =  2258                      #kJ/kg\n",
      "ufg100kPa  =  2088.7                    #kJ/kg\n",
      "vg100kPa  =  1.6940                     #m**3/kg\n",
      "vg2000kPa  =  0.09963                   #m**3/kg\n",
      "ug2000kPa  =  2600.3                    #kJ/kg\n",
      "hg2000kPa  =  2799.5                    #kJ/kg\n",
      "hf1000kPa  =  762.81                    #kJ/kg,\n",
      "hfg1000kPa  =  2015.3                   #kJ/kg \n",
      "vf1000kPa  =  0.001127                  #m3/kg\n",
      "vg1000kPa  =  0.19444                   #m3/kg\n",
      "\n",
      "#Calculations:\n",
      "v1 = vf100kPa+x1*(vg100kPa-vf100kPa) #Initial specific volume(in m**3/kg):\n",
      "h1 = hf100kPa+x1*hfg100kPa #Enthalpy at 1(in kJ/kg):\n",
      "V = m1*x1*v1 #Volume of vessel(in m**3):\n",
      "v2 = vg2000kPa*v1/(vg2000kPa+v1) #Final specific volume(in m**3/kg):\n",
      "x2 = (v2-vf1000kPa)/(vg1000kPa-vf1000kPa)#Final dryness fraction:\n",
      "h2 = hf1000kPa+x2*hfg1000kPa #Final enthalpy(in kJ/kg):\n",
      "m = m1*(h1-h2)/(h2-hg2000kPa) #Mass of dry steam at 2000kPa(in kg):\n",
      "U1 = m*(uf100kPa+x1*ufg100kPa) #Internal energy in the beginning(in kJ):\n",
      "\n",
      "#Results:\n",
      "print \"Mass of dry steam at 2000 kPa to be added: \",round(m,2),\"kg\" \n",
      "print \"Quality of final mixture: \",round(x2,3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mass of dry steam at 2000 kPa to be added:  11.97 kg\n",
        "Quality of final mixture:  0.455\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15, page no. 190"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable Declaration: \n",
      "r =  71.5  #Recorded condenser vacuum(cm of Mercury)\n",
      "br =  76.8 #Barometer reading(cm of Mercury) \n",
      "Tc =  35  #Temperature of condensation(\u00b0C)\n",
      "Thw =  27.6  #Temperature of hot well(\u00b0C)\n",
      "mc =  1930  #Mass of condensate per hour()Kg\n",
      "mcw =  62000    #Mass of cooling water per hour(Kg)\n",
      "Ti =  8.51 #Inlet temperature (\u00b0C)\n",
      "To =  26.24    #Outlet temperature(\u00b0C)\n",
      "#From steam tables:\n",
      "hf  =  146.68 #kJ/kg\n",
      "hfg  =  2418.6 #kJ/kg\n",
      "\n",
      "#Calculations:\n",
      "pc = (br-r)/73.55*101.325 #Condensor pressure(in kPa):\n",
      "ps =  5.628 #Partial pressure of steam corresponding to 35\u00c2\u00b0C from steam table(in kPa):\n",
      "x = (mcw*(To-Ti)*4.18-mc*hf+mc*4.18*To)/(mc*hfg) #Dryness fraction:\n",
      "\n",
      "#Results:\n",
      "print \"Dryness fraction of the steam entering:\",round(x,2) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Dryness fraction of the steam entering: 0.97\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 16, page no. 191"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from math import pi\n",
      "#Variable Declaration: \n",
      "D = 0.2 #Diameter of the vessel(in m):\n",
      "d = 0.02 #Depth(in m):\n",
      "T = 150 #Temperature(in \u00b0C):\n",
      "F = 10 #Force applied(in kN):\n",
      "Q = 600 #Heat supplied(in kJ):\n",
      "#From steam tables:\n",
      "hf = 612.1 \n",
      "hfg = 2128.7\n",
      "vg = 0.4435\n",
      "h2 = 1582.8\n",
      "\n",
      "#Calculations:\n",
      "p = F/(pi*D**2)*4+101.3 #Pressure at which process is taking place(in kPa):\n",
      "V1 = pi*D**2*d/4 #Volume of water contained(in m**3):\n",
      "m = V1*1000 #Mass of water(in kg):\n",
      "x = (Q-hf*m+4.18*T*m)/(hfg*m) #Dryness fraction:\n",
      "U1 = m*4.18*T-p*V1 #Internal energy of water initially(in kJ):\n",
      "V2 = m*x*vg #Final volume(in m**3):\n",
      "U2 = m*h2-p*V2 #Internal energy at state 2(in kJ):\n",
      "dU = U2-U1 #Change in internal energy(in kJ):\n",
      "W = p*(V2-V1) #Work done(in kJ):\n",
      "\n",
      "#Results:\n",
      "print \"Dryness fraction of the steam produced: \"  ,round(x,3) \n",
      "print \"Change in internal energy: \",round(dU,2), \"kJ\"\n",
      "print \"Work done: \",round(W,2),\"kJ\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Dryness fraction of the steam produced:  0.456\n",
        "Change in internal energy:  547.54 kJ\n",
        "Work done:  53.01 kJ\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17, page no. 192"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable Declaration: \n",
      "ms = 40   #Mass of steam passed(in kg):\n",
      "mw = 2.2  #Mass of water passed(in kg):\n",
      "p1 = 1.47 #Initial pressure of steam(in MPa):\n",
      "T = 120  #Temperature after throttling(in C):\n",
      "p2 = 107.88 #Pressure after throttling(in kPa):\n",
      "s = 2.09 #Specific heat of superheated steam(in kJ/kg.K):\n",
      "hf = 840.513 #From steam tables:\n",
      "hfg = 1951.02\n",
      "h1 = 2673.95\n",
      "\n",
      "#Calculations:\n",
      "ds = T-101.8 #Degree of superheat(in C):\n",
      "h2 = h1+ds*s #Enthalpy of superheated steam(in kJ/kg):\n",
      "x2 = (h2-hf)/hfg #Dryness fraction after throttling:\n",
      "x1 = (ms-mw)/ms #Dryness fraction before throttling:\n",
      "x = x1*x2 #Overall dryness fraction:\n",
      "\n",
      "#Results:\n",
      "print \"Dryness fraction \",round(x,4)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Dryness fraction  0.9065\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 18, page no. 192"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable Declaration: \n",
      "Va = 0.4 #Initial volume in part A(in m**3):\n",
      "pa = 10 #Pressure(in bar):\n",
      "V = 0.4 #Initial volume in part B(in m**3):\n",
      "p1 = 10 #Pressure in part B(in bar):\n",
      "p2 = 15 #Final pressure in part B(in bar):\n",
      "#From steam tables:\n",
      "hf = 762.83 \n",
      "hfg = 2015.3\n",
      "h2 = 2792.2\n",
      "\n",
      "#Calculations:\n",
      "Q = V*(p2-p1)*10**2 #Heat added(in kJ):\n",
      "x1 = (h2-Q-hf)/hfg #Dryness fraction:\n",
      "\n",
      "#Results:\n",
      "print \"Heat added: \",round(Q),\"kJ\" \n",
      "print \"Initial quality: \",round(x1,3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat added:  200.0 kJ\n",
        "Initial quality:  0.908\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 19, page no. 193"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable Declaration: \n",
      "m = 3 #Mass of wet steam(in kg):\n",
      "p1 = 1.4 #Initial pressure(in bar):\n",
      "V1 = 2.25 #Initial volume(in m**3):\n",
      "T = 400 #Final temperature of steam(in \u00b0C):\n",
      "V2 = 4.65 #At 400 \u00b0C,volume of steam(in m**3):\n",
      "#From steam tables:\n",
      "vg = 1.2455 \n",
      "hf = 457.99\n",
      "hfg = 2232.3\n",
      "h2 = 3276.6\n",
      "uf = 457.84\n",
      "ufg = 2059.34\n",
      "u2 = 2966.7\n",
      "\n",
      "#Calculations:\n",
      "v1 = V1/m #Specific volume of wer steam in cylinder(in m**3/kg):\n",
      "x1 = v1/vg #Dryness fraction of initial steam:\n",
      "h1 = hf+x1*hfg #Initial enthalpy of wet steam(in kJ/kg):\n",
      "v2 = V2/m #At 400\u00b0C specific volume of steam(in m**3/kg):\n",
      "p2 = 0.20 #Actual pressure(from steam table)(in MPa):\n",
      "ds = T-120.23 #Finally the degree of superheat(in \u00b0C): #Saturation temp at this pressure  =  120.23\u00c2\u00b0C\n",
      "Q = m*(h2-h1) #Heat added during the process(in kJ):\n",
      "u1 = uf+x1*ufg #Internal energy of initial wet steam(in kJ/kg):\n",
      "dU = m*(u2-u1) #Change in internal energy(in kJ):\n",
      "W = Q-dU #Work done(in kJ):\n",
      "\n",
      "#Results:\n",
      "print \"Heat transfer: \",round(Q,2),\"kJ\" \n",
      "print \"Work transfer : \",round(W,2),\"kJ\"\n",
      "print \"____Note: Please check the value of x1 calculated and used: (calculated is 0.602 and used is 0.607 hence there is a difference in answer)____\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat transfer:  4423.17 kJ\n",
        "Work transfer :  616.8 kJ\n",
        "____Note: Please check the value of x1 calculated and used: (calculated is 0.602 and used is 0.607 hence there is a difference in answer)____\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 20, page no. 194"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Variable Declaration: \n",
      "p1 = 10 #Pressure of the steam(in bar):\n",
      "T = 500 #Temperature(in \u00b0C):\n",
      "p2 = 1 #Final pressure(in bar):\n",
      "#From steam tables:\n",
      "h10bar500  =  3478.5            #kJ/kg \n",
      "s10bar500  =  7.7622            #kJ/kg.K\n",
      "v10bar500  =  0.3541            #m**3/kg\n",
      "h1bar400  =  3278.2             #kJ/kg\n",
      "h1bar500  =  3488.1             #kJ/kg\n",
      "v1bar500  =  3.565              #m**3/kg\n",
      "v1bar400  =  3.103              #m**3/kg\n",
      "s1bar500  =  8.8342             #kJ/kg.K\n",
      "s1bar400  =  8.5435             #kJ/kg.K\n",
      "h2 = h10bar500\n",
      "\n",
      "#Calculations:\n",
      "T2 = (h2-h1bar400)*(T-400)/(h1bar500-h1bar400)+400 #Final temperature(in \u00b0C):\n",
      "s2 = s1bar400+(s1bar500-s1bar400)/(T-400)*(T2-400) #Final entropy(in kJ/kg.K):\n",
      "ds = s2-s10bar500  #Change in entropy(in kJ/kg.K):\n",
      "v2 = v1bar400+(v1bar500-v1bar400)/(T-400)*(T2-400) #Final specific volume(in m**3/kg):\n",
      "p = v10bar500/v2*100 #Percentage volume occupied by steam:\n",
      "\n",
      "#Results:\n",
      "print \"Final temperature: \",round(T2,2),\"\u00b0C\" \n",
      "print \"Change in entropy: \",round(ds,4),\"kJ/Kg K\"\n",
      "print \"Percentage of vessel volume initially occupied by steam: \",round(p,2),\"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Final temperature:  495.43 \u00b0C\n",
        "Change in entropy:  1.0587 kJ/Kg K\n",
        "Percentage of vessel volume initially occupied by steam:  9.99 %\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 21, page no. 195"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable Declaration: \n",
      "#Steam entering:\n",
      "p1 = 2.5     #Pressure(in MPa): \n",
      "T1 = 350   #Temperature(in \u00b0C):\n",
      "#Steam rejected:\n",
      "p2 = 20   #Pressure(in kPa):\n",
      "x2 = 0.92  #Dryness fraction:\n",
      "p3 = 30  #Pressure of one quater of intial steam(in kPa):\n",
      "T0 = 30+273 #Temperature(in K):\n",
      "m1 = 1\n",
      "m2 = 0.25\n",
      "m3 = 0.75\n",
      "Q = -10 #Heat lost during expansion(in kJ):\n",
      "#From steam tables:\n",
      "h1 = 3126.3                 #kJ/kg\n",
      "s1 = 6.8403                 #kJ/kg.K\n",
      "h2 = 2878.6                 #kJ/kg\n",
      "s2 = 8.5309                 #kJ/kg.K\n",
      "h3  =  2421.04              #kJ/kg\n",
      "s3  =  7.3425               #kJ/kg.K\n",
      "hf  =  251.40               #kJ/kg\n",
      "hg  =  2609.7               #kJ/kg\n",
      "sf  =  0.8320               #kJ/kg.K\n",
      "sfg  =  7.0766              #kJ/kg.K\n",
      "h0 = 125.79 \n",
      "s0 = 0.4369\n",
      "\n",
      "#Calculations:\n",
      "A1 = (h1-h0)-T0*(s1-s0)     #Availability of steam entering turbine(in kJ/kg):\n",
      "A2 = (h2-h0)-T0*(s2-s0)     #Availability of steam leaving turbine at state 2(in kJ/kg):\n",
      "A3 = (h3-h0)-T0*(s3-s0)     #Availability of steam leaving turbine at state 3(in kJ/kg):\n",
      "Wmax = m1*A1-m2*A2-m3*A3    #Maximum work per kg of steam entering turbine(in kJ/kg):\n",
      "I = T0*(m2*s2+m3*s3-m1*s1)-Q#Irreversibilty(in kJ/s):\n",
      "\n",
      "#Results:\n",
      "print \"Maximum work\",round(Wmax,2),\"kJ/kg\" \n",
      "print \"Irreversibility\",round(I,2),\"kJ/s\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum work 833.06 kJ/kg\n",
        "Irreversibility 252.19 kJ/s\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 22, page no. 196"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable Declaration: \n",
      "p1 = 6 #Initial pressure(in MPa):\n",
      "p2 = 5 #Final pressure(in MPa):\n",
      "T1 = 400 #Initial temperature(in \u00b0C):\n",
      "patm = 100 #Atmospheric pressure(in kPa):\n",
      "Ta = 20+273 #Atmospheric temperature(in \u00b0K):\n",
      "#From steam tables:\n",
      "h1 = 3177.2             #kJ/kg \n",
      "s1 = 6.5408             #kJ/kg.K\n",
      "h2 = h1\n",
      "T2 = 392.7              #\u00b0C(by interpolation)\n",
      "s2 = 6.6172             #kJ/kg.K(#By interpolation Entropy)\n",
      "h0 = 83.96              #kJ/kg\n",
      "s0  =  0.2966           #kJ/kg\n",
      "\n",
      "#Calculations:\n",
      "A1 = (h1-h0)-Ta*(s1-s0) #Availability at state 1(in kJ/kg):\n",
      "A2 = (h2-h0)-Ta*(s2-s0) #Availability at state 2(in kJ/kg):\n",
      "dA = A2-A1 #Change in availibilty(in kJ/kg):\n",
      "\n",
      "print \"Change in availability: \",round(-dA,1),\"kJ/kg decrease\","
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Change in availability:  22.4 kJ/kg decrease\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 23, page no. 198"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable Declaration:\n",
      "TH1 =  95 #Temperature of the hot water entering(in \u00c2\u00b0C):\n",
      "TH2 =  50 #Temperature of the hot water at exit(in \u00c2\u00b0C): \n",
      "mH  =  0.8 #Mass flow rate(in kg/s):\n",
      "TC1 =  15+273 #Temperature of cooling water entering(in \u00c2\u00b0K):\n",
      "TC2 =  45+273 #Temperature of cooling water at exit(in \u00c2\u00b0K):\n",
      "T0 = 25+273 #Temperature of dead state(in K):\n",
      "#From steam tables:\n",
      "h0 = 104.89                     #kJ/kg\n",
      "s0 = 0.3674                     #kJ/kg.K\n",
      "hH1 = 397.96                    #kJ/kg\n",
      "sH1 = 1.2500                    #kJ/kg.K\n",
      "hH2 = 209.33                    #kJ/kg.K\n",
      "sH2 = 0.7038                    #kJ/kg.K\n",
      "hC2 = 188.45                    #kJ/kg.K\n",
      "sC2 = 0.6387                    #kJ/kg.K\n",
      "hC1 = 62.99                     #kJ/kg.K\n",
      "sC1 = 0.2245                    #kJ/kg.K\n",
      "\n",
      "#Calculations:\n",
      "mC = mH*(TH1-TH2)/(TC2-TC1)\t#Mass flow rate of cooling water(in kg/s):\n",
      "AH1 = mH*((hH1-h0)-T0*(sH1-s0))\t#Exergy entering through hot water stream(in kJ/s):\n",
      "dAc = mC*((hC2-hC1)-T0*(sC2-sC1))#Rate of exergy increase in cold stream(in kJ/s):\n",
      "n = dAc/AH1*100 #Second law efficiency:\n",
      "dAh = mH*((hH1-hH2)-T0*(sH1-sH2))#Rate of exergy loss in hot stream(in kJ/s):\n",
      "dA = dAh-dAc #Exergy destruction(in kJ/s):\n",
      "\n",
      "#Results:\n",
      "print \"Second law efficincy: \",round(n,2),\"%\"  \n",
      "print \"Exergy destruction: \",round(dA,2),\"kJ/s\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Second law efficincy:  10.12 %\n",
        "Exergy destruction:  18.26 kJ/s\n"
       ]
      }
     ],
     "prompt_number": 27
    }
   ],
   "metadata": {}
  }
 ]
}