summaryrefslogtreecommitdiff
path: root/Thermodynamics_An_Engineering_Approach/Chapter17.ipynb
blob: 5b1b7ade48d46fa75ffef3c9be506b2d13c6043a (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
{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 17: Compressible Flow"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-1 ,Page No.826"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "V1=250.0;#velocity of aircraft in m/s\n",
      "T1=255.07;#ambient air temperature in K\n",
      "P1=54.05;#atmospheric pressure in kPa\n",
      "h=5000.0;#altitude in m\n",
      "\n",
      "#from Table A-2a\n",
      "cp=1.005;#in kJ/kg-K\n",
      "k=1.4;\n",
      "\n",
      "#calculations\n",
      "T01=T1+V1**2/(2*cp*1000);#factor of 1000 to convert kJ to J\n",
      "P01=P1*(T01/T1)**(k/(k-1));\n",
      "#given pressure ratio in compressor *\n",
      "# T02 = T01*(P02/P01)^((k-1)/k)\n",
      "T02 = T01*(8)**((k-1)/k);\n",
      "win=cp*(T02-T01);\n",
      "print'the stagnation pressure at the compressor inlet %f kPa'%round(P01,2);\n",
      "print'the required compressor work per unit mass %f kJ/kg'%round(win,1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the stagnation pressure at the compressor inlet 80.840000 kPa\n",
        "the required compressor work per unit mass 233.400000 kJ/kg\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-2 ,Page No.829"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt\n",
      "\n",
      "#given data\n",
      "V=200.0;#air velocity in m/s\n",
      "T=30+273.0;#air temperature in K\n",
      "\n",
      "#from Table A-2a\n",
      "R=0.287;#in kJ/kg-K\n",
      "k=1.4;\n",
      "\n",
      "#calculations\n",
      "c=sqrt(k*R*T*1000);#factor of 1000 to convert kJ to J\n",
      "print'the speed of sound %i m/s'%round(c);\n",
      "Ma=V/c;\n",
      "print'the Mach number at the diffuser inlet is %f'%round(Ma,3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the speed of sound 349 m/s\n",
        "the Mach number at the diffuser inlet is 0.573000\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-3 ,Page No.829"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt\n",
      "\n",
      "#given data\n",
      "T0=200+273.0;#intial temperature in K\n",
      "P0=1400.0;#intial pressure in kPa\n",
      "#stagnant temp. & pressure is same as inlet due to small inlet velocity\n",
      "P=1200.0;#pressure corresponding to a pressure drop of 200 kPa\n",
      "m=3.0;#mass flow rate in kg/s\n",
      "\n",
      "#from Table A-2a\n",
      "cp=0.846;#in kJ/kg-K\n",
      "R=0.1889;#in kJ/kg-K\n",
      "k=1.289;\n",
      "\n",
      "#calculations\n",
      "T=T0*(P/P0)**((k-1)/k);\n",
      "V=sqrt(2*cp*(T0-T)*1000);#factor of 1000 to convert kJ to J\n",
      "p=P/(R*T);\n",
      "A=m/(p*V);\n",
      "c=sqrt(k*R*T*1000);#factor of 1000 to convert kJ to J\n",
      "Ma=V/c;\n",
      "print'velocity %f m/s'%round(V,1);\n",
      "print'density %f kg/m^3'%round(p,1);\n",
      "print'flow area %f cm^2'%round((A*10000),1);\n",
      "print'Mach number is %f'%round(Ma,3);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "velocity 164.900000 m/s\n",
        "density 13.900000 kg/m^3\n",
        "flow area 13.100000 cm^2\n",
        "Mach number is 0.494000\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-4 ,Page No.836"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "T0=200+273.0;#intial temperature in K\n",
      "P0=1400.0;#intial pressure in kPa\n",
      "\n",
      "#from Table A-2a\n",
      "k=1.289;\n",
      "\n",
      "#calculations\n",
      "#Tc & Tr stands for critical temp and ratio respectively\n",
      "#Pc & Pr stands for critical temp and ratio respectively\n",
      "Tr=2/(k+1);\n",
      "Pr=(2/(k+1))**(k/(k-1));\n",
      "Tc=Tr*T0;\n",
      "Pc=Pr*P0;\n",
      "print'critical temperature %i K'%round(Tc);\n",
      "print'critical pressure %i kPa'%round(Pc)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "critical temperature 413 K\n",
        "critical pressure 767 kPa\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-5 ,Page No.839"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt\n",
      "\n",
      "#given data\n",
      "Vi=150.0;#air velocity in m/s\n",
      "Ti=600+273.0;#air temperature in K\n",
      "Pi=1.0;#air pressure in MPa\n",
      "At=50.0/10000.0;#nozzle throat area in m^2\n",
      "\n",
      "#from Table A-2a\n",
      "R=0.287;#in kJ/kg-K\n",
      "cp=1.005;#in kJ/kg-K\n",
      "k=1.4;\n",
      "\n",
      "#calculations\n",
      "Toi=Ti+Vi**2/(2*cp*1000);#factor of 1000 to convert kJ to J\n",
      "Poi=Pi*(Toi/Ti)**(k/(k-1));\n",
      "#flow is isentropic \n",
      "#stagnation temp. and pressure values remain constant\n",
      "To=Toi;\n",
      "Po=Poi;\n",
      "#from Table 17\u20132\n",
      "#The critical-pressure ratio is 0.5283\n",
      "\n",
      "#Part a\n",
      "Pb=0.7;\n",
      "Pca=Pb/Po;\n",
      "# Pca > 0.5283\n",
      "#exit plane pressure is equal to the back pressure\n",
      "Pt=Pb;\n",
      "#from Table A\u201332\n",
      "Mat=0.778;\n",
      "#Tt/To = 0.892\n",
      "Tt=0.892*To;\n",
      "pt=Pt*1000/(R*Tt);#factor of 1000 to convert MPa to kPa\n",
      "Vt=Mat*sqrt(k*R*Tt*1000);#factor of 1000 to convert kJ to J\n",
      "ma=pt*At*Vt;\n",
      "print'the mass flow rate through the nozzle when the back pressure is 0.7 MPa %f kg/s'%round(ma,2);\n",
      "\n",
      "#Part b\n",
      "Pb=0.4;\n",
      "Pca=Pb/Po;\n",
      "# Pca < 0.5283\n",
      "#sonic conditions exists at the exit\n",
      "Ma=1;\n",
      "mb=At*(Po*1000)*(sqrt(k*1000/(R*To)))*(2/(k+1))**((k+1)/(2*(k-1)));#factor of 1000 to convert MPa to kPa and kJ to J\n",
      "print'the mass flow rate through the nozzle when the back pressure is 0.4 MPa %f kg/s'%round(mb,2);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the mass flow rate through the nozzle when the back pressure is 0.7 MPa 6.770000 kg/s\n",
        "the mass flow rate through the nozzle when the back pressure is 0.4 MPa 7.110000 kg/s\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-6 ,Page No.840"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "T1=400;#intial temperature in K\n",
      "P1=100;#intial pressure in kPa\n",
      "Ma1=0.3;#intial mach no\n",
      "A21=0.8;#A2/A1 as flow area has been reduced by 20 percent\n",
      "\n",
      "#assumption\n",
      "k=1.4;\n",
      "\n",
      "#from Table A\u201332\n",
      "#at Ma1=0.3\n",
      "#s stands for * symbol\n",
      "A1s = 2.0351;#A1/As\n",
      "T10 = 0.9823;#T1/T0\n",
      "P10 = 0.9305;#P1/P0\n",
      "A2s = A21*A1s;#A2/As\n",
      "#at this value of A2/As\n",
      "T20=0.9701;#T2/T0\n",
      "P20=0.8993;#P2/P0\n",
      "Ma2=0.391;\n",
      "\n",
      "#calculations\n",
      "T2=T1*T20/T10;\n",
      "P2=P1*P20/P10;\n",
      "print'Ma2 is %f'%round(Ma2,3);\n",
      "print'T2 %i K is'%round(T2);\n",
      "print'P2 %f kPa is'%round(P2,1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Ma2 is 0.391000\n",
        "T2 395 K is\n",
        "P2 96.600000 kPa is\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-7 ,Page No.844"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data \n",
      "T0=800;#intial temperature in K\n",
      "P0=1;#intial pressure in MPa\n",
      "Vi=0;#negligible intial velcity\n",
      "At=20;#throat area in cm^2\n",
      "Mae=2;#exit Mach number\n",
      "\n",
      "#from Table A-2a\n",
      "R=0.287;#in kJ/kg-K\n",
      "k=1.4;\n",
      "\n",
      "#calculations\n",
      "\n",
      "#part - a\n",
      "# Mach no. at exit is 2 hence sonic conditions at throat\n",
      "p0=P0*1000/(R*T0);#factor of 1000 to convert MPa to kPa\n",
      "#from Table A-32 at Mat=1\n",
      "#s stands for * symbol\n",
      "Ps0 = 0.5283;#Ts/T0\n",
      "Ts0 = 0.8333;#Ps/P0\n",
      "ps0=0.6339;#ps/p0\n",
      "Ps=Ps0*P0;\n",
      "Ts=Ts0*T0;\n",
      "ps=ps0*p0;\n",
      "As=At;\n",
      "Vs=sqrt(k*R*Ts*1000);#factor of 1000 to convert kJ to J\n",
      "print('the throat conditions');\n",
      "print'Presssure %f MPa'%round(Ps,4);\n",
      "print'Temperature %f K'%round(Ts,1);\n",
      "print'density %f kg/m^3'%round(ps,3);\n",
      "print'area %f cm^2'%round(As);\n",
      "print'velocity %f m/s'%round(Vs,1);\n",
      "\n",
      "#part - b\n",
      "#from Table A-32\n",
      "#at Mae=2\n",
      "Te0 = 0.5556;#Te/T0\n",
      "Pe0 = 0.1278;#Pe/P0\n",
      "pe0= 0.2300;#pe/p0\n",
      "Ae0= 1.6875;#Ae/Ao\n",
      "Pe=Pe0*P0;\n",
      "Te=Te0*T0;\n",
      "pe=pe0*p0;\n",
      "Ae=Ae0*At;\n",
      "Ve=Mae*sqrt(k*R*Te*1000);#factor of 1000 to convert kJ to J\n",
      "print('the exit plane conditions, including the exit area');\n",
      "print'Presssure %f MPa'%round(Pe,4);\n",
      "print'Temperature %f K'%round(Te,1);\n",
      "print'density %f kg/m^3'%round(pe,3);\n",
      "print'area %f cm^2'%round(Ae,2);\n",
      "print'velocity %f m/s'%round(Ve,1);\n",
      "#part - c\n",
      "m=ps*As*Vs/10000;#factor of 10000 to convert cm^2 to m^2\n",
      "print'the mass flow rate through the nozzle %f kg/s'%round(m,2);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the throat conditions\n",
        "Presssure 0.528300 MPa\n",
        "Temperature 666.600000 K\n",
        "density 2.761000 kg/m^3\n",
        "area 20.000000 cm^2\n",
        "velocity 517.500000 m/s\n",
        "the exit plane conditions, including the exit area\n",
        "Presssure 0.127800 MPa\n",
        "Temperature 444.500000 K\n",
        "density 1.002000 kg/m^3\n",
        "area 33.750000 cm^2\n",
        "velocity 845.200000 m/s\n",
        "the mass flow rate through the nozzle 2.860000 kg/s\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-9 ,Page No.850"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import log,sqrt\n",
      "\n",
      "#data from Ex - 17.7\n",
      "m=2.86;\n",
      "Ma1=2;\n",
      "P01=1;\n",
      "P1=0.1278;\n",
      "T1=444.5;\n",
      "p1=1.002;\n",
      "\n",
      "#from Table A-2a\n",
      "R=0.287;#in kJ/kg-K\n",
      "cp=1.005;#in kJ/kg-K\n",
      "k=1.4;\n",
      "\n",
      "#calculations\n",
      "\n",
      "#part - a\n",
      "#from Table A-33 at Ma1=2.0\n",
      "Ma2=0.5774;\n",
      "P0201=0.7209;#P02/P01\n",
      "P21=4.5;#P2/P1;\n",
      "T21=1.6875;#T2/T1\n",
      "p21=2.6667;#p2/p1\n",
      "P02=P0201*P01;\n",
      "P2=P21*P1;\n",
      "T2=T21*T1;\n",
      "p2=p21*p1;\n",
      "print'the stagnation pressure %f MPa'%round(P02,3);\n",
      "print'the static pressure %f MPa'%round(P2,3);\n",
      "print'static temperature %f K'%round(T2);\n",
      "print'static density %f kg/m^3'%round(p2,2);\n",
      "\n",
      "#part - b\n",
      "#s21 = s2 - s1\n",
      "s21=cp*log(T2/T1)-R*log(P2/P1);\n",
      "print'the entropy change across the shock %fkJ/kg-K'%round(s21,4);\n",
      "\n",
      "#part - c\n",
      "V2=Ma2*sqrt(k*R*T2*1000);#factor of 1000 to convert kJ to J\n",
      "print'the exit velocity %f m/s'%round(V2);\n",
      "\n",
      "#part - d\n",
      "print('flow rate is not affected by presence of shock waves amd remains 2.86 kg/sec')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the stagnation pressure 0.721000 MPa\n",
        "the static pressure 0.575000 MPa\n",
        "static temperature 750.000000 K\n",
        "static density 2.670000 kg/m^3\n",
        "the entropy change across the shock 0.094200kJ/kg-K\n",
        "the exit velocity 317.000000 m/s\n",
        "flow rate is not affected by presence of shock waves amd remains 2.86 kg/sec\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-10 ,Page No.858"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sin,pi\n",
      "\n",
      "#given data\n",
      "#using protactor frpm Fig 17-36\n",
      "u=19;#u stands for angle of the mach lines\n",
      "\n",
      "#calculations\n",
      "#by Eq. 17-47\n",
      "#i.e u= asin(1/Ma)\n",
      "Ma=1/sin(u*pi/180);#converting to radians\n",
      "print'The Mach number is %f'%round(Ma,2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Mach number is 3.070000\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-11 ,Page No.858"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sin,pi\n",
      "\n",
      "#given data\n",
      "Ma1=2;#Supersonic air mach no\n",
      "P1=75;#Supersonic air at pressure in kPa\n",
      "O=10*pi/180;#converting to radians & angle b/w shock wave and normal\n",
      "\n",
      "#constants used\n",
      "k=1.4;\n",
      "\n",
      "#calcualtions\n",
      "#with given values of Ma1 and O from Eq 17-46\n",
      "Bweak=39.3*pi/180;#converting to radians\n",
      "Bstrong=83.7*pi/180;#converting to radians\n",
      "#Weak shock\n",
      "Ma1w=Ma1*sin(Bweak);\n",
      "#Strong shock\n",
      "Ma1s=Ma1*sin(Bstrong);\n",
      "#from second part Eq 17-40\n",
      "Ma2w=0.8032;\n",
      "Ma2s=0.5794;\n",
      "#pressure ratio = (2*k*Ma^2 - k + 1)/(k + 1 )\n",
      "#Weak shock\n",
      "P2w=P1*(2*k*Ma1w**2 - k + 1)/(k + 1 );\n",
      "print'pressure for weak shock %i kPa'%round(P2w);\n",
      "#Strong shock\n",
      "P2s=P1*(2*k*Ma1s**2 - k + 1)/(k + 1 );\n",
      "print'pressure for strong shock %i kPa'%round(P2s);\n",
      "#Weak shock\n",
      "Ma2=Ma2w/sin(Bweak-O);\n",
      "print'Mach number downstream for weak shock is %f'%round(Ma2,2);\n",
      "#Strong shock\n",
      "Ma2=Ma2s/sin(Bstrong-O);\n",
      "print'Mach number downstream for strong shock is %f'%round(Ma2,3);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "pressure for weak shock 128 kPa\n",
        "pressure for strong shock 333 kPa\n",
        "Mach number downstream for weak shock is 1.640000\n",
        "Mach number downstream for strong shock is 0.604000\n"
       ]
      }
     ],
     "prompt_number": 35
    },
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Example 17-12 ,Page No.859"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt,pi,atan\n",
      "\n",
      "#given data\n",
      "Ma1=2;#Supersonic air mach no\n",
      "P1=230;#Supersonic air pressure in kPa\n",
      "O=10*pi/180;#converting to radians & O stands for angle of the mach lines\n",
      "\n",
      "#constants used\n",
      "k=1.4;\n",
      "\n",
      "#calculations\n",
      "#Eq. 17\u201349 for the upstream Prandtl\u2013Meyer function\n",
      "vMa1=sqrt((k+1)/(k-1))*atan(sqrt((k-1)*(Ma1**2-1)/(k+1))*pi/180)-atan(sqrt(Ma1**2-1)*pi/180);#converting to radians\n",
      "#Eq. 17\u201348 to calculate the downstream Prandtl\u2013Meyer function\n",
      "vMa2=O+vMa1;\n",
      "#using equation solver as implict nature of Eq 17-49\n",
      "Ma2=2.385;\n",
      "print'downstream Mach number Ma2 is %f'%round(Ma2,3);\n",
      "#P2 = (P2/P0)/(P1/P0) * P1\n",
      "P2= (1 + (k-1)*Ma2**2/2 )**(-k/(k-1)) / (1 + (k-1)*Ma1**2/2 )**(-k/(k-1)) * P1;\n",
      "print'downstream pressure %i kPa'%round(P2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "downstream Mach number Ma2 is 2.385000\n",
        "downstream pressure 126 kPa\n"
       ]
      }
     ],
     "prompt_number": 37
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-15 ,Page No.868"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi,sqrt\n",
      "\n",
      "#given data\n",
      "P1=480.0;#intial pressure in kPa\n",
      "T1=550.0;#intial temperature in K\n",
      "V1=80.0;#intial velocity in m/s\n",
      "d1=15.0/100.0;#diameter in m\n",
      "AF=40.0;#air to fuel ratio\n",
      "HV=40000.0;#heating value in kJ/kg\n",
      "\n",
      "#from Table A-2a\n",
      "R=0.287;#in kJ/kg-K\n",
      "cp=1.005;#in kJ/kg-K\n",
      "k=1.4;\n",
      "\n",
      "#calculations\n",
      "p1=P1/(R*T1);\n",
      "A1=pi*d1**2/4;\n",
      "mair=p1*A1*V1;\n",
      "mfuel=mair/AF;\n",
      "Q=mfuel*HV;\n",
      "q=Q/mair;\n",
      "T01=T1+V1**2/(2*cp);\n",
      "c1=sqrt(k*R*T1*1000);#factor of 1000 to convert kJ to J\n",
      "Ma1=V1/c1;\n",
      "#exit stagnation energy equation q= Cp (T02 - T01)\n",
      "T02=T01+q/cp;\n",
      "#from Table A\u201334\n",
      "#at Ma1\n",
      "#s stands for * symbol\n",
      "T0s=0.1291;#T0/Ts\n",
      "Ts0=T01/T0s;\n",
      "T2s=T02/Ts0;#T02/T*0\n",
      "#from Table A\u201334 at this ratio\n",
      "Ma2=0.3142;\n",
      "#Rayleigh flow relations corresponding to the inlet and exit Mach no\n",
      "#at Ma1\n",
      "T1s=0.1541;#T1/Ts\n",
      "P1s=2.3065;#P1/Ps\n",
      "V1s=0.0668;#V1/Vs\n",
      "#at Ma2\n",
      "T2s=0.4389;#T2/Ts\n",
      "P2s=2.1086;#P2/Ps\n",
      "V2s=0.2082;#V2/Vs\n",
      "T2=T2s/T1s*T1;\n",
      "P2=P2s/P1s*P1;\n",
      "V2=V2s/V1s*V1;    \n",
      "print'Mach Number at exit is %f'%round(Ma2,4);\n",
      "print'Presssure %i MPa'%round(P2);\n",
      "print'Temperature %i K'%round(T2);\n",
      "print'velocity %i m/s'%round(V2);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mach Number at exit is 0.314200\n",
        "Presssure 439 MPa\n",
        "Temperature 1566 K\n",
        "velocity 249 m/s\n"
       ]
      }
     ],
     "prompt_number": 41
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17-16 ,Page No.870"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt\n",
      "\n",
      "#given data\n",
      "P01=2000;#entry pressure in kPa\n",
      "T1=400;#entry temperature in C\n",
      "V1=0;#negligible velocity at entry\n",
      "nN=0.93;#overall nozzle efficiency\n",
      "m=2.5;#mass flow rate in kg/s\n",
      "P2=300;#exit pressure in kPa\n",
      "\n",
      "#calculations\n",
      "\n",
      "#part - a\n",
      "P201=P2/P01;\n",
      "#critical pressure ratio at this values is 0.546\n",
      "Pt=0.546*P01;\n",
      "#at inlet\n",
      "h1=3248.4;\n",
      "h01=h1;\n",
      "s1=7.1292;\n",
      "#at throat\n",
      "st=s1;\n",
      "ht=3076.8;\n",
      "vt=0.24196;\n",
      "Vt=sqrt(2*(h01-ht)*1000);#factor of 1000 to convert kJ to J\n",
      "At=m*vt/Vt;\n",
      "#at state 2s\n",
      "s2s=s1;\n",
      "h2s=2783.6;\n",
      "#nN = (h01 - h2)/ (h01 - h2s)\n",
      "h2=h01-nN*(h01-h2s);\n",
      "#at P2 and h2\n",
      "v2=0.67723;\n",
      "s2=7.2019;\n",
      "V2=sqrt(2*(h01-h2)*1000);#factor of 1000 to convert kJ to J\n",
      "A2=m*v2/V2;\n",
      "print'throat area %f cm^2'%round((At*10000),2);\n",
      "print'exit area %f cm^2'%round((A2*10000),2);\n",
      "\n",
      "#part - b\n",
      "# at st=7.1292\n",
      "#pressures of 1.115 and 1.065 MPa\n",
      "#c calculated using tables\n",
      "c=sqrt((1115-1065)/(1/0.23776 - 1/0.24633)*1000);#factor of 1000 to convert kPa to Pa\n",
      "Ma=Vt/c;\n",
      "print'the Mach number at the throat is %f'%round(Ma,2);\n",
      "# at s2=7.2019\n",
      "#pressures of 325 and 275 kPa\n",
      "c=sqrt((325-276)/(1/0.63596 - 1/0.72245)*1000);#factor of 1000 to convert kPa to Pa\n",
      "Ma=V2/c;\n",
      "print'the Mach number at the nozzle exit is %f'%round(Ma,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "throat area 10.330000 cm^2\n",
        "exit area 18.210000 cm^2\n",
        "the Mach number at the throat is 1.000000\n",
        "the Mach number at the nozzle exit is 1.820000\n"
       ]
      }
     ],
     "prompt_number": 44
    }
   ],
   "metadata": {}
  }
 ]
}