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
|
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Chapter 2 : pipe flow of gasses and gas liquid mixtures\n"
]
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"example 2.1 page no : 27"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# find pressure maintained at compressor\n",
"\n",
"from scipy.optimize import fsolve\n",
"from math import *\n",
"\n",
"# Initialization of Variable\n",
"pi = 3.1428\n",
"mmm = 16.04/1000 #molar mass of methane\n",
"mV = 22.414/1000 #molar volume\n",
"R = 8.314\n",
"mu = 1.08/10**5\n",
"r = 4.2/100 #radius\n",
"rr = 0.026/2/r #relative roughness\n",
"Pfinal = 560.*1000.\n",
"tfinal = 273+24\n",
"l = 68.5\n",
"m = 2.35 #mass flow rate\n",
"\n",
"#calculation\n",
"A = pi*r**2\n",
"A = round(A*10.**5)/10.**5\n",
"rho = mmm/mV\n",
"rho24 = mmm*Pfinal*273/mV/101.3/tfinal #density at 24'C\n",
"u = m/rho24/A\n",
"Re = u*rho24*2*r/mu\n",
"\n",
"#from graph\n",
"phi = 0.0032\n",
"#for solving using fsolve we copy numerical value of constant terms\n",
"#using back calculation\n",
"#as pressure maintained should be more than Pfinal so guessed value is Pfinal\n",
"\n",
"def eqn(x):\n",
" y = m**2/A**2*log(x/Pfinal)+(Pfinal**2-x**2)/2/R/tfinal*mmm+4*phi*l/2/r*m**2/A**2\n",
" return y\n",
"x = fsolve(eqn,560*10**3)\n",
"print \"pressure maintained at compressor in (kN/m**2):\",x[0]/1000\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"pressure maintained at compressor in (kN/m**2): 960.06917347\n"
]
}
],
"prompt_number": 1
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"example 2.2 pageno : 29"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"'''\n",
"find\n",
"ratio of Pw/P1\n",
"maximum velocity in (m/s)\n",
"maximum mass flow rate in(kg/s)\n",
"heat taken up to maintain isothermal codition(J/s)\n",
"crtical pressure ratio in adiabatic condition\n",
"velocity at adiabatic condition in (m/s)\n",
"mass flow rate at adiabatic condition in (kg/s)\n",
"temperature of discharging gas in (Celcius)\n",
"'''\n",
"\n",
"from math import *\n",
"from numpy import *\n",
"from scipy.optimize import fsolve\n",
"\n",
"# Initialization of Variable\n",
"M = 28.8/1000\n",
"mu = 1.73/10**5\n",
"gamm = 1.402\n",
"P1 = 107.6*10**3\n",
"V = 22.414/1000\n",
"R = 8.314\n",
"temp = 285.\n",
"d = 4./1000\n",
"rr = 0.0008\n",
"phi = 0.00285\n",
"l = 68.5 \n",
"\n",
"#calculation\n",
"#constant term of equation\n",
"#part1\n",
"\n",
"a = 1.-8*phi*l/d #constant term in deff\n",
"def f(x):\n",
" return log(x**2)-x**2+2.938\n",
" \n",
"x = fsolve(f,1)\n",
"print x\n",
"z = 1./x[0]\n",
"z = round(z*1000.)/1000\n",
"print \"ratio of Pw/P1 : %.4f\"%z\n",
"\n",
"#part2\n",
"Pw = z*P1\n",
"nuw = V*P1*temp/Pw/M/273.\n",
"Uw = sqrt(nuw*Pw)\n",
"print \"maximum velocity in (m/s): %.4f\"%Uw\n",
"\n",
"#part3\n",
"Gw = pi*d**2/4*Pw/Uw\n",
"print \"maximum mass flow rate in(kg/s): %.4f\"%Gw\n",
"\n",
"#part4\n",
"G = 2.173/1000\n",
"J = G*Uw**2/2\n",
"print \"heat taken up to maintain isothermal codition(J/s): %.4f\"%J\n",
"\n",
"#part5\n",
"nu2 = 2.79 #found from graph\n",
"nu1 = R*temp/M/P1\n",
"P2 = P1*(nu1/nu2)**gamm\n",
"print \"crtical pressure ratio in adiabatic condition: %.4f\"%(P2/P1)\n",
"\n",
"#part6\n",
"Uw = sqrt(gamm*P2*nu2)\n",
"print \"velocity at adiabatic condition in (m/s): %.4f\"%Uw\n",
"\n",
"#part7\n",
"Gw = pi*d**2/4*Uw/nu2\n",
"print \"mass flow rate at adiabatic condition in (kg/s): %.4f\"%Gw\n",
"\n",
"\n",
"#part8\n",
"#polynomial in T of the form ax**2+bx+c = 0\n",
"c = gamm/(gamm-1)*P1*nu1+.5*Gw**2/pi**2/d**4*16*nu1**2\n",
"b = gamm/(gamm-1)*R/M\n",
"a = .5*Gw**2/pi**2/d**4*16*(R/M/P2)**2\n",
"y = poly1d([a,b,-c],False)\n",
"T2 = roots(y)\n",
"print \"temperature of discharging gas in (Celcius) : %.4f\"%(T2[1]-273)\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"[ 1.0268468]\n",
"ratio of Pw/P1 : 0.9740\n",
"maximum velocity in (m/s): 295.6723\n",
"maximum mass flow rate in(kg/s): 0.0045\n",
"heat taken up to maintain isothermal codition(J/s): 94.9841\n",
"crtical pressure ratio in adiabatic condition: 0.1629\n",
"velocity at adiabatic condition in (m/s): 261.8257\n",
"mass flow rate at adiabatic condition in (kg/s): 0.0012\n",
"temperature of discharging gas in (Celcius) : -46.3847"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n"
]
},
{
"output_type": "stream",
"stream": "stderr",
"text": [
"/usr/lib/python2.7/dist-packages/scipy/optimize/minpack.py:227: RuntimeWarning: The iteration is not making good progress, as measured by the \n",
" improvement from the last ten iterations.\n",
" warnings.warn(msg, RuntimeWarning)\n"
]
}
],
"prompt_number": 1
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"example 2.3 pageno : 35"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"'''\n",
"find\n",
"new estimate assumed\n",
"mass flow rate of steam through pipe\n",
"pressure of pipe at downstream end in\n",
"temperature of steam emerging from pipe\n",
"'''\n",
"\n",
"from scipy.optimize import fsolve \n",
"import math \n",
"\n",
"# Initialization of Variable\n",
"\n",
"#1 refer to initial condition\n",
"R=8.314\n",
"P1=550.*10**3\n",
"T1=273.+350\n",
"M=18./1000\n",
"d=2.4/100\n",
"pi=3.1428\n",
"A=pi*d**2./4\n",
"gamm=1.33\n",
"roughness=0.096/1000/d\n",
"l=0.85\n",
"phi=0.0035 #assumed value of friction factor\n",
"\n",
"#calculation\n",
"nu1=R*T1/M/P1\n",
"Pw=0.4*P1 #estimation\n",
"nuw=(P1/Pw)**0.75*nu1\n",
"enthalpy=3167*1000.\n",
"Gw=math.sqrt(enthalpy*A**2/(gamm*nuw**2/(gamm-1)-nu1**2/2-nuw**2/2))\n",
"def eqn(x):\n",
" return math.log(x/nu1)+(gamm-1)/gamm*(enthalpy/2*(A/Gw)**2*(1/x**2-1/nu1**2)+0.25*(nu1**2/x**2-1)-.5*math.log(x/nu1))+4*phi*l/d\n",
"\n",
"x=fsolve(eqn,0.2)\n",
"\n",
"if x[0] != nuw:\n",
" print \"we again have to estimate Pw/P1\"\n",
" print \"new estimate assumed as 0.45\"\n",
" Pw=0.45*P1 #new estimation\n",
" nuw=(P1/Pw)**0.75*nu1\n",
" # & we equalise nu2 to nuw\n",
" nu2=nuw \n",
" Gw=math.sqrt(enthalpy*A**2/(gamm*nuw**2/(gamm-1)-nu1**2./2-nuw**2./2))\n",
" print \"mass flow rate of steam through pipe kg/s): %.2f\"%(Gw) \n",
" #part 2\n",
" print \"pressure of pipe at downstream end in (kPa):\",Pw/1000\n",
"else:\n",
" print \"our estimation is correct\"\n",
"\n",
"#part3\n",
"enthalpyw=2888.7*1000. #estimated from steam table\n",
"Tw=math.sqrt((enthalpy-enthalpyw+.5*Gw**2/A**2*nu1**2)*2*A**2/Gw**2/R**2*M**2*Pw**2)\n",
"print \"temperature of steam emerging from pipe in (Celcius): %.4f\"%(Tw-273)\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"we again have to estimate Pw/P1\n",
"new estimate assumed as 0.45\n",
"mass flow rate of steam through pipe kg/s): 0.46\n",
"pressure of pipe at downstream end in (kPa): 247.5\n",
"temperature of steam emerging from pipe in (Celcius): 209.9420\n"
]
}
],
"prompt_number": 2
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"example 2.4 pageno : 39"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"'''\n",
"find\n",
"pressure at nozzle throat\n",
"diameter required at nozzle throat\n",
"sonic velocity at throat\n",
"'''\n",
"\n",
"import math \n",
"\n",
"# Initialization of Variable\n",
"M=28.05/1000\n",
"gamm=1.23\n",
"R=8.314\n",
"atm=101.3*1000\n",
"P1=3.*atm\n",
"\n",
"#calculation\n",
"P2=P1*(2./(gamm+1))**(gamm/(gamm-1))\n",
"print \"pressure at nozzle throat (kPa): %.4f\"%(P2/1000.)\n",
"\n",
"#part2\n",
"temp=273.+50\n",
"nu1=R*temp/P1/M\n",
"G=18. #mass flow rate\n",
"nu2=nu1*(P2/P1)**(-1/gamm)\n",
"A=G**2*nu2**2*(gamm-1)/(2*gamm*P1*nu1*(1-(P2/P1)**((gamm-1)/gamm)))\n",
"d=math.sqrt(4*math.sqrt(A)/math.pi)\n",
"print \"diameter required at nozzle throat in (cm) : %.4f\"%(d*100)\n",
"#part3\n",
"vel=math.sqrt(2*gamm*P1*nu1/(gamm-1)*(1-(P2/P1)**((gamm-1)/gamm)))\n",
"print \"sonic velocity at throat in(m/s): %.4f\"%vel\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"pressure at nozzle throat (kPa): 169.7903\n",
"diameter required at nozzle throat in (cm) : 18.8847\n",
"sonic velocity at throat in(m/s): 324.9787\n"
]
}
],
"prompt_number": 3
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"example 2.5 page no : 41"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# find height of manometer\n",
"\n",
"import math \n",
"\n",
"# Initialization of Variable\n",
"T=273.+15\n",
"rho=999.\n",
"rhom=13559. #density of mercury\n",
"g=9.81\n",
"P2=764.3/1000*rhom*g\n",
"R=8.314\n",
"M=16.04/1000\n",
"d=4.5/1000.\n",
"A=math.pi*d**2/4.\n",
"G=0.75/1000 #mass flow rate\n",
"delP=(1-math.exp(R*T*G**2./2/P2**2/M/A**2))*P2\n",
"h=-delP/rho/g\n",
"print \"height of manometer in (cm) %.4f\"%(h*100)\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"height of manometer in (cm) 16.7941\n"
]
}
],
"prompt_number": 4
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"example 2.6 page no : 44"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"'''\n",
"find\n",
"both liquid phase and solid phase \n",
"required pressure drop per unit length\n",
"'''\n",
"\n",
"import math \n",
"\n",
"# Initialization of Variable\n",
"rhol=931.\n",
"mu=1.55/10000 #viscosity of water\n",
"Vsp=0.6057 #specific volume\n",
"T=273+133.\n",
"mug=1.38/100000 #viscosity of steam\n",
"P=300*1000.\n",
"d=0.075\n",
"Gg=0.05 #mass flow gas phase\n",
"Gl=1.5 #mass flow liquid phase\n",
"A=math.pi*d**2./4\n",
"rho = 999.\n",
"#calculation\n",
"rhog=1./Vsp\n",
"rhog=round(rhog*1000)/1000.\n",
"velg=Gg/A/rhog\n",
"velg=round(velg*100)/100.\n",
"Reg=rhog*velg*d/mug\n",
"\n",
"#using chart\n",
"phig=0.00245 #friction factor gas phase\n",
"l=1\n",
"delPg=4*phig*velg**2*rhog/d\n",
"\n",
"#consider liquid phase\n",
"vell=Gl/A/rho\n",
"Rel=rho*vell*d/mu\n",
"if Rel>4000 and Reg>4000:\n",
" print \"both liquid phase and solid phase in turbulent motion\"\n",
" #from chart\n",
"\n",
"PHIg=5.\n",
"delP=PHIg**2.*delPg\n",
"print \"required pressure drop per unit length in (Pa) : %.4f\"%delP\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"both liquid phase and solid phase in turbulent motion\n",
"required pressure drop per unit length in (Pa) : 253.8050\n"
]
}
],
"prompt_number": 5
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
|