summaryrefslogtreecommitdiff
path: root/Thermodynamics_An_Engineering_Approach/Chapter5.ipynb
blob: da9be875a73a69d7de516bd449bbdbcf84630192 (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
{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 5: Mass and Energy Analysis of Control Volumes"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-1 ,Page No.224"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "V=10.0;#volumne of bucket in galon\n",
      "t=50;#time taken to fill the bucket in sec\n",
      "p=1;#density of water in kg/L\n",
      "re=0.8/2/100;#radius of nozzle exit in m\n",
      "\n",
      "#calculations\n",
      "Vd=V/t*3.7854;#factor 0f 3.7854 for gal to L\n",
      "print'volumne flow rate through hose %f L/s'%round(Vd,3);\n",
      "m=p*Vd;\n",
      "print'mass flow rate through hose %f kg/s'%round(m,3);\n",
      "Ae=math.pi*re**2;\n",
      "Ve=Vd/Ae/1000;#factor of 1000 for L to m^3\n",
      "print'average velocity at the nozzle %f m/s'%round(Ve,1);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "volumne flow rate through hose 0.757000 L/s\n",
        "mass flow rate through hose 0.757000 kg/s\n",
        "average velocity at the nozzle 15.100000 m/s\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-2 ,Page No.225"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from scipy.integrate import quad \n",
      "from pylab import *\n",
      "\n",
      "#given data\n",
      "Dtank=3*12;#diameter of tank in inches\n",
      "Djet=0.5;#diameter of water jet in inches\n",
      "h0=2;#bottom reference in ft\n",
      "h1=4;#height of water tank in ft\n",
      "\n",
      "#constants used \n",
      "g=32.2;#in ft/s^2\n",
      "\n",
      "#calculations\n",
      "#min - mout = dmCV/dt\n",
      "#mout = p*(2*g*h*Ajet)^2\n",
      "#mCV = p*Atank*h\n",
      "#from these we get dt = Dtank^2/Djet^2 * (dh/(2*g*h)^2)\n",
      "def intgrnd1(h): \n",
      " return (Dtank**2/Djet**2*(1/sqrt(2*g*h)))\n",
      "t, err = quad(intgrnd1, h0, h1) \n",
      "t=(t/60);#in min\n",
      "print'time taken to drop to 2 ft %f min'%round(t,1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "time taken to drop to 2 ft 12.600000 min\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-3 ,Page No.229"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "P=150;#operating pressure in kPa\n",
      "Vliquid=0.6/1000.0;#amount of liquid in the cooker in m^3\n",
      "t=40.0*60;#period of operation in sec\n",
      "Ac=8*10**-6;#exit area of opening in m^2\n",
      "\n",
      "#from Table A-5\n",
      "#from P = 150 kPa\n",
      "h=2693.1;\n",
      "ug=2519.2;\n",
      "vf=0.001053;\n",
      "vg=1.1594;\n",
      "\n",
      "#calculations\n",
      "m=Vliquid/vf;\n",
      "md=m/t;\n",
      "print'mass flow rate %f kg/s'%md;\n",
      "V=md*vg/(Ac);\n",
      "print'exit velocity %f m/s'%round(V,1);\n",
      "Eflow=h-ug;\n",
      "Et=h;\n",
      "print'flow energy %f kJ/kg'%round(Eflow,1);\n",
      "print'total energy %f kJ/kg'%round(Et,1);\n",
      "Emass=md*Et;\n",
      "print'rate at which energy leaves the cooker %f kW'%round(Emass,3)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "mass flow rate 0.000237 kg/s\n",
        "exit velocity 34.400000 m/s\n",
        "flow energy 173.900000 kJ/kg\n",
        "total energy 2693.100000 kJ/kg\n",
        "rate at which energy leaves the cooker 0.639000 kW\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-4 ,Page No.234"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "T1=283;#temperature of air in K\n",
      "P1=80;#entering pressure in kPa\n",
      "V1=200;#velocity ar inlet in m/s\n",
      "A1=0.4;#inlet area in m^2\n",
      "\n",
      "#constants used\n",
      "R=0.287;#in kPa-m^3/kg-K\n",
      "\n",
      "#calulations\n",
      "v1=R*T1/P1;\n",
      "m=V1*A1/v1;\n",
      "print'mass flow rate of air %f kg/s'%round(m,1);\n",
      "# Ein - Eout = dEsystem / dt\n",
      "#from Table A-17\n",
      "h1=283.14;\n",
      "V2=0;\n",
      "h2=h1-(V2^2 - V1^2)/2/1000;#factor of 1000 to convert to kJ/kg\n",
      "#from Table A-17 at this value of h2\n",
      "T2=303;\n",
      "print'the temperature %i K is'%T2;\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "mass flow rate of air 78.800000 kg/s\n",
        "the temperature 303 K is\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-5 ,Page No.235"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "P1=250;#inlet pressure in psia\n",
      "T1=700;#inlet temp in F\n",
      "A1=0.2;#inlet area in ft^2\n",
      "qout=1.2;#heat losses in Btu/lbm\n",
      "m=10;#mass flow rate in lbm/sec\n",
      "P2=200;#nozzle pressure in kPa\n",
      "V2=900;#nozzle velocity in m/s\n",
      "\n",
      "#from Table A-6E\n",
      "v1=2.6883;\n",
      "h1=1371.4;\n",
      "\n",
      "#calculations\n",
      "V1=m*v1/A1;\n",
      "print'the inlet velocit %f f/s'%round(V1,1);\n",
      "# Ein - Eout = dEsystem / dt\n",
      "h2=h1-qout-(V2**2 - V1**2)/2/25037;#factor of 25037 to convert to Btu/lbm\n",
      "#at this value h2, from Tablw A-6E\n",
      "T2=662;\n",
      "print'exit temperature %i F'%T2\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the inlet velocit 134.400000 f/s\n",
        "exit temperature 662 F\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-6 ,Page No.236"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "T1=280;#intial pressure in kPa\n",
      "P1=100;#intial temp in K\n",
      "m=0.02;#mass flow rate in kg/s\n",
      "qout=16;#heat losses in kJ/kg\n",
      "P2=600;#final pressure in kPa\n",
      "T2=400;#final temp in K\n",
      "\n",
      "#from Table A-17\n",
      "h1=280.13;\n",
      "h2=400.98;\n",
      "\n",
      "#calculations\n",
      "# Ein - Eout = dEsystem / dt\n",
      "Win=m*qout+m*(h2-h1);\n",
      "print'the input power of compressor %f kW'%round(Win,2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the input power of compressor 2.740000 kW\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-7 ,Page No.237"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "P1=2;#inlet pressure in MPa\n",
      "T1=400;#inlet temp in K\n",
      "V1=50.0;#inlet velocity in m/s\n",
      "z1=10;#inlet height in m\n",
      "P2=15;#final pressure in MPa\n",
      "x2=0.9;#final dryness fraction\n",
      "V2=180.0;#final velocity in m/s\n",
      "z2=6;#final height in m\n",
      "Wout=5*1000;#power output in kW\n",
      "\n",
      "#from Table A-6\n",
      "h1=3248.4;\n",
      "#similarly for P2\n",
      "hf=225.94;\n",
      "hfg=2372.3;\n",
      "\n",
      "#constants used \n",
      "g=9.8;#in m/s^2\n",
      "\n",
      "#calcualtions\n",
      "h2=hf+x2*hfg;\n",
      "print'difference in enthalpies %f kJ/kg'%round((h2-h1),2);\n",
      "print'difference in kinetic energy %f kJ/kg'%round((V2**2-V1**2)/2/1000,2);#factor of 1000 to convert to kJ/kg\n",
      "print'difference in potential energy %f kJ/kg'%round(g*(z2-z1)/1000,2);#factor of 1000 to convert to kJ/kg\n",
      "wout=-((h2-h1)+(V2**2-V1**2)/2/1000+g*(z2-z1)/1000);#factor of 1000 to convert to kJ/kg\n",
      "print'work done per unit of mass %f kJ/kg'%round(wout,2);\n",
      "m=Wout/wout;\n",
      "print'mass flow rate %f kg/s'%round(m,2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "difference in enthalpies -887.390000 kJ/kg\n",
        "difference in kinetic energy 14.950000 kJ/kg\n",
        "difference in potential energy -0.040000 kJ/kg\n",
        "work done per unit of mass 872.480000 kJ/kg\n",
        "mass flow rate 5.730000 kg/s\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-8 ,Page No.239"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "P1=0.8;#entering pressure in MPa\n",
      "P2=0.12;#throttled pressure in MPa\n",
      "\n",
      "#from Table A-12\n",
      "#sat. liq at P1\n",
      "T1=31.31;\n",
      "h1=95.47;\n",
      "#since process is insentropic and at  P2\n",
      "h2=h1;\n",
      "hf=22.49;\n",
      "hg=236.97;\n",
      "T2=-22.32;\n",
      "\n",
      "#calculations\n",
      "x2=(h2-hf)/(hg-hf);\n",
      "print'the final state is %f'%round(x2,3);\n",
      "dT=T2-T1;\n",
      "print'temperature drop %f C'%round(dT,2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the final state is 0.340000\n",
        "temperature drop -53.630000 C\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-9 ,Page No.241"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "T1=140;#inlet temp of hot water in F\n",
      "T2=50;#inlet temp of cold water in F\n",
      "T3=110;#steady state output temp in F\n",
      "P=20;#operating pressure in psia\n",
      "\n",
      "#for a compressed liq at given temp\n",
      "h1=107.99;\n",
      "h2=18.07;\n",
      "h3=78.02;\n",
      "\n",
      "#calculations\n",
      "#Mass balance min =  mout So, m1+m2 = m3\n",
      "#Energy balance Ein = Eout So, m1*h1 + m2*h2 = m3*h3\n",
      "#combining realations\n",
      "#m1*h1 + m2*h2 = (m1+m2)*h3\n",
      "#dividing by m2 and y=m1/m2\n",
      "#we get, yh1 + h2 = (y+1)*h3\n",
      "y=(h3-h2)/(h1-h3);\n",
      "print'the ratio of mass flow rates %f'%round(y,1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the ratio of mass flow rates 2.000000\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-10 ,Page No.242"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "T1=15;#water inlet temp in C\n",
      "P1=300;#water inlet pressure in kPa\n",
      "T2=25;#water outlet temp in C\n",
      "T3=70;#R-134a inlet temp in C\n",
      "P3=1000;#R-134a inlet pressure in kPa\n",
      "T4=35;#R-134a outlet temp in C\n",
      "mr=6;#mass flow rate in kg/min\n",
      "\n",
      "#from Table A-4, A-13 and A-11\n",
      "h1=62.982;\n",
      "h2=104.83;\n",
      "h3=303.85;\n",
      "h4=100.87;\n",
      "\n",
      "#calculations\n",
      "#mass balance m1=m2=mw and m3=m4=mr\n",
      "#energy balance m1*h1 + m3*h3 =  m2*h2 + m4*h4\n",
      "#combining them mw*(h1-h2) = mr*(h4-h3)\n",
      "mw= mr*(h4-h3)/(h1-h2);\n",
      "print'mass flow rate of cooling water %f kg/min'%round(mw,1);\n",
      "Qin=mw*(h2-h1);\n",
      "print'heat transfer rate %i kJ/min'%round(Qin)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "mass flow rate of cooling water 29.100000 kg/min\n",
        "heat transfer rate 1218 kJ/min\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-11 ,Page No.245"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "T1=17+273;#inlet temp in K\n",
      "P1=100;#inlet pressure in kPa\n",
      "V1=150;#inlet volumetric rate in m^3/min\n",
      "Win=15;#rated power in kW\n",
      "Qout=200/1000;#heat lost in kJ/s\n",
      "\n",
      "#constants used\n",
      "R=0.287;#in kPa-m^3/kg-K\n",
      "cp=1.005;#in kJ/kg C\n",
      "\n",
      "#calculations\n",
      "v1=R*T1/P1;\n",
      "m=V1/v1/60;#factor of 6 to convert to s\n",
      "# Win - Qout = m*cp*(T2-T1)\n",
      "T2= T1 + (Win - Qout)/(m*cp);\n",
      "print'exit temperature %f C'%round((T2-273),2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "exit temperature 21.970000 C\n"
       ]
      }
     ],
     "prompt_number": 33
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5-13 ,Page No.250"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given data\n",
      "V=6.0/1000;#volumne of cooker in m^3\n",
      "Pgage=75;#operating pressure in kPa\n",
      "Patm=100;#atmospheric pressure in kPa\n",
      "m1=1;#mass of water in kg\n",
      "Qind=0.5;#heat supplying rate in kJ/sec ; d stands for .\n",
      "t=30*60;#operating time in s\n",
      "\n",
      "#calculation\n",
      "Pabs=Pgage+Patm;\n",
      "#from Table A-5, ths saturation temp \n",
      "T=116.04;\n",
      "print'the temperature at which cooking takes place %f C'%T;\n",
      "#mass balance me=(m1-m2)cv\n",
      "#energy balance Qin - mehe = (m2u2 - m1u1)cv\n",
      "Qin=Qind*t;\n",
      "#from Table A-5\n",
      "he=2700.2;\n",
      "vf=0.001;\n",
      "vg=1.004;\n",
      "uf=486.82;\n",
      "ufg=2037.7;\n",
      "v1=V/m1;\n",
      "x1=(v1-vf)/(vg-vf);\n",
      "u1=uf+x1*ufg;\n",
      "U=m1*u1;\n",
      "#Qin = (m1 - V/v2)*he + (V/v2*u2 - m1*u1)\n",
      "#v2=vf + x2*(vg-vf)\n",
      "#u2=uf +  x2*ufg\n",
      "#combining these equations we get\n",
      "#solved using EES\n",
      "x2=0.009;\n",
      "v2=vf + x2*(vg-vf);\n",
      "m2=V/v2;\n",
      "print'amount of water left %f kg'%round(m2,1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the temperature at which cooking takes place 116.040000 C\n",
        "amount of water left 0.600000 kg\n"
       ]
      }
     ],
     "prompt_number": 4
    }
   ],
   "metadata": {}
  }
 ]
}