summaryrefslogtreecommitdiff
path: root/Fluid_Mechanics_by_John_F._Douglas/Chapter_17.ipynb
blob: 2791e2c24ef72822dbe744284e772b24517ac303 (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
{
 "metadata": {
  "name": "",
  "signature": "sha256:c21785277c0a99c3eb4c310a9e20c477f6ab2a0a22da1b2d3844df1699a78d21"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 17: Compressible Flow in Pipes"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17.1, Page 566"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "import sympy\n",
      "from sympy import solve,symbols\n",
      "\n",
      " #Initializing  the  variables\n",
      "g  =  9.81;\n",
      "rho  =  1000;\n",
      "rhoHg  =  13.6*rho;\n",
      "d1  =  0.075;\n",
      "d2  =  0.025;\n",
      "Pi  =  0.250;\n",
      "Pt  =  0.150;\n",
      "P_Hg  =  0.760;\n",
      "rho1  =  1.6;\n",
      "gma  =  1.4;\n",
      "\n",
      " #Calculations\n",
      "P1  =  (Pi+P_Hg)*rhoHg*g;\n",
      "P2  =  (Pt+P_Hg)*rhoHg*g;\n",
      "rho2  =  rho1*(P2/P1)**(1/gma);\n",
      "V0=symbols('V0')\n",
      "V1=symbols('V1')\n",
      "Velo  =  solve([d2**2*V1*rho2-d1**2*V0*rho1,0.5*(V1**2  -  V0**2)*((gma-1)/gma)*(rho2*rho1/(rho2*P1-rho1*P2))-1],[V0,V1])\n",
      "s=(Velo[1])[0]\n",
      "Flow  =  math.pi*d1**2/4*s;\n",
      "\n",
      "print \"Volume of flow (m3/s):\",round(Flow,3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Volume of flow (m3/s): 0.06\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17.2, Page 571"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "\n",
      " #Initializing  the  variables\n",
      "Ma  =  4;\n",
      "gma  =  1.4;\n",
      "At  =  500;                                                              #  in  mm\n",
      "\n",
      " #Calculations\n",
      "N  =  1  +  (gma-1)*Ma**2/2;\n",
      "D  =  (gma+1)/2  ;\n",
      "#ratio of A/At ==R\n",
      "R  = round( (N/D)**((gma+1)/(2*(gma-1)))/Ma,2);\n",
      "A=At*R\n",
      "print \"Area of test section (mm^2):\",A"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Area of test section (mm^2): 5360.0\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17.3, Page 575"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "\n",
      " #Initializing  the  variables\n",
      "Ma1  =  2;\n",
      "gma  =  1.4;\n",
      "T1  =  15+273;                                                        #  In  kelvin\n",
      "P1  =  105;  \n",
      "\n",
      " #Calculations\n",
      "Ma2  =  (((gma-1)*Ma1**2  +2)/(2*gma*Ma1**2-gma+1))**0.5;\n",
      "P2  =  P1*(1+gma*Ma1**2)/(1+gma*Ma2**2);\n",
      "T2  =  T1*(1  +(gma-1)/2*Ma1**2)/(1  +(gma-1)/2*Ma2**2);\n",
      "\n",
      "\n",
      "print \"Mach No downstream shock wave                   :\",round(Ma2,3)\n",
      "print \"Pressure (bar) of downstream shock wave         :\",round(P2)\n",
      "print \"Temperature (Degree C) of downstream shock wave :\",T2 - 273"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mach No downstream shock wave                   : 0.577\n",
        "Pressure (bar) of downstream shock wave         : 473.0\n",
        "Temperature (Degree C) of downstream shock wave : 213.0\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17.4, Page 581"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "\n",
      " #Initializing  the  variables\n",
      "gma  =  1.4;\n",
      "f  =  0.00375;\n",
      "d  =  0.05;\n",
      "\n",
      " #Calculations\n",
      "m  =  d/4;\n",
      "def  x(Ma):\n",
      "    A  =(1  -Ma**2  )/(gma*Ma**2);\n",
      "    B  =  (gma+1)*Ma**2/(2+(gma-1)*Ma**2);  \n",
      "    y  =  m/f*(A+  (gma+1)*math.log(B)/(2*gma));\n",
      "    return y\n",
      "\n",
      "X1  =  x(0.2);                                  #  At  entrance  Ma  =  0.2;\n",
      "X06_X1  =x(0.6);                                #  Section(b)  Ma  =  0.6;\n",
      "\n",
      "X06  =    X1-X06_X1;\n",
      "\n",
      "print \"The Distance X1 at which the Mach number is unity (m) :\",round(X1,2)\n",
      "print \"Distance from the entrance (m)                        :\",round(X06,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Distance X1 at which the Mach number is unity (m) : 48.44\n",
        "Distance from the entrance (m)                        : 46.81\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17.5, Page 585"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "from scipy.optimize import fsolve\n",
      "\n",
      " #Initializing  the  variables\n",
      "gma  =  1.4;\n",
      "Q  =  28/60;                             #  m3/s\n",
      "d  =  0.1;\n",
      "p1  =  200*10**3;\n",
      "f  =  0.004;\n",
      "x_x1  =  60;\n",
      "R  =  287;\n",
      "T  =  15+273;\n",
      "\n",
      " #Calculations\n",
      "A  =  math.pi*d**2/4;\n",
      "m  =  d/4;\n",
      "v1  =  Q/A;\n",
      "pa  =  p1*(1-f*(x_x1)*v1**2/(m*R*T))**0.5;\n",
      "\n",
      "def g(p):\n",
      "    A  =  (v1*p1)**2/(R*T)\n",
      "    B  =  f*A*x_x1/(2*m);\n",
      "    y  =  (p**2  -  p1**2)/2  -A*math.log(p/p1)  +B;\n",
      "    return y\n",
      "    \n",
      "pb=fsolve(g,pa)                        #  Guessing  solution  around  pa\n",
      "pb=pb[0]\n",
      "print \"Pressure at the outlet, neglecting velocity changes   (kN/m2) :\",round(pa/1000,1)\n",
      "print \"Pressure at the outlet, allowing for velocity changes (kN/m2) :\",round(pb/1000,1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure at the outlet, neglecting velocity changes   (kN/m2) : 153.6\n",
        "Pressure at the outlet, allowing for velocity changes (kN/m2) : 150.4\n"
       ]
      }
     ],
     "prompt_number": 6
    }
   ],
   "metadata": {}
  }
 ]
}