summaryrefslogtreecommitdiff
path: root/Chemical_Engineering_Thermodynamics_by_Y_V_C_Rao/ch5.ipynb
blob: 9cf5b1c82772f458280f2ea0fd87b7c469355512 (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
{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 5 : Second law of thermodynamics and its applications"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.2  Page No : 161"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "# Variables\n",
      "Q = 1000.;\t\t    \t #amount of energy absorbed by the heat engine in kJ/s\n",
      "W = 650.;\t\t\t     #work delivered by the heat engine in kW\n",
      "T_source = 500. \t\t #temperature of the source in degree celsius\n",
      "T_sink = 25.\t\t\t #temperature of the sink in degree celsius\n",
      "\n",
      "# Calculations\n",
      "n_claimed = W/Q\n",
      "T1 = T_source+273.15\n",
      "T2 = T_sink+273.15\n",
      "n_carnot = 1-(T2/T1)\n",
      "\n",
      "# Results\n",
      "print \" The efficiency of the Carnot engine = %0.3f \"%(n_carnot);\n",
      "print \" The efficiency of the engine claimed by the inventor = %0.2f \"%(n_claimed);\n",
      "if n_claimed<n_carnot:\n",
      "    print \" The claimed heat engine is theoretically feasible as the efficiency of the engine is lesser than that of a Carnot engine\";\n",
      "else:\n",
      "    print \" The claimed heat engine is not theoretically feasible as the efficiency of the engine is greater than that of a Carnot engine\";\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The efficiency of the Carnot engine = 0.614 \n",
        " The efficiency of the engine claimed by the inventor = 0.65 \n",
        " The claimed heat engine is not theoretically feasible as the efficiency of the engine is greater than that of a Carnot engine\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.3  Page No : 165"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "T_source_summer = 42; #temperature in the summer months in degree celsius\n",
      "T_sink_winter = 0;\t  #temperature in the winter months in degree celius\n",
      "T_amb = 25;\t\t\t  #temperature at which the house is to be maintained during both the months in degree celsius\n",
      "energy_loss = 0.5;\n",
      "\n",
      "# Calculations\n",
      "T_H_summer = T_source_summer+273.15\n",
      "T_L_summer = T_amb+273.15\n",
      "T_H_winter = T_amb+273.15\n",
      "T_L_winter = T_sink_winter+273.15\n",
      "W_summer = (energy_loss*((T_H_summer-T_L_summer)**2))/(T_L_summer)\n",
      "W_winter = (energy_loss*((T_H_winter-T_L_winter)**2))/(T_H_winter)\n",
      "\n",
      "# Results\n",
      "print \" The minimum power required to operate the device in summer = %.4f kW \"%(W_summer);\n",
      "print \" The minimum power required to operate the device in winter = %f kW \"%(W_winter);\n",
      "\n",
      "# Note: Answer in book is wrong. Please calculated manually."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The minimum power required to operate the device in summer = 0.4847 kW \n",
        " The minimum power required to operate the device in winter = 1.048130 kW \n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.4  Page No : 166"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "T_L = 4.25 \t\t\t #normal boiling point of helium in K\n",
      "Q_L = 0.083\t\t\t #latent heat of vaporization of helium in kJ/mol\n",
      "n = 1.  \t\t\t #amount of liquid helium to be produced in kmol\n",
      "T_amb = 42.\t\t\t #ambient temperature in summer in degree celsius\n",
      "\n",
      "# Calculations\n",
      "T_H = T_amb+273.15\n",
      "COP = (T_L)/(T_H-T_L)\n",
      "W = (Q_L)/COP;\t\t\n",
      "\n",
      "# Results\n",
      "print \" The maximum possible COP of the unit = %0.4f \"%(COP);\n",
      "print \" The minimum amount of work to be done on the refrigerating unit = %f kJ \"%(W);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The maximum possible COP of the unit = 0.0137 \n",
        " The minimum amount of work to be done on the refrigerating unit = 6.071694 kJ \n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.5  Page No : 166"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "T_ice = 0.;\t\t        \t #temperature of the ice to be produced in degree celsius\n",
      "m = 5000.;\t\t\t         #rate at which ice is to be produced in kg/hour\n",
      "T_water = 0.;\t    \t\t #temperature of water used to produce ice in degree celsius\n",
      "T_amb = 40.;\t\t    \t #ambient temperature in degree celsius\n",
      "T_source = 100.;\t\t\t #temperature of the source for operating heat engine in degree celsius\n",
      "lambda_fusion = 6.002;\t\t\t #latent heat of fusion of water in kJ/mol at 0 degree celsius\n",
      "molar_mass = 18*10**-3;\t\t\t #molar mass of water in kg/mol\n",
      "\n",
      "# Calculations\n",
      "T_L = T_water+273.15\n",
      "T_H = T_amb+273.15\n",
      "COP = (T_L)/(T_H-T_L)\n",
      "Q_L = ((m/3600)/molar_mass)*(lambda_fusion)\n",
      "W = (Q_L)/(COP);\t\t\t \n",
      "T1 = T_source+273.15;\t\t\n",
      "T2 = T_amb+273.15\n",
      "n_heatengine = (T1-T2)/T1\n",
      "Q1 = W/n_heatengine;\t\n",
      "energy_ratio = (Q1+Q_L)/Q_L;\n",
      "\n",
      "# Results\n",
      "print \" The minimum power required to operate the refrigerator = %0.2f kW\"%(W);\n",
      "print \" The maximum possible efficiency of the heat engine = %0.4f \"%(n_heatengine);\n",
      "print \" Ratio of the energy rejected to the ambient atmosphere to the\\\n",
      " energy absorbed from the water = %0.4f \"%(energy_ratio);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The minimum power required to operate the refrigerator = 67.82 kW\n",
        " The maximum possible efficiency of the heat engine = 0.1608 \n",
        " Ratio of the energy rejected to the ambient atmosphere to the energy absorbed from the water = 1.9107 \n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.6  Page No : 169"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "T1 = 800.\t\t\t #temperature of reservoir 1 in K\n",
      "T2 = 400.\t\t\t #temperature of reservoir 2 in K\n",
      "Q1 = 1000.\t\t\t #energy absorbed from reservoir maintained at T1 in kJ\n",
      "Q2 = 400.\t\t\t #energy absorbed from reservoir maintained at T2 in kJ\n",
      "W = 1000.\t\t\t #work delivered by the heat engine in kJ\n",
      "T3 = 300.\t\t\t #temperature of the sink in K\n",
      "\n",
      "# Calculations\n",
      "Q3 = (Q1+Q2)-W\n",
      "clausius_inequality = (Q1/T1)+(Q2/T2)-(Q3/T3)\n",
      "\n",
      "# Results\n",
      "print \" The LHS of the Clausius inequality = %0.4f \"%(clausius_inequality);\n",
      "if clausius_inequality<0 or clausius_inequality == 0:\n",
      "    print \" The given process does not violate the second law of thermodynamics, therefore the claim is correct\"\n",
      "else:\n",
      "    print \" This is a violation of the second law of thermodynamics, and hence the claim cannot be justified\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The LHS of the Clausius inequality = 0.9167 \n",
        " This is a violation of the second law of thermodynamics, and hence the claim cannot be justified\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.7  Page No : 172"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "T_system = 200.;\t\t\t #temperature of the contents of reactor in degree celsius\n",
      "t = 15.         \t\t\t #operation time of agitator in minutes\n",
      "P = 750.    \t    \t\t #power of the operating motor in W\n",
      "\n",
      "# Calculations\n",
      "dQ = P*t*60*10**-3\n",
      "T = T_system+273.15\n",
      "del_S = dQ/T;\t\t\n",
      "\n",
      "# Results\n",
      "print \" The change in the entropy of the reactor contents = %0.4f kJ/K \"%(del_S);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The change in the entropy of the reactor contents = 1.4266 kJ/K \n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.8  Page No : 172"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "\n",
      "# Variables\n",
      "P = 0.101325;\t\t\t #pressure in the piston cylinder assembly in MPa\n",
      "T1 = 300.;\t\t\t #temperature of the piston cylinder assembly in K\n",
      "T2 = 400;\t\t\t #final temperature of the piston cylinder assembly in K\n",
      "a = 45.369;\t\t\t #coefficients to compute isobaric molar heat capacity of CO2(g) in J/molK\n",
      "b = 8.688*10**-3;\t\t\t #coefficients to compute isobaric molar heat capacity of CO2(g) in J/molK\n",
      "e = 9.619*10**5;\t\t\t #coefficients to compute isobaric molar heat capacity of CO2(g) in J/molK\n",
      "\n",
      "# Calculations\n",
      "del_S = (a*math.log(T2/T1))+(b*(T2-T1))+((e)*((1./T2**2)-(1./T1**2)))\n",
      "\n",
      "# Results\n",
      "print \" The change in entropy of CO2 = %.4f J/molK\"%(del_S);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The change in entropy of CO2 = 9.2447 J/molK\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.9  Page No : 173"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "m = 1.      \t\t\t #amount of saturated liquid water in kg\n",
      "T_initial = 100.\t\t #initial temperature of water in degree celsius\n",
      "T_body = 500.\t\t\t #temperature of body which is brought into contact with the cylinder in degree celsius\n",
      "hfg = 2256.94\t\t\t #enthalpy of vaporization taken from steam tables corresponding to T1 in kJ/kg\n",
      "\n",
      "# Calculations\n",
      "T = T_initial+273.15\n",
      "del_S = hfg/T;\t\t\n",
      "\n",
      "# Results\n",
      "print \" The change in entropy of water = %0.4f kJ/kgK\"%(del_S);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The change in entropy of water = 6.0483 kJ/kgK\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.10  Page No : 173"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "m_steel = 10.   \t\t\t #mass of steel casting in kg\n",
      "T_steel = 800.\t    \t\t #temperature of steel casting in degree celsius\n",
      "m_water = 100.\t\t    \t #mass of water used for quenching in kg\n",
      "T_water = 30.\t\t\t     #temperature of water used for quenching in degree celsius\n",
      "Cp_steel = 0.461;\t\t\t #heat capacity of steel in kJ/kgK\n",
      "Cp_water = 4.23;\t\t\t #heat capacity of water in kJ/kgK\n",
      "\n",
      "# Calculations\n",
      "Ti_steel = T_steel+273.15\n",
      "Ti_water = T_water+273.15\n",
      "T_final = ((m_steel*Cp_steel*Ti_steel)+(m_water*Cp_water*Ti_water))/((m_steel*Cp_steel)+(m_water*Cp_water));\n",
      "del_S_steel = m_steel*Cp_steel*math.log(T_final/Ti_steel)\n",
      "del_S_water = m_water*Cp_water*math.log(T_final/Ti_water)\n",
      "\n",
      "# Results\n",
      "print \" The change in entropy of steel  =  %0.4f kJ/K\"%(del_S_steel);\n",
      "print \" The change in entropy of water  =  %f kJ/K\"%(del_S_water);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The change in entropy of steel  =  -5.7031 kJ/K\n",
        " The change in entropy of water  =  11.427392 kJ/K\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.11  Page No : 175"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "V = 2.\t    \t\t #volume of insulated tank in m**3\n",
      "Ta = 400.\t\t\t #temperature of gas in compartment (a) in K\n",
      "Pa = 3.\t\t    \t #pressure of gas in compartment (a) in MPa\n",
      "Tb = 600.\t\t\t #temperature of gas in compartment (b) in K\n",
      "Pb = 1.\t\t\t     #pressure of gas in compartment (b) in MPa\n",
      "R = 8.314;\t\t\t #universal gas constant in J/molK\n",
      "\n",
      "# Calculations\n",
      "Va = V/2\n",
      "Vb = V/2\n",
      "Na = (Pa*10**6*Va)/(R*Ta)\n",
      "Nb = (Pb*10**6*Vb)/(R*Tb)\n",
      "T = ((Na*Ta)+(Nb*Tb))/(Na+Nb)\n",
      "N = Na+Nb;\t\t\t \n",
      "P = ((N*R*T)/V)*10**-6\n",
      "Cp = (5./2)*R;\t\t\t\n",
      "del_S = ((Na*((Cp*math.log(T/Ta))-(R*math.log(P/Pa))))+(Nb*((Cp*math.log(T/Tb))-(R*math.log(P/Pb)))))*10**-3; # Calculations of the change in entropy using Eq.(5.43) in kJ/K\n",
      "\n",
      "# Results\n",
      "print \" Entropy change of the gas = %0.2f kJ/K\"%(del_S);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Entropy change of the gas = 2.19 kJ/K\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.12  Page No : 177"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "# Variables\n",
      "N = 1.\t    \t\t #amount of air to be separated into its components in kmol\n",
      "P = 0.1\t\t    \t #pressure of air in MPa\n",
      "T = 300.\t\t\t #temperature of air in K\n",
      "per_oxygen = 21.\t\t\t #percentage of oxygen in air\n",
      "per_nitrogen = 79.\t\t\t #percentage of nitrogen in air\n",
      "R = 8.314;\t\t\t         #universal gas constant in J/molK\n",
      "\n",
      "# Calculations\n",
      "\n",
      "x1 = per_nitrogen/100\n",
      "x2 = per_oxygen/100;\n",
      "W = (T*N*10**3*R*((x1*math.log (x1))+(x2*math.log (x2))))*10**-3\n",
      "\n",
      "# Results\n",
      "print \" Minimum work to be done to separate 1kmol of air at 0.1MPa and 300K into pure oxygen\\\n",
      " and nitrogen at the same temperature and pressure = %0.2f kJ\"%(abs(W));"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Minimum work to be done to separate 1kmol of air at 0.1MPa and 300K into pure oxygen and nitrogen at the same temperature and pressure = 1281.91 kJ\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.13  Page No : 179"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "# Variables\n",
      "m_ice = 10.\t    \t\t #mass of the block of ice in kg\n",
      "T_ice = 0.\t\t    \t #temperature of the ice in degree celsius\n",
      "m_water = 100.\t\t\t #mass of watre in the tank in kg\n",
      "T_water = 30.\t\t\t #temperature of the water in the tank in degree celsius\n",
      "Cp = 4.23;\t\t\t     #heat capacity of water in kJ/kgK\n",
      "lambda_melting = 333.44\t\t\t #latent heat of melting of ice in kJ/kg\n",
      "\n",
      "# Calculations\n",
      "Ti_ice = T_ice+273.15\n",
      "Ti_water = T_water+273.15\n",
      "T_final = ((m_water*Cp*Ti_water)+(m_ice*Cp*Ti_ice)-(m_ice*lambda_melting))/((m_ice*Cp)+(m_water*Cp))\n",
      "del_S_ice = ((m_ice*lambda_melting)/(Ti_ice))+(m_ice*Cp*math.log (T_final/Ti_ice));\t\t\t \n",
      "del_S_water = m_water*Cp*math.log (T_final/Ti_water)\n",
      "del_S_G = del_S_ice+del_S_water;\t\t\t \n",
      "\n",
      "# Results\n",
      "print \" The change in entropy of ice  =  %f kJ/K\"%(del_S_ice);\n",
      "print \" The change in entropy of water  =  %f kJ/K\"%(del_S_water);\n",
      "print \" The entropy generated =  %f kJ/K\"%(del_S_G);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The change in entropy of ice  =  15.211650 kJ/K\n",
        " The change in entropy of water  =  -14.035033 kJ/K\n",
        " The entropy generated =  1.176617 kJ/K\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.14  Page No : 182"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "P = 3.\t\t\t         #pressure of superheated steam in MPa\n",
      "T_enter = 300.\t\t\t #entrance temperature of superheated steam in degree celsius\n",
      "T_exit = 45.\t\t\t #final temperature at which the steam leaves in degree celsisus\n",
      "m = 1.      \t\t\t #mass flow rate of steam in kg/s\n",
      "\n",
      "# Calculations\n",
      "\n",
      "si = 6.5422\n",
      "hi = 2995.1\n",
      "sf = 0.6383\n",
      "hf = 188.35\n",
      "sg = 8.1661;\t\t\t #entropy of saturated vapour in kJ/kgK\n",
      "hg = 2583.3;\t\t\t #entahlpy of saturayed vapour in kJ/kg\n",
      "\n",
      "Xe = (si-sf)/(sg-sf)\n",
      "he = ((1-Xe)*hf)+(Xe*hg)\n",
      "Ws = -m*(he-hi);\t\t\n",
      "\n",
      "# Results\n",
      "print \" The power  Results from the turbine = %0.1f kW\"%(Ws);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The power  Results from the turbine = 928.4 kW\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.15  Page No : 183"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "# Variables\n",
      "Pi = 3.\t\t\t #pressure of dry saturated steam when it enters the nozzle in bar\n",
      "Pe = 2.\t\t\t #pressure of dry saturated steam at the exit in bar\n",
      "\n",
      "# Calculations\n",
      "#From steam tables corresponding to Pi\n",
      "si = 6.9909;\t\t\t #entropy of steam at the entrance in kJ/kgK\n",
      "hi = 2724.7;\t\t\t #entahlpy of steam at the entrance in kJ/kg\n",
      "\n",
      "#From steam tables corresponding to Pe\n",
      "sf = 1.5301;\t\t\t #entropy of saturated liquid in kJ/kgK\n",
      "hf = 504.70;\t\t\t #enthalpy of saturated liquid in kJ/kg\n",
      "sg = 7.1268;\t\t\t #entropy of saturated vapour in kJ/kgK\n",
      "hg = 2706.3;\t\t\t #entahlpy of saturayed vapour in kJ/kg\n",
      "\n",
      "se = 6.9909\n",
      "Xe = (se-sf)/(sg-sf)\n",
      "he = ((1-Xe)*hf)+(Xe*hg)\n",
      "Ve = math.sqrt (2*(hi-he)*10**3)\n",
      "\n",
      "# Results\n",
      "print \" The exit velocity of steam = %f m/s\"%(Ve);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The exit velocity of steam = 379.103198 m/s\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.16  Page No : 183"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "# Variables\n",
      "N_glycerol = 100.\t\t\t #molar flow rate of glycerol in mol/s\n",
      "Ti_gly = 227.\t\t\t #inlet temperature of glycerol in degree celsius\n",
      "Te_gly = 40.\t\t\t #outlet temperature of glycerol in degree celsius\n",
      "Ti_water = 25.\t\t\t #inlet temperature of cooling water in degree celsius\n",
      "Te_water = 50.\t\t\t #outlet temperature of cooling water in degree celsius\n",
      "Cp_gly = 280.\t\t\t #heat capacity of glycerol in J/molK\n",
      "Cp_water = 77.\t\t\t #heat capacity of water in J/molK\n",
      "\n",
      "# Calculations\n",
      "Ti_gly = Ti_gly+273.15\n",
      "Te_gly = Te_gly+273.15\n",
      "Ti_water = Ti_water+273.15\n",
      "Te_water = Te_water+273.15\n",
      "\n",
      "N_water = -(N_glycerol*Cp_gly*(Te_gly-Ti_gly))/(Cp_water*(Te_water-Ti_water));\n",
      "del_S_gly = N_glycerol*Cp_gly*math.log (Te_gly/Ti_gly)*10**-3\n",
      "del_S_water = N_water*Cp_water*math.log (Te_water/Ti_water)*10**-3\n",
      "S_G = del_S_gly+del_S_water\n",
      "\n",
      "# Results\n",
      "print \" The rate at which entropy is generated in the heat exchanger = %0.3f kJ/K s\"%(S_G);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The rate at which entropy is generated in the heat exchanger = 3.754 kJ/K s\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.17  Page No : 183"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "T_i = 150.\t\t\t #temperature of saturated steam taken up by the device in degree celsius\n",
      "T_e = 200.\t\t\t #temperature of superheated steam delivered by the device in degree celsius\n",
      "P_e = 0.2\t\t\t #pressure of superheated steam delivered by the device in MPa\n",
      "me2 = 0.949\t\t\t #mass of superheated steam leaving the device in kg\n",
      "me1 = 0.051\t\t\t #mass of saturated liquid leaving the device in kg\n",
      "T_liq = 100.\t\t #temperature of saturated liquid leaving the device in degree celsius\n",
      "mi = 1.     \t\t #mass of saturated steam fed to the device in kg\n",
      "\n",
      "# Calculations\n",
      "#From steam tables corresponding to T_i\n",
      "hi = 2745.4 \t\t\t #enthalpy of saturated vapour in kJ/kg\n",
      "si = 6.8358;\t\t\t #entropy of saturated vapour in kJ/kgK\n",
      "\n",
      "#For saturated liquid at T_liq\n",
      "he1 = 419.06;\t\t\t #enthalpy of saturated liquid in kJ/kg\n",
      "se1 = 1.3069;\t\t\t #entropy of saturated vapour in kJ/kgK\n",
      "\n",
      "#For superheated steam at P_e and T_e\n",
      "he2 = 2870.5;\t\t\t #enthalpy of superheated steam in kJ/kg\n",
      "se2 = 7.5072;\t\t\t #entropy of superheated steam in kJ/kgK\n",
      "\n",
      "LHS = mi*hi;\n",
      "RHS = (me1*he1)+(me2*he2);\n",
      "\n",
      "S_G = (me1*se1)+(me2*se2)-(mi*si);\n",
      "\n",
      "# Results\n",
      "print \" The LHS of the equation applied to the flow device to check if the first law of thermodynamics is satisfied =  %0.1f kJ\"%(LHS);\n",
      "print \" The RHS of the equation applied to the flow device to check if the first law of thermodynamics is satisfied = %0.1f kJ\"%(RHS);\n",
      "print \" The entropy generated by applying the second law of thermodynamics to the flow device = %0.4f kJ/kgK\"%(S_G);\n",
      "if int(LHS) ==  int(RHS) and S_G>0 or S_G == 0 :\n",
      "    print \" As the first and second law of thermodynamics are satisfied, the device is theoretically feasible \"\n",
      "else:\n",
      "    print \" As both the first and second law or either the first or second law of thermodynamics \\\n",
      "     are not satisfied, the device is not feasible \"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The LHS of the equation applied to the flow device to check if the first law of thermodynamics is satisfied =  2745.4 kJ\n",
        " The RHS of the equation applied to the flow device to check if the first law of thermodynamics is satisfied = 2745.5 kJ\n",
        " The entropy generated by applying the second law of thermodynamics to the flow device = 0.3552 kJ/kgK\n",
        " As the first and second law of thermodynamics are satisfied, the device is theoretically feasible \n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.18  Page No : 185"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "Pi = 30.\t\t\t #pressure of superheated steam entering the turbine in bar\n",
      "Ti = 300.\t\t\t #temperature of superheated steam entering the turbine in degree celsius\n",
      "Pe = 0.1\t\t\t #pressure at which steam exits the turbine in bar\n",
      "Xe = 0.9\t\t\t #quality of steam at the exit (no unit)(for the actual turbine)\n",
      "\n",
      "# Calculations\n",
      "#For superheated steam at Pi and Ti\n",
      "hi = 2995.1;\t\t\t #enthalpy of superheated steam at the entrance in kJ/kg\n",
      "si = 6.5422;\t\t\t #entropy of superheated steam at the entrance in kJ/kgK\n",
      "\n",
      "#For steam at Pe\n",
      "hf = 191.83;\t\t\t #enthalpy of saturated liquid in kJ/kg\n",
      "hg = 2584.8;\t\t\t #enthalpy of saturated vapour in kJ/kg\n",
      "sf = 0.6493;\t\t\t #entropy of saturated liquid in kJ/kgK\n",
      "sg = 8.1511;\t\t\t #entropy of saturated vapour in kJ/kgK\n",
      "\n",
      "X2 = (si-sf)/(sg-sf)\n",
      "h2 = (hf*(1-X2))+(X2*hg)\n",
      "he = (hf*(1-Xe))+(Xe*hg)\n",
      "n_T = (hi-he)/(hi-h2)\n",
      "\n",
      "# Results\n",
      "print \" The isentropic efficiency of the turbine = %f \"%(n_T);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The isentropic efficiency of the turbine = 0.703395 \n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.19  Page No : 186"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "Ti = 25.\t\t\t #temperature of air taken in by the adiabatic air compressor in degree celsius\n",
      "Pi = 0.1\t\t\t #pressure of air taken in by the adiabatic air compressor in MPa\n",
      "Pe = 1.\t    \t\t #discharge pressure of air in MPa\n",
      "n_c = 0.8\t\t\t #isentropic efficiency of the compressor (no unit)\n",
      "gaamma = 1.4\t\t #ratio of molar specific heat capacities (no unit)\n",
      "R = 8.314\t\t\t #universal gas constant in J/molK\n",
      "\n",
      "# Calculations\n",
      "Ti = Ti+273.15\n",
      "Te = Ti*(((Pe*10**6)/(Pi*10**6))**((gaamma-1)/gaamma))\n",
      "W_s = (((R*gaamma)/(gaamma-1))*(Te-Ti))*10**-3;\t\t\t\n",
      "Ws = W_s/n_c\n",
      "Te_actual = ((Ws*10**3*(gaamma-1))/(R*gaamma))+Ti\n",
      "\n",
      "# Results\n",
      "print \" The exit temperature of air = %0.2f K\"%(Te_actual);\n",
      "print \" The power consumed by the compressor  = %f kW/mol\"%(Ws);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The exit temperature of air = 645.01 K\n",
        " The power consumed by the compressor  = 10.093262 kW/mol\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.20  Page No : 187"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "Ti = 30.\t\t\t #temperature of saturated liquid water in degree celsius\n",
      "m = 500.\t\t\t #mass flow rate of water being pumped in kg/s\n",
      "P2 = 3. \t\t\t #preesure maintained in the boiler in MPa\n",
      "n_p = 0.75;\t\t\t #isentropic efficiency of the pump (no unit)\n",
      "\n",
      "# Calculations\n",
      "#For saturated liquid water at Ti\n",
      "vf = 0.0010043\n",
      "P1 = 4.241;\t\t\n",
      "\n",
      "Ws_m = (vf*((P2*10**6)-(P1*10**3)))*10**-3\n",
      "Ws_act_m = Ws_m/n_p;\t\t\t \n",
      "P = ((Ws_act_m*10**3)*m)*10**-6;\n",
      "\n",
      "# Results\n",
      "print \" The power consumed by the pump  =  %d MW\"%(P);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The power consumed by the pump  =  2 MW\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.21  Page No : 188"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "Pi = 3.\t\t\t #pressure of dry saturated steam entering the nozzle in bar\n",
      "Xe = 0.98\t\t #quality of steam exiting the nozzle (no unit)\n",
      "Pe = 2.\t\t\t #pressure of steam exiting the nozzle in bar\n",
      "\n",
      "# Calculations\n",
      "#For steam at Pi\n",
      "hi = 2724.7\n",
      "he = 2652.8\n",
      "V2_2_s = hi-he\n",
      "\n",
      "#For steam at Pe\n",
      "hf = 504.70\n",
      "hg = 2706.3\n",
      "he_act = ((1-Xe)*hf)+(Xe*hg)\n",
      "V2_2 = hi-he_act;\t\t\t\n",
      "n_N = (V2_2)/(V2_2_s)\t\t\n",
      "\n",
      "# Results\n",
      "print \" The isentropic efficiency of the nozzle = %0.3f \"%(n_N);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The isentropic efficiency of the nozzle = 0.868 \n"
       ]
      }
     ],
     "prompt_number": 25
    }
   ],
   "metadata": {}
  }
 ]
}