summaryrefslogtreecommitdiff
path: root/backup/Aircraft_Propulsion_by__S._Farokhi_version_backup/Chapter2.ipynb
blob: 3ef33620582ebd89a3ecea0e31347cc84c99fe1c (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
{
 "metadata": {
  "name": "",
  "signature": "sha256:3e12517f8ab83d0ab6f64b711f692d9d5ad1586954ddb0ddc7157c71ba36d503"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter2-Compressible flow with friction and heat: A review"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1-pg19"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#what is the gas constant of air and density of air\n",
      "import math\n",
      "#intilization variable\n",
      "p=3*10**6 ; #pressure in Pa\n",
      "t=298. ; #temperatue in kelvin\n",
      "mw= 29.; #molecular weight in kg/mol\n",
      "ru=8314.; #universal constant in J/kmol.K\n",
      "r=ru/mw ;\n",
      "#using perfect gas law to get density:\n",
      "rho=p/(r*t) ;\n",
      "print'%s %.2f %s'%('Gas constant of air in',r,'J/kg.K')\n",
      "print'%s %.1f %s'%('Density of air in',rho,'kg/m^3')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Gas constant of air in 286.69 J/kg.K\n",
        "Density of air in 35.1 kg/m^3\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex2-pg23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#find out the exit temperature and exit density by various methods \n",
      "import math\n",
      "t1=288.; #inlet temperture in Kelvin\n",
      "p1=100*10**3; #inlet pressure in Pa\n",
      "p2=1*10**6 #exit pressure in Pa\n",
      "gma=1.4; #gamma.\n",
      "rg=287.; #gas constant in J/kg.K\n",
      "t2=t1*(p2/p1)**((gma-1)/gma);   #exit temperature \n",
      "print'%s %.5f %s'%('Exit temperature in',t2,'K')\n",
      "#first method to find exit density:\n",
      "#application of perfect gas law at exit\n",
      "rho=p2/(rg*t2); #rho= exit density.\n",
      "print'%s %.7f %s'%('exit density at by method 1 in',rho,'kg/m^3')\n",
      "#method 2: using isentropic relation between inlet and exit density.\n",
      "rho1=p1/(rg*t1); #inlet density.\n",
      "rho=rho1*(p2/p1)**(1/gma);\n",
      "print'%s %.2f %s'%('exit density by method 2 in',rho,'kg/m^3')\n",
      "\n",
      "                                                     "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Exit temperature in 556.04095 K\n",
        "exit density at by method 1 in 6.2663021 kg/m^3\n",
        "exit density by method 2 in 6.27 kg/m^3\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex3-pg25"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#what is the rate of mass flow through exit \n",
      "import math\n",
      "d1=1.2 #inlet 1 density in kg/m^3.\n",
      "u1=25. # inlet 1 veocity in m/s.\n",
      "a1=0.25 #inlet 1 area in m^2.\n",
      "d2=0.2 #inlet 2 density in kg/m^3.\n",
      "u2=225. #inlet 2 velocity in m/s.\n",
      "a2=0.10 #inlet 2 area in m^2.\n",
      "m1=d1*a1*u1; #rate of mass flow entering inlet 1.\n",
      "m2=d2*u2*a2; #rate of mass flow entering inlet 2.\n",
      "#since total mass in=total mass out,\n",
      "m3=m1+m2; #m3=rate of mass flow through exit.\n",
      "print'%s %.f %s'%('Rate of mass flow through exit in',m3,' kg/s')\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Rate of mass flow through exit in 12  kg/s\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex4-pg27"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#what is the axial force needed to support the plate and lateral force needed to support the plate\n",
      "import math\n",
      "u1=2 #speed of water going on the plate. X-component in m/s.\n",
      "v1=0 #speed of water going on the plate. Y-component in m/s.\n",
      "u2=1 #speed of water going on the plate. X-component in m/s.\n",
      "v2=1.73 #speed of water going on the plate Y-coponent in m/s.\n",
      "m=0.1 #rate of flow of mass of the water on the plate in kg/s.\n",
      "#Using Newton's second law.\n",
      "Fx=m*(u2-u1); #X-component of force exerted by water\n",
      "print'%s %.1f %s'%('Axial force needed to support the plate in',Fx,'N')\n",
      "Fy=m*(v2-v1); #Y-component of force exerted by water.\n",
      "print'%s %.3f %s'%('Lateral force needed to support the plate in',Fy,'N')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Axial force needed to support the plate in -0.1 N\n",
        "Lateral force needed to support the plate in 0.173 N\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex5-pg29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Exit total and static temperature \n",
      "m=50 #mass flow rate in kg/s.\n",
      "T1=298 #inlet temperature in K.\n",
      "u1=150 #inlet velocity in m/s.\n",
      "cp1=1004 #specific heat at constant pressure of inlet in J/kg.K.\n",
      "gm=1.4 #gamma.\n",
      "u2=400 # exit velocity in m/s.\n",
      "cp2=1243. #specific heat at constant pressure of exit in J/kg.K.\n",
      "q=42*10**6 #heat transfer rate in control volume in Watt.\n",
      "me=-100*10**3 #mechanical power in Watt.\n",
      "#first calculate total enthalpy at the inlet:\n",
      "ht1=cp1*T1+(u1**2)/2; #ht1=Total inlet enthalpy.\n",
      "#now applying conservation of energy equation:\n",
      "ht2=ht1+((q-me)/m) #ht2=Total enthalpy at exit.\n",
      "Tt2=ht2/cp2; #Tt2=Total exit temperature.\n",
      "T2=Tt2-((u2**2)/(2*cp2)); #T2=static exit temperature.\n",
      "print'%s %.5f %s'%('Exit total temperature in',Tt2,'K')\n",
      "print'%s %.4f %s'%('Exit static temperature in',T2,'K')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Exit total temperature in 927.14562 K\n",
        "Exit static temperature in 862.7852 K\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex6-pg65"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#intilization variable\n",
      "import math\n",
      "d=0.2 #Diameter in meters.\n",
      "M1=0.2 #inlet Mach no.\n",
      "p1=100*10**3 #inlet pressure in Pa\n",
      "Tt1=288. #total inlet temperature in K\n",
      "q=100*10**3 #rate of heat transfer to fluid in Watt.\n",
      "rg=287. #Gas constant in J/kg.K.\n",
      "gm=1.4 #gamma\n",
      "#(a)inlet mass flow:\n",
      "m=((gm/rg)**(1./2.))*(p1/(Tt1)**(1./2.))*3.14*(d*d)/4.*(M1/(1.+((gm-1.)/2.)*(M1**2.))**((gm+1.)/(2.*(gm-1.))));\n",
      "\n",
      "#(b)\n",
      "qm=q/m; #Heat per unit mass.\n",
      "#Tt1/Tcr=0.1736, pt1/Pcr=1.2346, ((Delta(s)/R)1=6.3402,p1/Pcr=2.2727)\n",
      "Tcr=Tt1/0.1736;\n",
      "\n",
      "Pcr=p1/2.2727;\n",
      "#From energy equation:\n",
      "cp=(gm/(gm-1.))*rg;\n",
      "Tt2=Tt1+(q/cp);\n",
      "q1cr=cp*(Tcr-Tt1)/1000.;\n",
      "M2=0.22;\n",
      "#From table : pt2/Pcr=1.2281, (Delta(s)/R)2=5.7395, p2/Pcr=2.2477.\n",
      "#The percent total pressure drop is (((pt1/Pcr)-(pt2/Pcr))/(pt1/Pcr))*100.\n",
      "p2=2.2477*Pcr;\n",
      "dp=((1.2346-1.2281)/1.2346)*100;\n",
      "#Entropy rise is the difference between (delta(s)/R)1 and (delta(s)/R)2.\n",
      "ds=6.3402-5.7395;\n",
      "#Static pressure drop in duct due to heat transfer is\n",
      "dps=((p1/Pcr)-(p2/Pcr))*Pcr/1000.;\n",
      "print'%s %.7f %s'%('Mass flow rate through duct in',m,'kg/s')\n",
      "print'%s %.4f %s'%('Critical heat flux that would choke the duct for the M1 in',q1cr,'kJ/kg')\n",
      "print'%s %.2f %s'%('The exit Mach No.',M2,'')\n",
      "print'%s %.7f %s'%('The percent total pressure loss',dp,'%')\n",
      "print'%s %.4f %s'%('The entropy rise',ds,'')\n",
      "print'%s %.7f %s'%('The static pressure drop in ',dps,'kPa')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mass flow rate through duct in 2.5235091 kg/s\n",
        "Critical heat flux that would choke the duct for the M1 in 1377.1556 kJ/kg\n",
        "The exit Mach No. 0.22 \n",
        "The percent total pressure loss 0.5264863 %\n",
        "The entropy rise 0.6007 \n",
        "The static pressure drop in  1.1000132 kPa\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex7-pg67"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#what is total exit temperautre if exit is choked and maximum heat released and fule to air ratio to thermally choke the combustor exit and total pressure loss\n",
      "#intilization variable\n",
      "import math\n",
      "M1=3.0 ##Mach no. at inlet\n",
      "pt1=45*10**3 ##Total pressure t inlet in Pa\n",
      "Tt1=1800 ##Total temperature at inlet in K\n",
      "hv=12000 ##Lower heating value of hydrogen kJ/kg\n",
      "gm=1.3 ##gamma\n",
      "R=0.287 ##in kJ/kg.K\n",
      "##Using RAYLEIGH table for M1=3.0 and gamma=1.3, we get Tt1/Tcr=0.6032, pt1/Pcr=4.0073.\n",
      "Tcr=Tt1/0.6032\n",
      "Pcr=pt1/4.0073\n",
      "##if exit is choked, Tt2=Tcr\n",
      "Tt2=Tt1/0.6032;\n",
      "cp=gm*R/(gm-1);\n",
      "##Energy balance across burner:\n",
      "Q1cr=cp*(Tcr-Tt1);\n",
      "f=(Q1cr/120000);\n",
      "##total pressure loss:\n",
      "dpt=1-Pcr/pt1;\n",
      "print'%s %.4f %s'%('Total exit temperature if exit is choked in',Tt2,'K')\n",
      "print'%s %.4f %s'%('Maximum heat released per unit mass of air in',Q1cr, 'kJ/kg')\n",
      "print'%s %.7f %s'%('fuel-to-air ratio to thermally choke the combustor exit',f,'')\n",
      "print'%s %.7f %s'%('Total pressure loss (in fraction)',dpt,'')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total exit temperature if exit is choked in 2984.0849 K\n",
        "Maximum heat released per unit mass of air in 1472.6069 kJ/kg\n",
        "fuel-to-air ratio to thermally choke the combustor exit 0.0122717 \n",
        "Total pressure loss (in fraction) 0.7504554 \n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex8-pg67"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the new inlet mach no and spilled flow at the inlet\n",
      "#initilization variable \n",
      "import math\n",
      "Tt1=50.+460. ##Converting the inlet temp. to the absolute scale i.e. in degree R\n",
      "M1=0.5 ##Initial inlet Mach no.\n",
      "pt1=14.7 ##Units in psia\n",
      "gm=1.4 ##gamma\n",
      "R=53.34 ##units in ft.lbf/lbm.degree R\n",
      "Tcr=Tt1/0.69136 \n",
      "cp=gm*R/(gm-1)\n",
      "##using energy equation:\n",
      "Q1cr=cp*(Tcr-Tt1)\n",
      "##since heat flux is 1.2(Q1cr).\n",
      "q=1.2*Q1cr\n",
      "Tt1cr1=Tt1+(Q1cr/cp) ##new exit total temp.\n",
      "z=Tt1/Tt1cr1\n",
      "M2=0.473\n",
      "\n",
      "f=M1/(1+((gm-1)/2)*M1**2)**((gm+1)/(2*(gm-1)))\n",
      "\n",
      "sm=((f*(M1)-f*(M2))/f*(M1))*100. ##sm=The % spilled flow at the inlet\n",
      "print'%s %.5f %s'%('The new inlet Mach no.',M2,'')\n",
      "print'%s %.5f %s'%('The % spilled flow at the inlet',sm,'')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The new inlet Mach no. 0.47300 \n",
        "The % spilled flow at the inlet 1.35000 \n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex9-pg76"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#intilization variable\n",
      "#calculate choking length abd exit mach no and total pressure loss and the static pressure and impulse due to friction \n",
      "import math\n",
      "d=0.2 ##diameter in meters.\n",
      "l=0.2 ##length in meters.\n",
      "Cf=0.005 ##average wall friction coefficient.\n",
      "M1=0.24 ##inlet mach no.\n",
      "gm=1.4 ##gamma.\n",
      "##From FANNO tbale\n",
      "L1cr=(9.3866*d/2)/(4*Cf);\n",
      "L2cr=L1cr-l;\n",
      "##from FANNO table\n",
      "M2=0.3;\n",
      "x=2.4956;\n",
      "y=2.0351;\n",
      "a=4.5383;\n",
      "b=3.6191;\n",
      "i1=2.043;\n",
      "i2=1.698;\n",
      "##% total pressure drop due to friction:\n",
      "dpt=(x-y)/(x)*100;\n",
      "##static pressur drop:\n",
      "dps=(a-b)/a*100;\n",
      "##Loss pf fluid:\n",
      "lf=(i2-i1);\n",
      "print'%s %.3f %s'%('The choking length of duct in',L1cr,'m')\n",
      "print'%s %.1f %s'%('The exit Mach no.',M2,'')\n",
      "print'%s %.6f %s'%('% total pressure loss',dpt,'')\n",
      "print'%s %.5f %s'%('The static pressure drop in',dps,'%')\n",
      "print'%s %.3f %s'%('Loss of impulse due to friction(I* times)',lf,'')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The choking length of duct in 46.933 m\n",
        "The exit Mach no. 0.3 \n",
        "% total pressure loss 18.452476 \n",
        "The static pressure drop in 20.25428 %\n",
        "Loss of impulse due to friction(I* times) -0.345 \n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex10-pg77"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#initilization variable\n",
      "import math \n",
      "#caluclate maximum length of the duct that will support given in inlet condition and the new inlet condition and flow drop \n",
      "M1=0.5\n",
      "a=2. ## area of cross section units in cm^2\n",
      "Cf=0.005 ##coefficient of skin friction\n",
      "gm=1.4 ##gamma\n",
      "##Calculations\n",
      "c=2.*(2.+1.); ##Parameter of surface.\n",
      "##From FANNO table: 4*Cf*L1cr/Dh=1.0691;\n",
      "Dh=4.*a/c; ##Hydrolic diameter.\n",
      "L1cr=1.069*Dh/(4.*Cf);\n",
      "##maximum length will be L1cr.\n",
      "##For new length(i.e. 2.16*L1cr), Mach no. M2 from FANNO table, M2=0.4;.\n",
      "M2=0.4;\n",
      "##the inlet total pressue and temp remains the same, therefore the mass flow rate in the duct is proportional to f(M):\n",
      "\n",
      "f=0.5/(1.+((gm-1.)/2.)*0.5**2.)**((gm+1.)/(2.*(gm-1.)))\n",
      "#endfunction\n",
      "dm=(f*(M1)-f*(M2))/f*(M1)*100.+10;\n",
      "print'%s %.3f %s'%(\"(a)Maximum length of duct that will support given inlet condition(in cm):\",L1cr,\"\")\n",
      "print'%s %.3f %s'%(\"(b)The new inlet condition mach no. M2:\",M2,\"\")\n",
      "print'%s %.3f %s'%(\"(c)% inlet mass flow drop due to the longer length of the duct:\",dm,\"\")\n",
      "\n",
      "\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)Maximum length of duct that will support given inlet condition(in cm): 71.267 \n",
        "(b)The new inlet condition mach no. M2: 0.400 \n",
        "(c)% inlet mass flow drop due to the longer length of the duct: 15.000 \n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex11-pg78"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import numpy\n",
      "M1=0.7;\n",
      "dpt=0.99; ##pt2/pt1=dpt.\n",
      "gm=1.4; ##gamma\n",
      "A2=1.237 \n",
      "a=1/1.237;\n",
      "import warnings\n",
      "warnings.filterwarnings('ignore')\n",
      "##Calculations:\n",
      "\n",
      "k=(1./dpt)*(a)*(M1/(1.+(0.2*(M1)**2.))**3.);\n",
      "po=([k*0.008,0,k*.12,0,k*.6,-1,k])\n",
      "W=numpy.roots(po)\n",
      "i=0;\n",
      "s=1;\n",
      "M2=W[4]\n",
      "print -M2,\"(a)The exit Mach no. M2:\"\n",
      "\n",
      "\n",
      "##p=p2/p1 i.e. static pressure ratio\n",
      "p=dpt*((1.+(gm-1.)*(M1)**2./2.)/(1.+(gm-1.)*(M2)**2./2.))**(gm/(gm-1.))\n",
      "##disp(p)\n",
      "Cpr=(2./(gm*(M1)**2.))*(p-1.) ##Cpr is static pressure recovery : (p2-p1)/q1.\n",
      "print\"%s %.2f %s\"%(\"(b)The static pressure recovery in the diffuser:\",-Cpr,\"\")\n",
      "##Change in fluid impulse:\n",
      "##Fxwalls=I2-I1=A1p1(1+gm*M1**2)-A2p2(1+gm*M2**2)\n",
      "##Let, u=Fxwall/(p1*A1)\n",
      "u=1.+gm*(M1)**2.-(1.237)*(p)*(1.+(gm*(M2)**2.))\n",
      "print\"%s %.2f %s\"%(\"(c)The force acting on the diffuser inner wall nondimensionalized by inlet static pressure and area:\",-u,\"\")\n",
      "\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(-1.70274823568-0j) (a)The exit Mach no. M2:\n",
        "(b)The static pressure recovery in the diffuser: 2.11 \n",
        "(c)The force acting on the diffuser inner wall nondimensionalized by inlet static pressure and area: 0.05 \n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex13-pg85"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "print \"Example2.13\"\n",
      "import numpy\n",
      "M1=0.5 #inlet mach no.\n",
      "p=10. #(p=pt1/p0) whaere pt1 is inlet total pressure and p0 is ambient pressure.\n",
      "dpc=0.01 #dpc=(pt1-Pth)/pt1 i.e. total pressure loss in convergant section\n",
      "f=0.99 #f=Pth/pt1\n",
      "dpd=0.02 #dpd=(Pth-pt2)/Pth i.e. total pressure loss in the divergent section\n",
      "j=1/0.98 #j=Pth/pt2\n",
      "A=2. #a=A2/Ath. nozzle area expansion ratio.\n",
      "gm=1.4 # gamma\n",
      "R=287. #J/kg.K universal gas constant.\n",
      "#Calculations:\n",
      "#\"th\"\" subscript denotes throat.\n",
      "Mth=1. #mach no at thorat is always 1.\n",
      "\n",
      "k=(j)*(1./A)*(Mth/(1+(0.2*(Mth)**2))**3)\n",
      "po=([k*0.008,0,k*.12,0,k*.6,-1,k])\n",
      "W=numpy.roots(po)\n",
      "i=0;\n",
      "s=1;\n",
      "M2=W[4]\n",
      "print M2,\"(a)The exit Mach no. M2:\"\n",
      "#p2/pt2=1/(1+(gm-1)/2*M2**2)**(gm/(gm-1)) \n",
      "#pt2=(pt2/Pth)*(Pth/pt1)*(pt1/p0)*p0\n",
      "#let pr=p2/p0\n",
      "pr=((1/j)*f*p)/(1+(0.2*(M2)**2))**(gm/(gm-1))\n",
      "\n",
      "print pr,\"(b)The exit static pressure in terms of ambient pressure p2/p0:\"#Fxwall=-Fxliquid=I1-I2\n",
      "\n",
      "#let r=A1/Ath\n",
      "r=(f)*(1/M1)*(((1+((gm-1)/2)*(M1)**2)/((gm+1)/2))**((gm+1)/(2*(gm-1))))\n",
      "#disp(r)\n",
      "#Psth is throat static pressure.\n",
      "#z1=Psth/pt1=f/((gm+1)/2)**(gm/(gm-1))\n",
      "z1=f/((gm+1)/2)**(gm/(gm-1))\n",
      "#disp(z1)\n",
      "#p1 is static pressure at inlet\n",
      "#s1=p1/pt1\n",
      "s1=1/(1+((gm-1)/2)*(M1)**2)**(gm/(gm-1))\n",
      "#disp(s1)\n",
      "#let y=Fxcwall/(Ath*pt1), where Fxwall is Fx converging-wall\n",
      "y=s1*r*(1+(gm*(M1)**2))-(z1*(1+(gm*(Mth)**2)))\n",
      "print y,\"(c)The nondimensional axial force acting on the convergent nozzle:\"\n",
      "#similarly finding nondimensional force on the nozzle DIVERGENT section\n",
      "#y1=Fxdiv-wall/Ath*pt1\n",
      "#f1=p2/pt1\n",
      "f1=pr*(1/p)\n",
      "#disp(f1)\n",
      "y1=z1*(1+(gm*(Mth)**2))-f1*A*(1+(gm*(M2)**2))\n",
      "print y1,\"(d)The nondimensional axial force acting on the divergent nozzle:\"\n",
      "#total axial force acting on nozzle wall: Fsum=y+y1\n",
      "Fsum=y+y1\n",
      "print Fsum,\"(e)The total axial force(nondimensional) acting on the nozzle: \""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Example2.13\n",
        "(2.17433864456+0j) (a)The exit Mach no. M2:\n",
        "(0.944524245306+0j) (b)The exit static pressure in terms of ambient pressure p2/p0:\n",
        "0.254397897726 (c)The nondimensional axial force acting on the convergent nozzle:\n",
        "(-0.184039795857+0j) (d)The nondimensional axial force acting on the divergent nozzle:\n",
        "(0.070358101869+0j) (e)The total axial force(nondimensional) acting on the nozzle: \n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex14-pg87"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate non dimensional axial force and negative sign on the axial force experienced by the compressor \n",
      "p=20. ##p=p2/p1 i.e. compression ratio.\n",
      "gm=1.4 ## gamma\n",
      "##Vx1=Vx2 i.e. axial velocity remains same.\n",
      "##calculations:\n",
      "d=p**(1/gm) ##d=d2/d1 i.e. density ratio\n",
      "A=1./d ## A=A2/A1 i.e. area ratio which is related to density ratio as: A2/A1=d1/d2.\n",
      "##disp(A)\n",
      "Fx=1.-p*A  ##Fx=Fxwall/p1*A1 i.e nondimensional axial force.\n",
      "print'%s %.7f %s'%(\"The non-dimensional axial force is :\",Fx,\"\")\n",
      "print'%s %.f %s'%(\"The negative sign on the axial force experienced by the compressor structure signifies a thrust production by this component.\",Fx,\" \")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The non-dimensional axial force is : -1.3535469 \n",
        "The negative sign on the axial force experienced by the compressor structure signifies a thrust production by this component. -1  \n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex15-pg88"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "print(\"Example 2.15\")\n",
      "t=1.8 ##t=T2/T1\n",
      "d=1./t ##d=d2/d1 i.e. density ratio\n",
      "v=1./d ##v=Vx2/Vx1 axial velocity ratio\n",
      "ndaf=1.-(v) ##nondimensional axial force acting on the combustor walls\n",
      "print'%s %.1f %s'%(\"The nondimensional axial force acting on the combustor walls:\",ndaf,\"\")\n",
      "print(\"Negative sign signifies a thrust production by the device\")\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Example 2.15\n",
        "The nondimensional axial force acting on the combustor walls: -0.8 \n",
        "Negative sign signifies a thrust production by the device\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex16-pg89"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "print(\"Example 2.16\")\n",
      "t=0.79 ##T2/T1 i.e. turbione expansion\n",
      "gm=1.4 ##gamma\n",
      "##calculations:\n",
      "d=t**(1./(gm-1.))\n",
      "##print'%s %.1f %s'%(d)\n",
      "a=1./d ##area ratio\n",
      "p=d**gm ##pressure ratio\n",
      "ndaf=1.-p*a\n",
      "print'%s %.2f %s'%(\"The nondimensional axial force:\",ndaf,\"\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Example 2.16\n",
        "The nondimensional axial force: 0.21 \n"
       ]
      }
     ],
     "prompt_number": 16
    }
   ],
   "metadata": {}
  }
 ]
}