summaryrefslogtreecommitdiff
path: root/Engineering_Thermodynamics_by_Dr._S._S._Khandare/chapter_no_2_2.ipynb
blob: 05b5f64fed0d3a2f44f98673cd506f6c89b31308 (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
{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter No - 2 : Gas Laws And Properties\n",
      "    "
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.1 - Page No :  22"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "# Given data\n",
      "P1= 250 # in kN/m**2\n",
      "V1= 6.2 # in m**3\n",
      "V2= 1.82 # in m**3\n",
      "# Formula P1*V1 = P2*V2\n",
      "P2= P1*V1/V2 # in kN/m**2\n",
      "print \"Pressure of air after compression = %0.1f kN/m**2 \" %P2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure of air after compression = 851.6 kN/m**2 \n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.2 - Page No :  22"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "guagePressure= 1500 # in kN/m**2\n",
      "atmPressure= 100 # in kN/m**2\n",
      "P1= guagePressure+atmPressure # in kN/m**2\n",
      "V1= 0.1 # in m**3\n",
      "V2= 0.4 # in m**3\n",
      "# Formula P1*V1 = P2*V2\n",
      "P2= P1*V1/V2 # in kN/m**2\n",
      "NewGuagePressure= P2-atmPressure # in kN/m**2\n",
      "print \"New guage pressure = %0.f kN/m**2 (3 bar)\" %NewGuagePressure"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "New guage pressure = 300 kN/m**2 (3 bar)\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.3 - Page No :  23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "P1= -4+101.3 # in kN/m**2\n",
      "V1= 96+475 # in cm**3\n",
      "V2= 96 # in cm**3\n",
      "# Formula P1*V1 = P2*V2\n",
      "P2= P1*V1/V2 # in kN/m**2\n",
      "print \"Pressure at the end of the compression stroke = %0.1f kN/m**2 \" %P2\n",
      "print \"Pressure at the end of the compression stroke = %0.3f bar  \" %(P2*10**-2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure at the end of the compression stroke = 578.7 kN/m**2 \n",
        "Pressure at the end of the compression stroke = 5.787 bar  \n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.4 - Page No :  25"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "V0= 1 # in m**3\n",
      "t= 300 # in \u00b0C\n",
      "V= V0*(1+t/273) # in m**3\n",
      "print \"The volume occupied = %0.1f m**3 \" %V"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The volume occupied = 2.1 m**3 \n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.5 - Page No :  25"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "V1= 2 # in m**3\n",
      "T1= 30+273 # in K\n",
      "T2= 230+273 # in K\n",
      "# V1/T1 = V0/T0 = V2/T2\n",
      "V2= V1*T2/T1 # in m**3\n",
      "print \"The final volume = %0.3f m**3 \" %V2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The final volume = 3.320 m**3 \n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.6 - Page No :  29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "P1= 7*10**5 # in N/m**2\n",
      "V1= 3 # in m**3\n",
      "V2= 9 # in m**3\n",
      "T1= 150+273 # in K\n",
      "T2= 10+273 # in K\n",
      "# Formula P1*V1/T1 = P2*V2/T2\n",
      "P2= P1*V1*T2/(T1*V2) # in N/m**2\n",
      "print \"Pressure of the gas = %0.3f bar \" %(P2*10**-5)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure of the gas = 1.561 bar \n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.7 - Page No :  29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "P1= 100 # in kN/m**2\n",
      "V1byV2= 12 # in \n",
      "T1= 115+273 # in K\n",
      "T2= 180+273 # in K\n",
      "# Formula P1*V1/T1 = P2*V2/T2\n",
      "P2= P1*V1byV2*T2/T1 # in N/m**2\n",
      "print \"Absolute pressure at the end of compression stroke = %0.2f bar \" %(P2*10**-2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Absolute pressure at the end of compression stroke = 14.01 bar \n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.8 - Page No :  30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "mR= 8314.3 # in J/kg-mole-K\n",
      "P= 200*10**3 # in N/m**2\n",
      "T= 30+273 # in K\n",
      "# Formula P*V = mR*T\n",
      "V= mR*T/P # in m**3\n",
      "print \"The molecular volume of all the gases = %0.3f m**3 \" %V"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The molecular volume of all the gases = 12.596 m**3 \n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.9 - Page No :  30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "P1= 96 # in kN/m**2\n",
      "P2= 725 # in kN/m**2\n",
      "V1= 600 # in cm**3\n",
      "V2= 100 # in cm**3\n",
      "T1= 100+273 # in K\n",
      "# Formula P1*V1/T1 = P2*V2/T2\n",
      "T2= P2*V2*T1/(P1*V1) # in K\n",
      "print \"Temperature at the end of compression = %0.3f \u00b0C \" %(T2-273)\n",
      "# Note:- In the book, There is an error to calculate the value of T2."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Temperature at the end of compression = 196.488 \u00b0C \n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.10 - Page No :  30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "MR= 8314.2 # in J/kg-mole-K\n",
      "mass= 44 # Molecular mass of carbon dioxide in kg\n",
      "R= MR/mass # in J/kg-K\n",
      "P= 11 # in MPa\n",
      "P=P*10**6 # in Pa\n",
      "V= 50*10**-3 # in m**3\n",
      "T= 18+273 # in K\n",
      "# Formula P*V= m*R*T\n",
      "m= P*V/(R*T) # in kg\n",
      "m=round(m) # in kg\n",
      "MolecularVolume= MR*T/P # in m**3\n",
      "D= m/V # density of the gas in kg/m**3\n",
      "SpecificVolume= 1/D # in m**3/kg\n",
      "print \"The mass of the gas = %0.f kg \" %m\n",
      "print \"The Molecular volume = %0.2f m**3 \" %MolecularVolume\n",
      "print \"The density of the gas = %0.f kg/m**3 \" %D\n",
      "print \"The specific volume of the gas = %0.3f m**3/kg \" %SpecificVolume"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mass of the gas = 10 kg \n",
        "The Molecular volume = 0.22 m**3 \n",
        "The density of the gas = 200 kg/m**3 \n",
        "The specific volume of the gas = 0.005 m**3/kg \n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.11 - Page No :  31"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "P1= 350 # in kN/m**2\n",
      "P1=P1*10**3 # in N/m**2\n",
      "P2= 1.05 # in kN/m**2\n",
      "P2=P2*10**6 # in N/m**2\n",
      "V= 0.3 # in m**3\n",
      "R= 0.29 # in kJ/kg-K\n",
      "R= R*10**3 # in j/kgK\n",
      "T1= 35+273 # in K\n",
      "# Formula P*V= m*R*T\n",
      "m= P1*V/(R*T1) # in kg\n",
      "# Formula P1*V1/T1 = P2*V2/T2 and since V1= V2\n",
      "T2= P2*T1/P1 # in K\n",
      "print \"Temperature at constant volume compression = %0.f \u00b0C \" %(T2-273)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Temperature at constant volume compression = 651 \u00b0C \n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.12 - Page No :  31"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "g1= 1.75 # gauge reading in bar\n",
      "atm= 1.013 # in atmospheric pressure in bar\n",
      "P1= g1+atm # in bar\n",
      "T1= 12+273 # in K\n",
      "T2= 45+273 # in K\n",
      "# Formula P1*V1/T1 = P2*V2/T2 and since V1= V2\n",
      "P2= P1*T2/T1 # in bar\n",
      "g2=P2-atm # tyre gauge reading in bar \n",
      "print\"Tyre guage reading at 45\u00b0C = %0.2f bar \"%g2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Tyre guage reading at 45\u00b0C = 2.07 bar \n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.13 - Page No :  37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Q= 120 # in kJ\n",
      "W= 150 # in kJ\n",
      "E= Q-W # change in internal energy in kJ\n",
      "print \"The internal energy of the system decreases by %0.0f kJ\" %abs(E)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The internal energy of the system decreases by 30 kJ\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.14 - Page No :  37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Q= -40 # in kJ/kg\n",
      "W= -80 # in kJ/kg\n",
      "E= Q-W # change in internal energy in kJ/kg\n",
      "print \"Change in internal energy = %0.0f kJ/kg \" %E\n",
      "print \"Thus internal energy of the working substance increases \""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Change in internal energy = 40 kJ/kg \n",
        "Thus internal energy of the working substance increases \n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.15 - Page No :  37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Int_energy_changes= 20 # in kJ/kg\n",
      "Q= 0 # in kJ\n",
      "W= -90 # in kJ\n",
      "E= Q-W # change in internal energy in kJ/kg\n",
      "m= E/Int_energy_changes # in kg\n",
      "print \"The mass of the fluid in the system = %0.1f kg \" %m"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mass of the fluid in the system = 4.5 kg \n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.16 - Page No :  38"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "U= 2800 # in kJ/kg\n",
      "P= 20 # in bar\n",
      "P= P*10**5 # in N/m**2\n",
      "V= 0.23/1000 # in m**3\n",
      "SP= U+P*V # specific enthalpy in kJ/kg\n",
      "print \"The specific enthalpy = %0.0f kJ/kg \" %SP"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The specific enthalpy = 3260 kJ/kg \n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.17 - Page No :  38"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "h1= 210 #first heat transfer in kJ\n",
      "h2= -20 # second heat transfer in kJ\n",
      "h3= -190 # third heat transfer in kJ\n",
      "h4= 60 # fourth heat transfer in kJ\n",
      "W1= -180 # first work transfer in kJ\n",
      "W2= 200 # second  work transfer in kJ\n",
      "W3= -300 # third  work transfer in kJ\n",
      "# Total Heat transfer = Total work transfer\n",
      "W4= h1+h2+h3+h4-W1-W2-W3 # forth  work transfer in kJ\n",
      "print \"Fourth work transfer = %0.0f kJ is :\" %W4\n",
      "print \"Thus the system delivers\",int(W4),\"kJ of work\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fourth work transfer = 340 kJ is :\n",
        "Thus the system delivers 340 kJ of work\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.18 - Page No :  47"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Cv= 0.718 # in kJ/kgK\n",
      "R= 0.278 # in kJ/kgK\n",
      "T1= 15+273 # in K\n",
      "T2= 135+273 # in K\n",
      "m= 2 # mass in kg\n",
      "V1= 0.7 # in m**3\n",
      "Q= m*Cv*(T2-T1) # in kJ\n",
      "print \"Heat supplied to gas = %0.2f kJ \" %Q\n",
      "# Formula P1*V1= m*R*T1\n",
      "P1= m*R*T1/V1 # in kN/m**2 absolute\n",
      "# From P1/T1= P2/T2\n",
      "P2= P1*T2/T1 # in kN/m**2\n",
      "print \"The final pressure = %0.1f kN/m**2 \" %P2\n",
      "# Note : The calculation in the book is not accurate"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat supplied to gas = 172.32 kJ \n",
        "The final pressure = 324.1 kN/m**2 \n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.19 - Page No :  48"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Cv= 1.005 # in kJ/kgK\n",
      "T1= 200+273 # in K\n",
      "T2= 15+273 # in K\n",
      "V1= 0.12 # in m**3\n",
      "m= 0.25 # mass in kg\n",
      "Q= m*Cv*(T1-T2) # in kJ\n",
      "print \"Heat extracted from the gas = %0.2f kJ \" %Q\n",
      "# From V1/T1= V2/T2\n",
      "V2= V1*T2/T1 # in m**3\n",
      "print \"The final volume of the gas = %0.3f m**3 \" %V2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat extracted from the gas = 46.48 kJ \n",
        "The final volume of the gas = 0.073 m**3 \n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.20 - Page No :  48"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "m=2 # molecular mass\n",
      "UGC= 8.3143 # universal gas constant in kJ/kg-mole-K\n",
      "Cp= 14.41 # in kJ/kg-K\n",
      "R= UGC/m # in kJ/kgK\n",
      "Cv= Cp-R # in kJ/kgK\n",
      "gama= Cp/Cv \n",
      "print \"The value of R = %0.3f kJ/kgK is :\" %R\n",
      "print \"The value of Cv = %0.3f kJ/kgK \" %Cv\n",
      "print \"The value of gama = %0.1f\" %gama"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R = 4.157 kJ/kgK is :\n",
        "The value of Cv = 10.253 kJ/kgK \n",
        "The value of gama = 1.4\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.21 - Page No :  48"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Cp = 0.796 # in kJ/kg-K\n",
      "Cv = 0.67 # in kJ/kg-K\n",
      "P1=1 # in bar\n",
      "P1= P1*10**5 # in N/m**2\n",
      "P2=3.5 # in bar\n",
      "P2= P2*10**5 # in N/m**2\n",
      "V1= 0.12 # in m**3\n",
      "V2= 0.05 # in m**3\n",
      "m=1 # in kg\n",
      "R= Cp-Cv # in kJ/kg-K\n",
      "R= R*10**3 # in J/kg-K\n",
      "# Formula P*V= m*R*T\n",
      "T1= P1*V1/(m*R) # in K\n",
      "# Formula P1*V1/T1 = P2*V2/T2\n",
      "T2= P2*V2*T1/(P1*V1) # in K\n",
      "T= T2-T1 # Temperature rise in K\n",
      "print \"Temperature rise = %0.1f K \" %T\n",
      "E= m*Cv*(T2-T1) # change in internal energy kJ\n",
      "print \"Change in internal energy = %0.1f kJ \" %E"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Temperature rise = 43.7 K \n",
        "Change in internal energy = 29.2 kJ \n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.22 - Page No :  49"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "CO2= 0.12 #volume of CO2 in m**3\n",
      "CO= 0.25 # in m**3\n",
      "H2= 0.06 # in m**3\n",
      "CH4= 0.02 # in m**3\n",
      "N2= 0.55 # in m**3\n",
      "R= 8.3143 # Universal gas constant in kJ/kg-mol-K\n",
      "mm_CO2= 44 # molecular mass of CO2\n",
      "mm_CO= 28 \n",
      "mm_H2= 2 \n",
      "mm_CH4= 16 \n",
      "mm_N2= 28 \n",
      "Gm_CO2= 5.28 # gravimetric mass of CO2\n",
      "Gm_CO= 7.00 \n",
      "Gm_H2= 0.12 \n",
      "Gm_CH4= 0.32 \n",
      "Gm_N2= 15.40 \n",
      "total_Gm= Gm_CO2+Gm_CO+Gm_H2+Gm_CH4+Gm_N2 \n",
      "Per_relative_CO2= Gm_CO2/total_Gm*100 # in %\n",
      "Per_relative_CO= Gm_CO/total_Gm*100 # in %\n",
      "Per_relative_H2= Gm_H2/total_Gm*100 # in %\n",
      "Per_relative_CH4= Gm_CH4/total_Gm*100 # in %\n",
      "Per_relative_N2= Gm_N2/total_Gm*100 # in %\n",
      "print \"Analysis % Relative : \"\n",
      "print \"CO2      :   \",round(Per_relative_CO2,1)\n",
      "print \"CO       :   \",round(Per_relative_CO,1)\n",
      "print \"H2       :   \",round(Per_relative_H2,3)\n",
      "print \"CH4      :   \",round(Per_relative_CH4,2)\n",
      "print \"N2       :   \",round(Per_relative_N2,1)\n",
      "App_Gas_Constant= R/total_Gm # in kJ/kg-K\n",
      "mol_Vol= 22.4 #mole volume at NTP in m**3\n",
      "Average_Density= total_Gm/mol_Vol # in kg/m**3 at NTP\n",
      "print \"The Apparent gas constant = %0.4f kJ/kg-K \" %App_Gas_Constant\n",
      "print \"The average density = %0.3f kg/m**3 at NTP. \" %Average_Density"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Analysis % Relative : \n",
        "CO2      :    18.8\n",
        "CO       :    24.9\n",
        "H2       :    0.427\n",
        "CH4      :    1.14\n",
        "N2       :    54.8\n",
        "The Apparent gas constant = 0.2957 kJ/kg-K \n",
        "The average density = 1.255 kg/m**3 at NTP. \n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.23 - Page No :  50"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Cv = 652 # in J/kg-K\n",
      "R= 287 # in J/kg-K\n",
      "Cp= Cv+R # in J/kg-K\n",
      "m=0.3 # in kg\n",
      "P= 1.5*10**5 # in N/m**2\n",
      "V= 0.283 # in m**3\n",
      "# Formula P*V= m*R*T\n",
      "T= P*V/(m*R) # in K\n",
      "T= T-273 # in \u00b0C\n",
      "T1= -40 # in \u00b0C\n",
      "delta_U= m*Cv*(T-T1) # in J\n",
      "print \"Internal energy = %0.3f kJ \" %(delta_U*10**-3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Internal energy = 50.862 kJ \n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.24 - Page No :50  "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "H2= 0.50 #volume of H2 in m**3\n",
      "CH4= 0.19 # in m**3\n",
      "CO= 0.18 # in m**3\n",
      "C2H4= 0.02 # in m**3\n",
      "CO2= 0.05 # in m**3\n",
      "N2= 0.06 # in m**3\n",
      "P= 100 # pressure of mixture in kN/m**2\n",
      "mm_CO2= 44 # molecular mass of CO2\n",
      "mm_CO= 28 \n",
      "mm_H2= 2 \n",
      "mm_CH4= 16 \n",
      "mm_C2H4= 28 \n",
      "mm_N2= 28 \n",
      "R= 8.3143 # Universal gas constant in kJ/kg-mol-K\n",
      "R_H2= R/mm_H2 # gas constant for H2\n",
      "R_CO2= R/mm_CO2 \n",
      "R_CO= R/mm_CO \n",
      "R_C2H4= R/mm_C2H4 \n",
      "R_CH4= R/mm_CH4 \n",
      "R_N2= R/mm_N2 \n",
      "M= mm_CO2*CO2+mm_H2*H2+mm_CH4*CH4+mm_CO*CO+mm_C2H4*C2H4+mm_N2*N2 # in kg\n",
      "print \"Apparent molecular mass of the gas = %0.2f kg \" %M\n",
      "mol_Vol= 22.4 #mole volume at NTP in m**3\n",
      "density= M/mol_Vol # in kg/m**3\n",
      "print \"Density of the mixture             = %0.3f kg/m**3 \" %density\n",
      "mixture_G_constant= R/M # in kJ/kg-K \n",
      "print \"The mixture gas constant           = %0.3f kJ/kg-K \" %mixture_G_constant\n",
      "P_H2= P*H2 #partial pressure of H2 in kN/m**2\n",
      "P_CH4= P*CH4 # in kN/m**2\n",
      "P_CO= P*CO # in kN/m**2\n",
      "P_C2H4= P*C2H4 # in kN/m**2\n",
      "P_CO2= P*CO2 # in kN/m**2\n",
      "P_N2= P*N2 # in kN/m**2\n",
      "print \"The partial pressure of H2         = %0.0f kN/m**2\" %P_H2\n",
      "print \"The partial pressure of CH4        = %0.0f kN/m**2\" %P_CH4\n",
      "print \"The partial pressure of CO         = %0.0f kN/m**2\" %P_CO\n",
      "print \"The partial pressure of C2H4       = %0.0f kN/m**2\" %P_C2H4\n",
      "print \"The partial pressure of CO2        = %0.0f kN/m**2\" %P_CO2\n",
      "print \"partial pressure of N2             = %0.0f kN/m**2\" %P_N2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Apparent molecular mass of the gas = 13.52 kg \n",
        "Density of the mixture             = 0.604 kg/m**3 \n",
        "The mixture gas constant           = 0.615 kJ/kg-K \n",
        "The partial pressure of H2         = 50 kN/m**2\n",
        "The partial pressure of CH4        = 19 kN/m**2\n",
        "The partial pressure of CO         = 18 kN/m**2\n",
        "The partial pressure of C2H4       = 2 kN/m**2\n",
        "The partial pressure of CO2        = 5 kN/m**2\n",
        "partial pressure of N2             = 6 kN/m**2\n"
       ]
      }
     ],
     "prompt_number": 24
    }
   ],
   "metadata": {}
  }
 ]
}