summaryrefslogtreecommitdiff
path: root/Gas_Dynamics_and_Jet_Propulsion_by_P._Murugaperumal/ch4.ipynb
blob: ec750ed0ee3eecafa14268aec4b2b7496f290e9d (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
{
 "metadata": {
  "name": "",
  "signature": "sha256:3dc843b6fccc3bd8da777a50fc56121df05dd48df905590c5824b3d32e8ee94a"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 4 : Flow through constant area ducts rayleigh flow"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.1 page : 9"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "Pa = 1*10**5 \t\t\t\t#Pressure of dry air in Pa\n",
      "To1 = 288 \t\t\t\t#Total stagnation temperature at inlet in K\n",
      "M1 = 1 \t\t\t\t#Mach number at inlet of pipe\n",
      "M2 = 0.8 \t\t\t\t#Mach number at exit o pipe\n",
      "Cp = 1.005 \t\t\t\t#Specific heat of dry air in kJ/kg-K   \n",
      " \n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "t1 = 0.834 \t\t\t\t#Temperature ratio at entry, i.e.entry static temperature to total temperature from gas tables at isentropic,M1 = 1 & adiabatic consmath.tant = 1.4\n",
      "T1 = t1*To1 \t\t\t\t#Static temperature at entry in Kelvin\n",
      "t2 = 0.964 \t\t\t\t#Temperature ratio at critical state, i.e. exit stagnation temperature to critical state temperature from gas tables at Rayleigh, M2 = 0.8 & adiabatic consmath.tant = 1.4\n",
      "To2 = t2*To1 \t\t\t\t#Total stagnation temperature at exit in K\n",
      "t3 = 1.025 \t\t\t\t#Temperature ratio at exit, i.e. exit static temperature to total temperature from gas tables at isentropic,M1 = 1 & adiabatic consmath.tant = 1.4\n",
      "T2 = t3*T1 \t\t\t\t#Static temperature at exit in Kelvin\n",
      "q = Cp*(To1-To2) \t\t\t\t#The heat transferred per unit mass flow in kJ/kg\n",
      "dT = To1-T2 \t\t\t\t#Change in temperature in K\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)The heat transferred per unit mass flow is %3.3f kJ/kg rejected \\\n",
      "\\nB)Change in temperature is %3.3f K'%(q,dT)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)The heat transferred per unit mass flow is 10.420 kJ/kg rejected \n",
        "B)Change in temperature is 41.803 K\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.2 page : 10"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "M1 = 3. \t\t\t\t#Mach number at entry\n",
      "P1 = 1. \t\t\t\t#Static Pressure at entry in atm\n",
      "T1 = 300. \t\t\t\t#Static Temperature at entry in K\n",
      "q = 300. \t\t\t\t#The heat transferred per unit mass flow in kJ/kg\n",
      "R = 287. \t\t\t\t#Gas consmath.tant in J/kg-K\n",
      "Cp = 1.005 \t\t\t\t#Specific heat of dry air in kJ/kg-K\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "t1 = 2.8 \t\t\t\t#Temperature ratio at entry from gas tables (M = 3,k = 1.4,isentropinC)\n",
      "To1 = t1*T1 \t\t\t\t#Total stagnation temperature at inlet in K\n",
      "p1 = 0.0272 \t\t\t\t#Pressure ratio  at entry from gas tables (M = 3,k = 1.4,isentropiC)\n",
      "Po1 = P1/p1 \t\t\t\t#Stagnation Pressure at entry in atm\n",
      "p2 = 0.176 \t\t\t\t#Static Pressure ratio  at critical state from gas tables (Rayleigh,k = 1.4,M = 3)\n",
      "Pt = P1/p2 \t\t\t\t#Static critical pressure in atm \n",
      "p3 = 3.424 \t\t\t\t#Stagnation Pressure ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 3)\n",
      "Pot = Po1/p3 \t\t\t\t#Stagnation critical pressure in atm\n",
      "t2 = 0.281 \t\t\t\t#Static temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 3) \n",
      "Tt = T1/t2 \t\t\t\t#Static critical temperature in K\n",
      "t3 = 0.654 \t\t\t\t#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 3)\n",
      "Tot = To1/t3 \t\t\t\t#Stagnation critical temperature in K\n",
      "To2 = (q/Cp)+To1 \t\t\t\t#Stagnation exit temperation in K\n",
      "t4 = (To2/Tot) \t\t\t\t#Stagnation Temperature ratio at exit\n",
      "M2 = 1.6 \t\t\t\t#Mack number at exit from gas tables (Rayleigh,t4)\n",
      "p4 = 0.524 \t\t\t\t#Static Pressure ratio  at exit from gas tables (Rayleigh,t4 = 0.866,M = 1.6)\n",
      "P2 = p4*Pt \t\t\t\t#Static Pressure at exit in atm\n",
      "p5 = 1.176 \t\t\t\t#Stagnation Pressure ratio at exit from gas tables (Rayleigh,t4 = 0.866,M = 1.6)\n",
      "Po2 = p5*Pot \t\t\t\t#Stagnation Pressure at exit in atm\n",
      "t5 = 0.702 \t\t\t\t#Static temperature ratio at exit from gas tables (Rayleigh,t4 = 0.866,M = 1.6)\n",
      "T2 = t5*Tt \t\t\t\t#Static exit temperature in K\n",
      "d2 = P2*101325/(R*T2) \t\t\t\t#density of air at exit in kg/m**3, P2 in N/m**2\n",
      "\n",
      "\t\t\t\t#outpur\n",
      "print 'A)The Mach numer at exit is %3.1f \\\n",
      "\\nB)Static Pressure at exit is %3.3f atm \\\n",
      "\\nC)Static exit temperature is %3.2f K \\\n",
      "\\nD)density of air at exit is %3.4f kg/m**3 \\\n",
      "\\nE)Stagnation exit temperation is %3.2f K \\\n",
      "\\nF)Stagnation Pressure at exit is %3.2f atm'%(M2,P2,T2,d2,To2,Po2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)The Mach numer at exit is 1.6 \n",
        "B)Static Pressure at exit is 2.977 atm \n",
        "C)Static exit temperature is 749.47 K \n",
        "D)density of air at exit is 1.4025 kg/m**3 \n",
        "E)Stagnation exit temperation is 1138.51 K \n",
        "F)Stagnation Pressure at exit is 12.63 atm\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.3 page : 11"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "M1 = 2 \t\t\t\t#Mach number at entry\n",
      "P1 = 1.4 \t\t\t\t#Static Pressure at entry in bar\n",
      "T1 = 323 \t\t\t\t#Static Temperature at entry in K\n",
      "Cp = 1.005 \t\t\t\t#Specific heat of dry air in kJ/kg-K\n",
      "k = 1.4 \t\t\t\t#Adiabatic consmath.tant\n",
      "R = 287 \t\t\t\t#Gas consmath.tant in J/kg-K\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "t1 = 0.555 \t\t\t\t#Temperature ratio at entry from gas tables (M = 2,k = 1.4,isentropiC)\n",
      "To1 = T1/t1 \t\t\t\t#Total stagnation temperature at inlet in K\n",
      "p1 = 0.364 \t\t\t\t#Pressure ratio  at entry from gas tables (M = 2,k = 1.4,isentropiC)\n",
      "Po1 = P1/p1 \t\t\t\t#Stagnation Pressure at entry in bar\n",
      "t2 = 0.529 \t\t\t\t#Static temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 2) \n",
      "Tt = T1/t2 \t\t\t\t#Static critical temperature in K\n",
      "t3 = 0.793 \t\t\t\t#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 2)\n",
      "Tot = To1/t3 \t\t\t\t#Stagnation critical temperature in K\n",
      "To2 = Tot \t\t\t\t#Stagnation exit temperation in K\n",
      "q = Cp*(To2-To1) \t\t\t\t#The heat transferred per unit mass flow in kJ/kg\n",
      "a1 = math.sqrt(k*R*T1) \t\t\t\t#Sound velocity in m/s\n",
      "C1 = M1*a1 \t\t\t\t#Air velocity in m/s\n",
      "d1 = (P1*10**5)/(R*T1) \t\t\t\t#density of air in kg/m**3\n",
      "ma = d1*C1 \t\t\t\t#Mass flow rate per unit area in kg/s-m**3\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)Mass flow rate per unit area is %3.2f kg/s-m**2 \\\n",
      "\\nB)Final temperarure is %3.3f K \\\n",
      "\\nC)Heat added is %3.2f kJ/kg'%(ma,Tt,q)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)Mass flow rate per unit area is 1088.13 kg/s-m**2 \n",
        "B)Final temperarure is 610.586 K \n",
        "C)Heat added is 152.68 kJ/kg\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.4 page : 11"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "C1 = 100. \t\t\t\t#Air velocity into combustion chamber in m/s\n",
      "P1 = 3. \t\t\t\t#Static Pressure at entry in bar\n",
      "T1 = 318. \t\t\t\t#Static Temperature at entry in K\n",
      "q = 630. \t\t\t\t#The heat transferred per unit mass flow in kJ/kg\n",
      "Cp = 1.005 \t\t\t\t#Specific heat of dry air in kJ/kg-K\n",
      "k = 1.4 \t\t\t\t#Adiabatic consmath.tant\n",
      "R = 287. \t\t\t\t#Gas consmath.tant in J/kg-K\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "a1 = math.sqrt(k*R*T1) \t\t\t\t#Sound velocity in m/s\n",
      "M1 = C1/a1 \t\t\t\t#Mach number at entry\n",
      "t1 = 0.985 \t\t\t\t#Temperature ratio at entry from gas tables (M1,k = 1.4,isentropiC)\n",
      "To1 = T1/t1 \t\t\t\t#Total stagnation temperature at inlet in K\n",
      "p1 = 0.947 \t\t\t\t#Pressure ratio  at entry from gas tables (M1,k = 1.4,isentropiC)\n",
      "Po1 = P1/p1 \t\t\t\t#Stagnation Pressure at entry in bar\n",
      "To2 = (q/Cp)+To1 \t\t\t\t#Stagnation exit temperation in K\n",
      "p2 = 2.163 \t\t\t\t#Static Pressure ratio  at critical state from gas tables (Rayleigh,k = 1.4,M = 0.28)\n",
      "Pt = P1/p2 \t\t\t\t#Static critical pressure in bar \n",
      "p3 = 2.206 \t\t\t\t#Stagnation Pressure ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 0.28)\n",
      "Pot = Po1/p3 \t\t\t\t#Stagnation critical pressure in bar\n",
      "t2 = 0.310 \t\t\t\t#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 0.28)\n",
      "Tot = To1/t2 \t\t\t\t#Stagnation critical temperature in K\n",
      "t3 = (To2/Tot) \t\t\t\t#Stagnation Temperature ratio at exit\n",
      "M2 = 0.7 \t\t\t\t#Mack number at exit from gas tables (Rayleigh,t3)\n",
      "p4 = 1.423 \t\t\t\t#Static Pressure ratio  at exit from gas tables (Rayleigh,t3,M2)\n",
      "P2 = p4*Pt \t\t\t\t#Static Pressure at exit in bar\n",
      "\n",
      "\t\t\t\t\n",
      "#Output \n",
      "print 'A)Pressure after combustion is %3.3f bar \\\n",
      "\\nB)Mach number after combustion is %3.1f'%(P2,M2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)Pressure after combustion is 1.974 bar \n",
        "B)Mach number after combustion is 0.7\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.5 page : 12"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "M1 = 3. \t\t\t\t#Mach number at entry\n",
      "To1 = 295. \t\t\t\t#Total stagnation temperature at inlet in K\n",
      "P1 = 0.5 \t\t\t\t#Static Pressure at entry in bar\n",
      "M2 = 1.5 \t\t\t\t#Mack number at exit\n",
      "Cp = 1.005 \t\t\t\t#Specific heat of dry air in kJ/kg-K\n",
      "R = 287. \t\t\t\t#Gas consmath.tant in J/kg-K\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "p1 = 0.0272 \t\t\t\t#Pressure ratio  at entry from gas tables (M = 3,k = 1.4,isentropiC)\n",
      "Po1 = P1/p1 \t\t\t\t#Stagnation Pressure at entry in bar\n",
      "t1 = 0.357 \t\t\t\t#Temperature ratio at entry from gas tables (M = 3,k = 1.4,isentropiC)\n",
      "T1 = t1*To1 \t\t\t\t#Static temperature at entry in Kelvin\n",
      "p2 = 0.176 \t\t\t\t#Static Pressure ratio  at critical state from gas tables (Rayleigh,k = 1.4,M = 3)\n",
      "Pt = P1/p2 \t\t\t\t#Static critical pressure in bar \n",
      "p3 = 3.424 \t\t\t\t#Stagnation Pressure ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 3)\n",
      "Pot = Po1/p3 \t\t\t\t#Stagnation critical pressure in bar\n",
      "t2 = 0.654 \t\t\t\t#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 3)\n",
      "Tot = To1/t2 \t\t\t\t#Stagnation critical temperature in K\n",
      "t3 = 0.280 \t\t\t\t#Static temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 3)\n",
      "Tt = T1/t3 \t\t\t\t#Static critical temperature in K\n",
      "p4 = 0.578 \t\t\t\t#\t\t\t\t#Static Pressure ratio  at exit from gas tables (Rayleigh,M = 1.5)\n",
      "P2 = p4*Pt \t\t\t\t#Static Pressure at exit in bar\n",
      "p5 = 1.122 \t\t\t\t#Stagnation Pressure ratio at exit from gas tables (Rayleigh,M = 1.5)\n",
      "Po2 = p5*Pot \t\t\t\t#Stagnation Pressure at exit in bar\n",
      "t4 = 0.753 \t\t\t\t#\t\t\t\t#Static temperature ratio at exit from gas tables (Rayleigh,M = 1.5)\n",
      "T2 = t4*Tt \t\t\t\t#Static exit temperature in K\n",
      "t5 = 0.909 \t\t\t\t#Stagnation temperature ratio at exit from gas tables (Rayleigh,M = 1.5)\n",
      "To2 = t5*Tot \t\t\t\t#Total stagnation temperature at exit in K\n",
      "q = Cp*(To1-To2) \t\t\t\t#The heat transferred per unit mass flow in kJ/kg\n",
      "SPC = Po1-Po2 \t\t\t\t#Change in stagnation pressure in bar\n",
      "n = math.log(Po1/Po2)/(math.log(Po1/Po2)-math.log(To1/To2)) \t\t\t\t#Exponent of polytropic equation\n",
      "qmax = Cp*(Tot-To1) \t\t\t\t#Maximum possible heat transfer in kJ/kg\n",
      "ds = Cp*math.log(T2/T1)-(R*math.log(P2/P1)) \t\t\t\t#Change in entropy in kJ/kg-K\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)Total temperature at exit is %3.2f K \\\n",
      "\\nB)Static pressure at exit is %3.3f bar  \\\n",
      "\\nC)Change in stagnation pressure is %3.2f bar \\\n",
      "\\nD)Exponent of polytropic equation is %3.2f'%(To2,P2,SPC,n)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)Total temperature at exit is 410.02 K \n",
        "B)Static pressure at exit is 1.642 bar  \n",
        "C)Change in stagnation pressure is 12.36 bar \n",
        "D)Exponent of polytropic equation is 0.77\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.6 page : 14"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "M2 = 0.9 \t\t\t\t#Mack number at exit\n",
      "P2 = 2.5 \t\t\t\t#Static Pressure at exit in bar\n",
      "T2 = 1273. \t\t\t\t#Static exit temperature in K\n",
      "t1 = 3.74 \t\t\t\t#ratio of stagnation temperatures at and exit entry\n",
      "Cp = 1.218 \t\t\t\t#Specific heat of dry air in kJ/kg-K\n",
      "k = 1.3 \t\t\t\t#Adiabatic consmath.tant\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "t2 = 0.892 \t\t\t\t#Temperauture ratio at exit from gas tables (isentropic,k = 1.3,M = 0.9)\n",
      "To2 = T2/t2 \t\t\t\t#Total stagnation temperature at exit in K\n",
      "To1 = To2/t1 \t\t\t\t#Total stagnation temperature at inlet in K\n",
      "p1 = 1.12 \t\t\t\t#Static pressure ratio at critical state from gas tables (Rayleigh,k = 1.3,M = 1.5)\n",
      "Pt = P2/p1 \t\t\t\t#Static critical pressure in bar\n",
      "t3 = 1.017 \t\t\t\t#Static temperature ratio at critical state from gas tables (Rayleigh,k = 1.3,M = 1.5)\n",
      "Tt = T2/t3 \t\t\t\t#Static critical temperature in K\n",
      "t4 = 0.991 \t\t\t\t#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.3,M = 1.5)\n",
      "Tot = To2/t4 \t\t\t\t#Stagnation critical temperature in K\n",
      "t5 = To1/Tot \t\t\t\t#Ratio of stagnation temperature at entry and critical state  \n",
      "M1 = 0.26 \t\t\t\t#Mach number at entry from gas tables (Rayleigh,t5,k = 1.3)\n",
      "p2 = 2.114 \t\t\t\t#Static Pressure ratio  at entry from gas tables (Rayleigh,t5,k = 1.3)\n",
      "P1 = Pt*p2 \t\t\t\t#Static Pressure at entry in bar\n",
      "t6 = 0.302 \t\t\t\t#Static temperature ratio  at entry from gas tables (Rayleigh,t5,k = 1.3)\n",
      "T1 = Tt*t6 \t\t\t\t#Static temperature at entry in Kelvin\n",
      "q = Cp*(To2-To1) \t\t\t\t#The heat transferred per unit mass flow in kJ/kg\n",
      "qmax = Cp*(Tot-To1) \t\t\t\t#Maximum possible heat transfer in kJ/kg \n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)Mach number at entry is %3.2f \\\n",
      "\\nB)Pressure at entry is %3.3f bar  \\\n",
      "\\nC)Temperature of gas is %3i K \\\n",
      "\\nD)Amount of heat added is %3.2f kJ/kg \\\n",
      "\\nE)Maximum heat that can be heated is %3.3f kJ/kg'%(M1,P1,T1,q,qmax)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)Mach number at entry is 0.26 \n",
        "B)Pressure at entry is 4.719 bar  \n",
        "C)Temperature of gas is 378 K \n",
        "D)Amount of heat added is 1273.47 kJ/kg \n",
        "E)Maximum heat that can be heated is 1289.259 kJ/kg\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.7 page : 15"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#input\n",
      "P1 = 0.343 \t\t\t\t#Static Pressure at entry in bar\n",
      "T1 = 310. \t\t\t\t#Static temperature at entry in Kelvin\n",
      "C1 = 60. \t\t\t\t#Velocity at entrance in m/s\n",
      "q = 1172.5 \t\t\t\t#The heat transferred per unit mass flow in kJ/kg\n",
      "Cp = 1.005 \t\t\t\t#Specific heat of dry air in kJ/kg-K\n",
      "k = 1.4 \t\t\t\t#Adiabatic consmath.tant\n",
      "R = 287. \t\t\t\t#Gas consmath.tant in J/kg-K\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "a1 = math.sqrt(k*R*T1) \t\t\t\t#Sound velocity in m/s\n",
      "M1 = C1/a1 \t\t\t\t#Mach number at entry\n",
      "t1 = 0.9943 \t\t\t\t#Temperature ratio at entry from gas tables (M = 0.17,k = 1.4,isentropic)\n",
      "To1 = T1/t1 \t\t\t\t#Total stagnation temperature at inlet in K\n",
      "p1 = 2.306 \t\t\t\t#Static Pressure ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 0.17)\n",
      "Pt = P1/p1 \t\t\t\t#Static critical pressure in bar\n",
      "t2 = 0.154 \t\t\t\t#Static temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 0.17) \n",
      "Tt = T1/t2 \t\t\t\t#Static critical temperature in K\n",
      "t3 = 0.129 \t\t\t\t#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 0.17)\n",
      "Tot = To1/t3 \t\t\t\t#Stagnation critical temperature in K\n",
      "c1 = 0.0665 \t\t\t\t#Velocity ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 0.17)\n",
      "Ct = C1/c1 \t\t\t\t#Critical velocity in m/s\n",
      "To2 = (q/Cp)+To1 \t\t\t\t#Stagnation exit temperation in K\n",
      "t4 = To2/Tot \t\t\t\t#Ratio of stagnation temperature at exit and critical state \n",
      "M2 = 0.45 \t\t\t\t#Mach number at exit from gas tables (Rayleigh,t4,k = 1.4)\n",
      "p2 = 1.87 \t\t\t\t#Static Pressure ratio  at exit from gas tables (Rayleigh,t4,k = 1.4)\n",
      "P2 = p2*Pt \t\t\t\t#Static Pressure at exit in bar \n",
      "t5 = 0.7075 \t\t\t\t#Static temperature ratio  at exit from gas tables (Rayleigh,t4,k = 1.4)\n",
      "T2 = t5*Tt \t\t\t\t#Static exit temperature in K\n",
      "c2 = 0.378 \t\t\t\t#Velocity ratio at critical state from gas tables (Rayleigh,k = 1.4,t4)\n",
      "C2 = Ct*c2 \t\t\t\t#exit velocity in m/s\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'At exit conditions : A)Mach number is %3.2f \\\n",
      "\\nB)Pressure is %3.3f bar \\\n",
      "\\nC)Temperature is %3.2f K \\\n",
      "\\nD)Exit velocity is %3.2f m/s'%(M2,P2,T2,C2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "At exit conditions : A)Mach number is 0.45 \n",
        "B)Pressure is 0.278 bar \n",
        "C)Temperature is 1424.19 K \n",
        "D)Exit velocity is 341.05 m/s\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.8 page : 16"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "M1 = 2. \t\t\t\t#Mach number at entry\n",
      "To1 = 523. \t\t\t\t#Total stagnation temperature at inlet in K\n",
      "Po1 = 6. \t\t\t\t#Stagnation Pressure at entry in bar\n",
      "To2 = 423. \t\t\t\t#Stagnation exit temperation in K\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "t1 = 0.555 \t\t\t\t#Temperature ratio at entry from gas tables (M = 2,k = 1.4,isentropiC)\n",
      "T1 = t1*To1 \t\t\t\t#Static temperature at entry in Kelvin\n",
      "p1 = 0.128 \t\t\t\t#Pressure ratio  at entry from gas tables (M = 2,k = 1.4,isentropiC)\n",
      "P1 = Po1*p1 \t\t\t\t#Static Pressure at entry in bar\n",
      "p2 = 0.364 \t\t\t\t#Static pressure ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 2)\n",
      "p3 = 1.503 \t\t\t\t#\t\t\t\t#Stagnation pressure ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 2), printing mistake in textbook\n",
      "t2 = 0.529 \t\t\t\t#Static Temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 2)\n",
      "t3 = 0.793 \t\t\t\t#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M = 2)\n",
      "t4 = (To2/To1)*t3 \t\t\t\t#Ratio of stagnation temperature at exit and critical state \n",
      "M2 = 3.15 \t\t\t\t#Mach number at exit from gas tables (Rayleigh,t4,k = 1.4)\n",
      "p4 = 0.161 \t\t\t\t#Static Pressure ratio  at exit from gas tables (Rayleigh,t4,k = 1.4), printing mistake in textbook\n",
      "t5 = 0.258 \t\t\t\t#Static temperature ratio  at exit from gas tables (Rayleigh,t4,k = 1.4)\n",
      "P2 = (p4/p2)*P1 \t\t\t\t#Static Pressure at exit in bar \n",
      "T2 = (t5/t2)*T1 \t\t\t\t#Static exit temperature in K\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'After Cooling : A)Mach number is %3.2f \\\n",
      "\\nB)Pressure is %3.4f bar \\\n",
      "\\nC)Temperature is %3.2f K'%(M2,P2,T2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "After Cooling : A)Mach number is 3.15 \n",
        "B)Pressure is 0.3397 bar \n",
        "C)Temperature is 141.57 K\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.9 page : 17"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "M2 = 0.8 \t\t\t\t#Mack number at exit\n",
      "t1 = 4. \t\t\t\t#Ratio of stagnation temperature at exit and entry\n",
      "T1 = 288. \t\t\t\t#Atmospheric temperature in K\n",
      "P1 = 1. \t\t\t\t#Atmospheric Pressure in atm\n",
      "Cp = 1.005 \t\t\t\t#Specific heat of dry air in kJ/kg-K\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "t2 = 0.964 \t\t\t\t#Ratio of stagnation temperature at exit and critical state from gas tables\n",
      "t3 = t2/t1 \t\t\t\t#Ratio of stagnation temperature at entry and critical state\n",
      "M1 = 0.24 \t\t\t\t#\t\t\t\t#Mach number at entry from gas tables (Rayleigh,t3,k = 1.4)\n",
      "t5 = 0.988 \t\t\t\t#Temperature ratio at entry from gas tables (M1,k = 1.4,isentropiC)\n",
      "To1 = T1/t5 \t\t\t\t#Total stagnation temperature at inlet in K\n",
      "To2 = t1*To1 \t\t\t\t#Stagnation exit temperation in K\n",
      "Tot = To1/t3 \t\t\t\t#Stagnation critical temperature in K\n",
      "q = Cp*(To2-To1) \t\t\t\t#The heat transferred per unit mass flow in kJ/kg\n",
      "qmax = Cp*(Tot-To1) \t\t\t\t#Maximum possible heat transfer in kJ/kg \n",
      "t6 = 0.9775 \t\t\t\t#Ratio of stagnation temperature for maximum static temperature (M = 1/math.sqrt(k),Rayleigh)\n",
      "To3 = Tot*t6 \t\t\t\t#maximum stagnation temperature in K\n",
      "q_req = Cp*(To3-To1) \t\t\t\t#Heat transfer required to get maximum static temperature in kJ/kg\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)Heat added per kg of air flow is %3.2f kJ/kg \\\n",
      "\\nB)Maximum possible heat transfer is %3.2f kJ/kg \\\n",
      "\\nC)Heat transfer required to get maximum static temperature is %3.1f kJ/kg'%(q,qmax,q_req)\n",
      "\n",
      "# note : rounding off error"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)Heat added per kg of air flow is 878.87 kJ/kg \n",
        "B)Maximum possible heat transfer is 922.63 kJ/kg \n",
        "C)Heat transfer required to get maximum static temperature is 895.3 kJ/kg\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.10 page : 17"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\t\n",
      "#Input data\n",
      "T1 = 560. \t\t\t\t#Static Temperature at entry in K\n",
      "P1 = 0.6 \t\t\t\t#Static Pressure at entry in bar\n",
      "C1 = 75. \t\t\t\t#Air velocity into combustion chamber in m/s\n",
      "mp = 30. \t\t\t\t#air fuel ratio\n",
      "CV = 92000. \t\t\t\t#Calorific value of fuel in kJ/kg\n",
      "Cp = 1.005 \t\t\t\t#Specific heat of dry air in kJ/kg-K\n",
      "k = 1.4 \t\t\t\t#Adiabatic consmath.tant\n",
      "R = 287. \t\t\t\t#Gas consmath.tant in J/kg-K\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "a1 = math.sqrt(k*R*T1) \t\t\t\t#Sound velocity in m/s\n",
      "M1 = C1/a1 \t\t\t\t#Mach number at entry\n",
      "t1 = 0.9949 \t\t\t\t#Temperature ratio at entry from gas tables (M1,k = 1.4,isentropiC)\n",
      "To1 = T1/t1 \t\t\t\t#Total stagnation temperature at inlet in K\n",
      "p1 = 0.982 \t\t\t\t#Pressure ratio  at entry from gas tables (M1,k = 1.4,isentropiC)\n",
      "Po1 = P1/p1 \t\t\t\t#Stagnation Pressure at entry in bar\n",
      "q = CV/(mp+1) \t\t\t\t#The heat transferred per unit mass flow in kJ/kg of gas, mp+1 = total amount of fuel = mf+ma\n",
      "p2 = 2.317 \t\t\t\t#Static Pressure ratio  at critical state from gas tables (Rayleigh,k = 1.4,M1)\n",
      "Pt = P1/p2 \t\t\t\t#Static critical pressure in bar\n",
      "p3 = 1.246 \t\t\t\t#Stagnation Pressure ratio at critical state from gas tables (Rayleigh,k = 1.4,M1)\n",
      "Pot = Po1/p3 \t\t\t\t#Stagnation critical pressure in bar\n",
      "t2 = 0.137 \t\t\t\t#Static temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M1) \n",
      "Tt = T1/t2 \t\t\t\t#Static critical temperature in K\n",
      "t3 = 0.115 \t\t\t\t#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M1)\n",
      "Tot = To1/t3 \t\t\t\t#Stagnation critical temperature in K\n",
      "To2 = (q/Cp)+To1 \t\t\t\t#Stagnation exit temperation in K\n",
      "t4 = To2/Tot \t\t\t\t#Ratio of stagnation temperature at exit and critical state \n",
      "M2 = 0.33 \t\t\t\t#Mach number at exit from gas tables (Rayleigh,t4,k = 1.4)\n",
      "p4 = 2.0825 \t\t\t\t#Static Pressure ratio  at exit from gas tables (Rayleigh,t4,k = 1.4)\n",
      "P2 = p4*Pt \t\t\t\t#Static Pressure at exit in bar, miscalculation in textbook\n",
      "p5 = 1.186 \t\t\t\t#Stagnation Pressure ratio at exit from gas tables (Rayleigh,t4,k = 1.4)\n",
      "Po2 = Pot*p5 \t\t\t\t#Stagnation Pressure at exit in bar\n",
      "t5 = 0.472 \t\t\t\t#Static temperature ratio  at exit from gas tables (Rayleigh,t4,k = 1.4)\n",
      "T2 = t5*Tt \t\t\t\t#Static exit temperature in K\n",
      "C2 = M2*math.sqrt(k*R*T2) \t\t\t\t#exit velocity in m/s\n",
      "SPL = ((Po1-Po2)/Po1)*100 \t\t\t\t#Percentage of pressure loss in combustion chamber in %\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)At exit:    \\\n",
      "\\nPressure is %3.5f bar     \\\n",
      "\\nTemperature is %3i K     \\\n",
      "\\nVelocity is %3.2f m/s     \\\n",
      "\\nMach number is %3.2f  \\\n",
      "\\nB)Maximum stagnation temperature available is %3.2f K \\\n",
      "\\nC)Percentage of pressure loss in combustion chamber is %3.1f percent \\\n",
      "\\nD)Intial Mach number is %3.2f '%(P2,T2,C2,M2,Tot,SPL,M1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)At exit:    \n",
        "Pressure is 0.53927 bar     \n",
        "Temperature is 1929 K     \n",
        "Velocity is 290.55 m/s     \n",
        "Mach number is 0.33  \n",
        "B)Maximum stagnation temperature available is 4894.53 K \n",
        "C)Percentage of pressure loss in combustion chamber is 4.8 percent \n",
        "D)Intial Mach number is 0.16 \n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.11 page : 19"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\t\n",
      "#Input data\n",
      "To1 = 473. \t\t\t\t#Total stagnation temperature at inlet in K\n",
      "To2 = 673. \t\t\t\t#Stagnation exit temperation in K\n",
      "M1 = 0.5 \t\t\t\t#Mach number at entry\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "t1 = 0.6914 \t\t\t\t#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M1)\n",
      "p1 = 1.7778 \t\t\t\t#Static pressure ratio at critical state from gas tables (Rayleigh,k = 1.4,M1)\n",
      "t2 = (To2/To1)*t1 \t\t\t\t#Stagnation temperature ratio at exit \n",
      "M2 = 0.867 \t\t\t\t#Mach number at exit from gas tables (Rayleigh,t2,k = 1.4)\n",
      "p2 = 1.16 \t\t\t\t#Static pressure ratio at exit from gas tables (Rayleigh,k = 1.4,M2)\n",
      "p = p2/p1 \t\t\t\t#ratio of static pressures at oulet and inlet\n",
      "PL = (1-p)*100 \t\t\t\t#pressure loss in %\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)Mach number is %3.3f \\\n",
      "\\nB)Percentage drop in pressure is %3.1f percent'%(M2,PL) \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)Mach number is 0.867 \n",
        "B)Percentage drop in pressure is 34.8 percent\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.12 page : 19"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\t\n",
      "#Input data\n",
      "t1 = 3. \t\t\t\t#Stagnation temperature ratio\n",
      "M2 = 0.8 \t\t\t\t#Mach number at exit\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "t2 = 0.964 \t\t\t\t#Ratio of stagnation temperature at exit and critical state (Rayleigh,M2,k = 1.4) \n",
      "p1 = 1.266 \t\t\t\t#Static Pressure ratio  at exit from gas tables (Rayleigh,M2,k = 1.4)\n",
      "t3 = t2/t1 \t\t\t\t#Stagnation temperature ratio at critical state \n",
      "M1 = 0.29 \t\t\t\t#Mach number at entry from gas tables (Rayleigh,t3,k = 1.4)\n",
      "p2 = 2.147 \t\t\t\t#Static pressure ratio at critical state from gas tables (Rayleigh,k = 1.4,M1)\n",
      "p = p1/p2 \t\t\t\t#ratio of static pressures at exit and entry\n",
      "PL = (1-p)*100 \t\t\t\t#Percentage loss in static pressure in %\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)Mach number at entry is %3.2f \\\n",
      "\\nB)Percentage loss in static pressure is %3i percent'%(M1,PL)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)Mach number at entry is 0.29 \n",
        "B)Percentage loss in static pressure is  41 percent\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.13 page : 20"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\t\n",
      "#Input data\n",
      "To1 = 300. \t\t\t\t#Total stagnation temperature at inlet in K\n",
      "To2 = 310. \t\t\t\t#Stagnation exit temperation in K\n",
      "G = 1300. \t\t\t\t#Mass velocity in kg/m**2-s\n",
      "P1 = 105.*10**3 \t\t\t\t#Static Pressure at entry in Pa\n",
      "Cp = 1.005 \t\t\t\t#Specific heat of dry air in kJ/kg-K\n",
      "R = 287. \t\t\t\t#Gas consmath.tant in J/kg-K\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "T1 = (((-2*P1**2*Cp)+math.sqrt(((-2*P1**2*Cp)**2)+(8*G**2*R**2*P1**2*Cp*To1)))/(2*G**2*R**2)) \t\t\t\t#Static temperature in K\n",
      "t1 = T1/To1 \t\t\t\t#Temperature ratio at entry\n",
      "M1 = 1.4 \t\t\t\t#Mach number at entry from gas tables (isentropic,t1,k = 1.4)\n",
      "t2 = 0.934 \t\t\t\t#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.4,M1)\n",
      "Tot = To1/t2 \t\t\t\t#Stagnation critical temperature in K\n",
      "t3 = To2/Tot \t\t\t\t#Stagnation temperature ratio at exit from gas tables (Rayleigh,k = 1.4,M1)\n",
      "M2 = 1.26 \t\t\t\t#Mach number at exit from gas tables (Rayleigh,t3,k = 1.4)\n",
      "\n",
      "\t\t\t\t\n",
      "#Output \n",
      "print 'A)The inlet mach number is %3.2f  \\\n",
      "\\nB)The exit mach number is %3.2f'%(M1,M2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)The inlet mach number is 1.40  \n",
        "B)The exit mach number is 1.26\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.14 page : 21"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "k = 1.3 \t\t\t\t#Adiabatic consmath.tant\n",
      "R = 466. \t\t\t\t#Gas consmath.tant in J/kg-K\n",
      "P1 = 0.345 \t\t\t\t#Static Pressure at entry in Pa\n",
      "T1 = 312. \t\t\t\t#Static Temperature at entry in K\n",
      "C1 = 65.5 \t\t\t\t#Entry velocity in m/s\n",
      "q = 4592. \t\t\t\t#The heat transferred per unit mass flow in kJ/kg\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "a1 = math.sqrt(k*R*T1) \t\t\t\t#Sound velocity in m/s\n",
      "M1 = C1/a1 \t\t\t\t#Mach number at entry\n",
      "t1 = 0.9965 \t\t\t\t#Temperature ratio at entry from gas tables (M1,k = 1.3,isentropiC)\n",
      "To1 = T1/t1 \t\t\t\t#Total stagnation temperature at inlet in K\n",
      "p1 = 2.235 \t\t\t\t#Static Pressure ratio  at critical state from gas tables (Rayleigh,k = 1.3,M1)\n",
      "Pt = P1/p1 \t\t\t\t#Static critical pressure in bar \n",
      "c1 = 0.051 \t\t\t\t#Velocity ratio at critical state from gas tables (Rayleigh,k = 1.3,M1)\n",
      "Ct = C1/c1 \t\t\t\t#Critical velocity in m/s\n",
      "t2 = 0.112 \t\t\t\t#Static temperature ratio at critical state from gas tables (Rayleigh,k = 1.3,M1) \n",
      "Tt = T1/t2 \t\t\t\t#Static critical temperature in K\n",
      "t3 = 0.098 \t\t\t\t#Stagnation temperature ratio at critical state from gas tables (Rayleigh,k = 1.3,M1)\n",
      "Tot = To1/t3 \t\t\t\t#Stagnation critical temperature in K\n",
      "Cp = (k*R)/(k-1) \t\t\t\t#Specific heat of dry air in kJ/kg-K\n",
      "To2 = (q/Cp)+To1 \t\t\t\t#Stagnation exit temperation in K\n",
      "t4 = (To2/Tot) \t\t\t\t#Stagnation Temperature ratio at exit\n",
      "M2 = 0.60 \t\t\t\t#Mack number at exit from gas tables (Rayleigh,t4)\n",
      "p2 = 1.567 \t\t\t\t#Static Pressure ratio  at exit from gas tables (Rayleigh,t4,k = 1.4)\n",
      "P2 = p2*Pt \t\t\t\t#Static Pressure at exit in bar \n",
      "t5 = 0.884 \t\t\t\t#Static temperature ratio  at exit from gas tables (Rayleigh,t4,k = 1.4)\n",
      "T2 = t5*Tt \t\t\t\t#Static exit temperature in K\n",
      "c2 = 0.564 \t\t\t\t#Velocity ratio at critical state from gas tables (Rayleigh,k = 1.4,t4)\n",
      "C2 = Ct*c2 \t\t\t\t#exit velocity in m/s\n",
      "qmax = Cp*(Tot-To1)/10**3 \t\t\t\t#Maximum possible heat transfer in kJ/kg \n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)Heat required to accelerate the gas from the inlet condition to sonic condition is %3.2f kJ/kg \\\n",
      "\\nB)The pressure and temperature at sonic condition are %3.3f bar and %3.2f K respectively \\\n",
      "\\nC)The properties at exit are:    \\\n",
      "\\nPressure is %3.3f bar    \\\n",
      "\\nTemperature is %3.2f K    \\\n",
      "\\nVelocity is %3i m/s'%(qmax,Pt,Tt,P2,T2,C2)\n",
      "\n",
      "# note : rounding off error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)Heat required to accelerate the gas from the inlet condition to sonic condition is 5819.23 kJ/kg \n",
        "B)The pressure and temperature at sonic condition are 0.154 bar and 2785.71 K respectively \n",
        "C)The properties at exit are:    \n",
        "Pressure is 0.242 bar    \n",
        "Temperature is 2462.57 K    \n",
        "Velocity is 724 m/s\n"
       ]
      }
     ],
     "prompt_number": 19
    }
   ],
   "metadata": {}
  }
 ]
}