summaryrefslogtreecommitdiff
path: root/Heat_Transfer_Principles_And_Applications_by_Dutta/ch4.ipynb
blob: 38ba457630b3247439a8cacc740a41900876959e (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
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 4 : Forced Convection"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.2 Page No : 112"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The rate of heat loss is 5328 W\n"
     ]
    }
   ],
   "source": [
    "# Variables\n",
    "l = 2.                      \t\t\t#m, length of flat surface\n",
    "T1 = 150.                   \t\t\t#C, surface temp.\n",
    "p = 1.                      \t\t\t#atm, pressure\n",
    "T2 = 30.                    \t\t\t#C, bulk air  temp.\n",
    "V = 12.                     \t\t\t#m/s, air velocity\n",
    "\n",
    "#Calculation\n",
    "Tf = (T1+T2)/2            \t\t\t#C, mean air film temp.\n",
    "mu = 2.131*10**-5            \t\t\t#m**2/s, vismath.cosity\n",
    "k = 0.031                   \t\t\t#W/m C, thermal conductivity\n",
    "rho = 0.962                 \t\t\t#kg/m**3, density of air\n",
    "cp = 1.01                   \t\t\t#kj/kg C, specific heat of air\n",
    "Pr = cp*10**3*mu/k                \t\t\t#Prandtl no.\n",
    "Remax = l*V*rho/mu          \t\t\t#maximum Reynold no.\n",
    "Re = 5.*10**5                 \t\t\t#Reynold no. during transition to turbulent flow   \n",
    "L_ = (Re*mu)/(V*rho)        \t\t\t#m,dismath.tance from the leading edge\n",
    "#for laminar flow heat transfer coefficient h, \n",
    "#h16.707*x**-(1/2)\n",
    "#(a)\n",
    "#h2 = 31.4*x**(-1/5)\n",
    "#b\n",
    "hav = 22.2\n",
    "#c\n",
    "Q = hav*l*p*(T1-T2)\n",
    "\n",
    "# Results\n",
    "print \"The rate of heat loss is %.0f W\"%(Q)\n",
    "\n",
    "# rounding off error."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.3 Page No : 114"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The steady state temprature is 230 C\n",
      "The recalculated value  is almost equal to previous one.\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "# Variables\n",
    "d = 7.24*10**-4                  \t\t\t#m, diameter of wire\n",
    "l = 1.                           \t\t\t#m, length of wire\n",
    "I = 8.3                         \t\t\t#A, current in a wire\n",
    "R = 2.625                       \t\t\t#ohm/m, electrical resistance\n",
    "V = 10.                          \t\t\t#m/s, air velocity\n",
    "Tb = 27.                         \t\t\t#C, bulk air temp.\n",
    "#the properties at bulk temp.\n",
    "mu = 1.983*10**-5                \t\t\t#m**2/s, vismath.cosity\n",
    "k = 0.02624                     \t\t\t#W/m C, thermal conductivity\n",
    "rho = 1.1774                    \t\t\t#kg/m**3, density of air\n",
    "cp = 1.0057                     \t\t\t#kj/kg C, specific heat of air\n",
    "\n",
    "# Calculations and Results\n",
    "Pr = cp*10**3*mu/k               \t\t\t#Prandtl no.\n",
    "Re = d*V*rho/mu                 \t\t\t# Reynold no.\n",
    "#from eq. 4.19, nusslet no.\n",
    "Nu = 0.3+(0.62*Re**(1./2)*Pr**(1./3)/(1+(0.4/Pr)**(2./3))**(1./4))*(1+(Re/(2.82*10**5))**(5./8))**(4./5)\n",
    "hav = Nu*k/d                    \t\t\t#W/m**2 C, average heat transfer coefficient\n",
    "Q = I**2*R                       \t\t\t#W, rate of electrical heat generation\n",
    "A = math.pi*d*l\n",
    "dt = Q/(hav*A)                  \t\t\t#C,temp. difference\n",
    "T = dt+Tb                       \t\t\t#C, steady state temp.\n",
    "print \"The steady state temprature is %.0f C\"%(T)\n",
    "\n",
    "Tm = (T+Tb)/2                   \t\t\t#C, mean air film temp.\n",
    "#the properties at Tm temp.\n",
    "mu1 = 2.30*10**-5                  \t\t\t#m**2/s, vismath.cosity\n",
    "k1 = 0.0338                       \t\t\t#W/m C, thermal conductivity\n",
    "rho1 = 0.878                      \t\t\t#kg/m**3, density of air\n",
    "cp1 = 1.014                       \t\t\t#kj/kg C, specific heat of air\n",
    "Re1 = d*V*rho1/mu1                \t\t\t# Reynold no.\n",
    "Pr1 = (1.014*10**3*2.30*10**-5)/k1             \t\t\t#Prandtl no.\n",
    "#from eq. 4.19, nusslet no.\n",
    "Nu1 = 0.3+(0.62*Re1**(1./2)*Pr1**(1./3)/(1+(0.4/Pr1)**(2./3))**(1./4))*(1+(Re1/(2.82*10**5))**(5./8))**(4./5)\n",
    "hav1 = Nu1*k1/d                    \t\t\t#W/m**2 C, average heat transfer coefficient\n",
    "dt1 = Q/(hav1*A)                  \t\t\t#C,temp. difference\n",
    "T1 = dt1+Tb                       \t\t\t#C, steady state temp.\n",
    "print \"The recalculated value  is almost equal to previous one.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.4 Page No : 116"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "initial  rate of melting of ice is 0.0109 g/s\n",
      "The required time is is 1665 s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Variables\n",
    "di = 0.04                       \t\t\t#m, diameter of ice ball\n",
    "V = 2.                           \t\t\t#m/s, air velocity\n",
    "T1 = 25.                         \t\t\t#C, steam temp.\n",
    "T2 = 0.\n",
    "#the properties  of air\n",
    "mu = 1.69*10**-5                 \t\t\t#kg/ms, vismath.cosity\n",
    "k = 0.026                       \t\t\t#W/m C, thermal conductivity\n",
    "rho = 1.248                     \t\t\t#kg/m**3, density \n",
    "cp = 1.005                      \t\t\t#kj/kg C, specific heat \n",
    "#propertice of ice\n",
    "lamda = 334.                     \t\t\t#kj/kg, heat of fusion\n",
    "rhoice = 920.                    \t\t\t#kg/m**3 density of ice\n",
    "\n",
    "# Calculations and Results\n",
    "Pr = cp*10**3*mu/k               \t\t\t#Prandtl no.\n",
    "Re = di*V*rho/mu                \t\t\t# Reynold no.\n",
    "#from eq. 4.19, nusslet no.\n",
    "Nu = 2+(0.4*Re**0.5+0.06*Re**(2./3))*Pr**0.4\n",
    "hav = Nu*k/di                          \t\t\t#W/m**2 C, average heat transfer coefficient\n",
    "Ai = math.pi*di**2                   \t\t\t#initial area of sphere\n",
    "Qi = Ai*hav*(T1-T2)                 \t\t\t#W = J/s, initial rate of heat transfer\n",
    "Ri = Qi/lamda                       \t\t\t#initial  rate of melting of ice\n",
    "print \"initial  rate of melting of ice is %.4f g/s\"%(Ri)\n",
    "\n",
    "#(b)\n",
    "#mass of ice ball 4/3*math.pi*r**3\n",
    "#Rate of melting =  Rm =  -d/dt(m)\n",
    "#Rate of heat input required  = -lamda*Rate of melting\n",
    "#heat balance equation\n",
    "# -lamda*(Rm) = h*4*math.pi*r**2*dt\n",
    "#integrating and solving\n",
    "rf = ((di/2)**3/2.)**(1./3)\n",
    "#solving eq. 3\n",
    "t1 = 1.355*10**-4/(8.136*10**-8)\n",
    "print \"The required time is is %.0f s\"%(t1)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.5 Page No : 121"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the required contact time is 1.43 s\n"
     ]
    }
   ],
   "source": [
    "from scipy.integrate import quad \n",
    "# Variables\n",
    "Vo = 0.5                        \t\t\t#m/s air velocity\n",
    "T1 = 800.                        \t\t\t#C, initial temp.\n",
    "T2 = 550.                        \t\t\t#C, final temp.\n",
    "Tam = 500.                       \t\t\t#C, air mean temp.\n",
    "P = 1.2                         \t\t\t#atm, pressure\n",
    "#the properties of solid particles.\n",
    "dp = 0.65*10**-3                 \t\t\t#m, average particle diameter\n",
    "cps = 0.196                     \t\t\t#kcal/kg C, specific heat\n",
    "rhos = 2550.                     \t\t\t#kg/m**3, density \n",
    "#Properties of air\n",
    "mu = 3.6*10**-5                  \t\t\t#kg/ms, vismath.cosity\n",
    "k = 0.05                        \t\t\t#kcal/hm C, thermal conductivity\n",
    "rho = 0.545                     \t\t\t#kg/m**3, density of air\n",
    "cp = 0.263                      \t\t\t#kcal/kg C, specific heat of air\n",
    "\n",
    "#calculation\n",
    "Pr = cp*mu*3600/k                    \t\t\t#Prandtl no.\n",
    "Redp = dp*Vo*rho/mu             \t\t\t# Reynold no.\n",
    "#from eq. 4.29(b) heat transfer coefficient\n",
    "h = (k/dp)*(2+0.6*(Redp)**(1./2)*(Pr)**(1./3))\n",
    "Tg = 500                        \t\t\t#C, gas temp.\n",
    "#from heat balance equation\n",
    "# -(dTs/dt) = 6h/(dp*rhos*cps)*(Ts-Tg)\n",
    "\n",
    "def f2(Ts): \n",
    "    return (1/(Ts-Tg))\n",
    "\n",
    "t = (dp*rhos*cps/(6*h))* quad(f2,550,800)[0]\n",
    "\n",
    "# Results\n",
    "print \"the required contact time is %.2f s\"%(t*3600)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.6 Page No : 126"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the required rate of flow of water is 1053 kg/h \n",
      "the overall heat transfer coefficient is 300 W/m**2 C\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "# Variables\n",
    "mo_ = 1000.           \t\t\t#kg/h, cooling rate of oil\n",
    "cpo = 2.05           \t\t\t#kj/kg C, specific heat of oil\n",
    "T1 = 70.              \t\t\t#C, initial temp. of oil\n",
    "T2 = 40.              \t\t\t#C,  temp. of oil after cooling\n",
    "cpw = 4.17           \t\t\t#kj/kg C, specific heat of water\n",
    "T3 = 42.              \t\t\t#C, initial temp. of water\n",
    "T4 = 28.              \t\t\t#C,  temp. of oil after cooling\n",
    "A = 3.                \t\t\t#m**2, heat exchange area\n",
    "\n",
    "# Calculation and Results\n",
    "mw_ = mo_*cpo*(T1-T2)/(cpw*(T3-T4))\n",
    "print \"the required rate of flow of water is %.0f kg/h \"%(mw_)\n",
    "Q = mo_*cpo*(T1-T2)/3600       \t\t\t#kw, heat duty\n",
    "dt1 = T1-T3                  \t\t\t#C, hot end temp. difference\n",
    "dt2 = T2-T4                  \t\t\t#C, cold end temp. difference\n",
    "LMTD = (dt1-dt2)/(math.log(dt1/dt2))  \t\t\t#math.log mean temp. difference\n",
    "dtm = LMTD\n",
    "U = Q*10**3/(A*dtm)\n",
    "print \"the overall heat transfer coefficient is %.0f W/m**2 C\"%(round(U,-1))\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.7 Page No : 126"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The inlet temprature is  Ti = 26 C\n",
      "The outlet temprature is To = 107 C\n"
     ]
    }
   ],
   "source": [
    "from scipy.optimize import fsolve \n",
    "import math\n",
    "\n",
    "# Variables\n",
    "Q = 38700.             \t\t\t#kcal/h, heat duty\n",
    "W = 2000.              \t\t\t#kg/h gas flow rate\n",
    "cp = 0.239            \t\t\t#kcal/kg C, specific heat of nitrogen\n",
    "A = 10.                \t\t\t#m**2 ,heat exchanger area\n",
    "U = 70.                \t\t\t#kcal/hm**2 C, overall heat transfer coefficient\n",
    "n = 0.63              \t\t\t#fin efficiency\n",
    "\n",
    "#Calculation\n",
    "dt = Q/(W*cp)         \t\t\t#C, temp. difference\n",
    "#To-Ti = dt.........................(i)\n",
    "dtm = Q/(U*A*n)\n",
    "#(To-Ti)/(math.log((160-Ti)/(160-To))) = 87.8........(2)\n",
    "#solving  1  and 2\n",
    "def f(To): \n",
    "    return (To-(To-dt))/(math.log((160-(To-dt))/(160-To)))-87.8\n",
    "\n",
    "To = fsolve(f,100)\n",
    "Ti = To-dt\n",
    "\n",
    "# Results\n",
    "print \"The inlet temprature is  Ti = %.0f C\"%(Ti)\n",
    "print \"The outlet temprature is To = %.0f C\"%(To)\n",
    "\n",
    "# note : answers are slightly different because of fsolve function of python."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.8 Page No : 127"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The outlet eater temp. is 109.8 C\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "# Variables\n",
    "V = 1.8                  \t\t\t#m/s, velocity of hot water\n",
    "T1 = 110.                 \t\t\t#C, initial temp.\n",
    "l = 15.                   \t\t\t#m, length  of pipe\n",
    "t = 0.02                 \t\t\t#m, thickness of insulation\n",
    "kc = 0.12                \t\t\t#W/mC,thermal conductivity of insulating layer\n",
    "ho = 10.                  \t\t\t#Wm**2 C, outside film coefficient\n",
    "T2 = 20.                  \t\t\t#C, ambient temp.\n",
    "#the properties of water at 110 C\n",
    "mu = 2.55*10**-4          \t\t\t#m**2/s, vismath.cosity\n",
    "k = 0.685                \t\t\t#W/m C, thermal conductivity\n",
    "rho = 950.                \t\t\t#kg/m**3, density of air\n",
    "cp = 4.23                \t\t\t#kj/kg C, specific heat of air\n",
    "di = 0.035               \t\t\t#m, actual internal dia. of pipe\n",
    "ri = di/2.                \t\t\t#m,internal radius\n",
    "t1 = 0.0036              \t\t\t#m, actual thickness of 1-1/4 schedule 40 pipe\n",
    "ro = ri+t1               \t\t\t#m, outer radius of pipe\n",
    "r_ = ro+t                \t\t\t#m, outer radius of insulation\n",
    "kw = 43.                  \t\t\t#W/mC, thermal conductivity of steel\n",
    "\n",
    "#calculation\n",
    "Pr = cp*10**3*mu/k        \t\t\t#Prandtl no.\n",
    "Re = di*V*rho/mu         \t\t\t# Reynold no.\n",
    "#from eq. 4.9,  Nusslet no.\n",
    "Nu = 0.023*(Re)**0.88*Pr**0.3\n",
    "hi = Nu*k/di             \t\t\t#W/m**2 C, average heat transfer coefficient\n",
    "#the overall coefficient inside area basis Ui\n",
    "Ui = 1./(1/hi+(ri*math.log(ro/ri))/kw+(ri*math.log(r_/ro))/kc+ri/(r_*ho)) \n",
    "Ai = math.pi*di*l           \t\t\t#m**2, inside area basis\n",
    "W = math.pi*ri**2*V*rho      \t\t\t#kg/s, water flow rate\n",
    "#from the relation b/w LMTD and rate of heat loss\n",
    "\n",
    "def f(To): \n",
    "    return (W*cp*10**3)/(Ui*Ai)*(T1-To)-((T1-To)/math.log((T1-T2)/(To-T2)))\n",
    "To = fsolve(f,100)\n",
    "\n",
    "# Results\n",
    "print \"The outlet eater temp. is %.1f C\"%(To)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.9 Page No : 129"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The exit water temp is 36 C\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "# Variables\n",
    "T1 = 28.              \t\t\t#C, inlet temp. \n",
    "T2 = 250.             \t\t\t#C,bulk temp.\n",
    "V = 10.               \t\t\t#m/s, gas velocity\n",
    "l = 20.               \t\t\t#m, length of pipe\n",
    "mw = 1.*3600          \t\t\t#kg/h, water flow rate\n",
    "di = 4.1*10**-2       \t\t\t#m, inlet diameter\n",
    "Tm = (T1+T2)/2       \t\t\t#C, mean temp.\n",
    "ro = 0.0484          \t\t\t#m, outside radius\n",
    "#properties of water\n",
    "mu = 8.6*10**-4       \t\t\t#kg/ms, vismath.cosity\n",
    "kw = 0.528           \t\t\t#kcal/h m C, thermal conductivity\n",
    "kw_ = 0.528*1.162    \t\t\t#W/ m C, thermal conductivity\n",
    "rho = 996.            \t\t\t#kg/m**3, density of air\n",
    "cp = 1*4.18          \t\t\t#kj/kg C, specific heat of air\n",
    "cp_ = 1.              \t\t\t#kcal/kg C\n",
    "#properties of flue gas\n",
    "mu1 = 2.33*10**-5     \t\t\t#kg/ms, vismath.cosity\n",
    "ka = 0.0292          \t\t\t#kcal/h m C, thermal conductivity\n",
    "rho1 = 0.891         \t\t\t#kg/m**3, density of air\n",
    "cp1 = 0.243          \t\t\t#kcal/kg C, specific heat of air\n",
    "Pr = 0.69\n",
    "\n",
    "#calculation\n",
    "A = math.pi/4*di**2       \t\t\t#m**2, cross section of pipe\n",
    "Vw = 1/(rho*A)       \t\t\t#m/s, velocity of warer\n",
    "Re = di*Vw*rho/mu    \t\t\t# Reynold no.\n",
    "Pr1 = cp*10**3*mu/kw_   \t\t\t#Prandtl no. for water\n",
    "Nu = 0.023*Re**0.8*Pr1**0.4               \t\t\t#Nusslet no.\n",
    "#water side heat transfer coefficient  hi\n",
    "hi = 206*kw/di\n",
    "#gas side heat transfer coefficient    ho\n",
    "a = 41              \t\t\t#mm, i.d. schedule\n",
    "Tw = 3.7            \t\t\t#mm, wall thickness\n",
    "do = a+2*Tw         \t\t\t#mm, outer diameter of pipe\n",
    "Re1 = do*10**-3*V*rho1/mu1    \t\t\t# Reynold no\n",
    "#from eq. 4.19, nusslet no.\n",
    "Nu1 = 0.3+(0.62*Re1**(1./2)*Pr**(1./3)/(1+(0.4/Pr)**(2./3))**(1/4.))*(1+(Re1/(2.82*10**5))**(5./8))**(4/5.)\n",
    "ho = (Nu1*ka/do)*10**3      \t\t\t#kcal/h m**2 C\n",
    "Uo = 1/(ro/(di/2*hi)+1/ho)   \t\t\t#kcal/h m**2 C, overall heat transfer coefficient\n",
    "\n",
    "#Heat balance\n",
    "A1 = math.pi*ro*l         \t\t\t#m62, outside area of pipe\n",
    "#from the formula of LMTD\n",
    "def f(T2_): \n",
    "    return mw*cp_*(T2_-T1)-Uo*A1*((T2_-T1)/math.log((T2-T1)/(T2-T2_)))\n",
    "T2_ = fsolve(f,1)\n",
    "\n",
    "# Results\n",
    "print \"The exit water temp is %.0f C\"%(T2_)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.10 Page No : 131"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The tube length is 123 m\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Variables\n",
    "dti = 0.0212        \t\t\t#m inner tube\n",
    "dto = 0.0254        \t\t\t#cm, outer tube\n",
    "dpi = 0.035         \t\t\t#cm, outer pipe\n",
    "mo_ = 500.           \t\t\t#kh/h, cooling rate of oil\n",
    "To2 = 110.           \t\t\t#C, initial temo. of oil\n",
    "To1 = 70.            \t\t\t#C, temp. after cooling of oil\n",
    "Tw2 = 40.            \t\t\t#C, inlet temp. of water\n",
    "Tw1 = 29.            \t\t\t#C, outlet temp. of water\n",
    "#properties of oil\n",
    "cpo = 0.478         \t\t\t#kcal/kg C\n",
    "ko = 0.12           \t\t\t#kcal/h m C, thermal conductivity\n",
    "rho = 850.           \t\t\t#kg/m**3, density of oil\n",
    "#properties of water\n",
    "kw = 0.542          \t\t\t#kcal/h m C, thermal conductivity\n",
    "kw_ = (kw*1.162)    \t\t\t#kj/kg C\n",
    "muw = 7.1*10**-4     \t\t\t#kg/ms, vismath.cosity of water\n",
    "cpw = 1.             \t\t\t#kcal/kg C\n",
    "cpw_ = cpw*4.17     \t\t\t#kcal/kg C\n",
    "rhow = 1000.         \t\t\t#kg/m**3, density\n",
    "\n",
    "#calculation\n",
    "HL = mo_*cpo*(To2-To1)      \t\t\t#kcal/h, heat load of exchanger\n",
    "mw_ = HL/(cpw*(Tw2-Tw1))    \t\t\t#kg/h water flow rate\n",
    "mw_1 = mw_/(3600*10**3)      \t\t\t#m**3/s water flow rate\n",
    "A1 = (math.pi/4)*(dti)**2        \t\t\t#m**2, flow area of tube\n",
    "Vw = mw_1/A1                \t\t\t#m/s water velocity\n",
    "Rew = dti*Vw*rhow/muw       \t\t\t#Reynold no.\n",
    "Prw = cpw_*10**3*muw/kw_      \t\t\t#Prandtl no.\n",
    "Nuw = 0.023*Rew**0.8*Prw**0.4 \t\t\t#nusslet no.\n",
    "#water side heat transfer coefficient   hi\n",
    "hi = Nuw*kw/dti\n",
    "\n",
    "#oil side heat transfer coefficient\n",
    "A2 = math.pi/4*(dpi**2-dto**2)    \t\t\t#m**2, flow area of annulus\n",
    "Vo = mo_/(3600*rho*A2)      \t\t\t#m/s velocity of oil\n",
    "de = (dpi**2-dto**2)/dto      \t\t\t#m, equivalent dia of annulus\n",
    "Tmo = (To2+To1)/2           \t\t\t#C,mean oil temp.\n",
    "muoil = math.exp((5550./(Tmo+273))-19)  \t\t\t#kg/ms, vismath.cosity of oil\n",
    "Reo = de*Vo*rho/muoil\n",
    "Pro = cpo*muoil*3600/ko     \t\t\t#prandtl no. for oil    \n",
    "\n",
    "#assume (1st approximation)\n",
    "Nuo = 3.66\n",
    "ho = Nuo*ko/de             \t\t\t#kcal/h m**2 c\n",
    "L = 1                      \t\t\t#assume length of tube\n",
    "Ai = math.pi*dti*L\n",
    "Ao = math.pi*dto*L\n",
    "#overall heat transfer coefficient 1st approximation\n",
    "Uo = 1/(1/ho+Ao/(Ai*hi))\n",
    "LMTD = ((To2-Tw2)-(To1-Tw1))/(math.log((To2-Tw2)/(To1-Tw1)))\n",
    "Ao1 = HL/(Uo*LMTD)         \t\t\t                #m**2, heat transfer area\n",
    "Lt = Ao1/(math.pi*dto)          \t\t\t        #m, tube length\n",
    "#from eq.  4.8\n",
    "Nuo1 = 1.86*(Reo*Pro/(Lt/de))**(1./3)   \t\t\t#Nusslet no. \n",
    "ho1 = Nuo1*ko/de\n",
    "Tmw = (Tw1+Tw2)/2         \t\t\t#C, mean water temp.\n",
    "#balancing heat transfer rate of oil and water\n",
    "\n",
    "#average wall temp. Twall\n",
    "Twall = ((hi*dti*(-Tmw))-(ho1*dto*Tmo))/(-65.71216)\n",
    "#vismath.cosity of oil at this temp.\n",
    "muwall = math.exp((5550/(Twall+273))-19)  \t\t\t#kg/ms, vismath.cosity of oil\n",
    "#Nusslet no. \n",
    "Nuo2 = 1.86*(Reo*Pro/(Lt/de))**(1./3)*(muoil/muwall)**0.14\n",
    "ho2 = Nuo2*ko/de\n",
    "Uo2 = 1/((1/ho2)+(Ao/(Ai*hi)))\n",
    "Ao2 = HL/(Uo2*LMTD)\n",
    "Lt_ = Ao2/(math.pi*dto)\n",
    "\n",
    "# Results\n",
    "print \"The tube length is %d m\"%(Lt_)\n",
    "\n",
    "# rounding off error."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.11 Page No : 135"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " the rate of heat transfer to water.is 6.93e+05 kcal/h\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "# Variables\n",
    "Ti = 260.                 \t\t\t#C, initial  temp.\n",
    "Ts = 70.                  \t\t\t#C, skin temp.\n",
    "St = 0.15                \t\t\t#m,space between tubes in equilateral triangular arrangement\n",
    "Sd = St                  \t\t\t#space between tubes\n",
    "mu = 4.43*10**-5                \t\t\t#m**2/s, momentum diffusity\n",
    "k = 0.0375                     \t\t\t#W/m C, thermal conductivity\n",
    "rho = 0.73                     \t\t\t#kg/m**3, density of air\n",
    "cp = 0.248                     \t\t\t#kj/kg C, specific heat of air\n",
    "V = 16.                         \t\t\t#m/s, velociity \n",
    "d = 0.06                       \t\t\t#m, outside diameter of tube\n",
    "Nt = 15.                        \t\t\t#no. of tubes in transverse row\n",
    "Nl = 14.                        \t\t\t#no. of tubes in longitudinal row\n",
    "N = Nl*Nt                      \t\t\t#total no. of tubes\n",
    "L = 1.                          \t\t\t#m, length\n",
    "#Calculation\n",
    "Sl = (math.sqrt(3)/2)*St\n",
    "Pr = cp*mu*3600*rho/k          \t\t\t#Prandtl no. of bulk air\n",
    "Pr = 0.62\n",
    "Prw = 0.70                     \t\t\t#Prandtl no. of air at wall temp. 70 C\n",
    "#from eq. 4.25\n",
    "Vmax = (St/(St-d))*V\n",
    "#from eq. 4.26\n",
    "Vmax1 = (St/(2*(St-d)))*V\n",
    "Redmax = d*Vmax/mu\n",
    "p = St/Sl                     \t\t\t#pitch ratio\n",
    "#from table 4.3\n",
    "m = 0.6\n",
    "C = 0.35*(St/Sl)**0.2\n",
    "h = round((k/d)*C*(36163)**m*(Pr)**(0.36)*(Pr/Prw)**(0.25))\n",
    "#from eq. 4.28\n",
    "dt = round(190*math.exp(-math.pi*d*N*h/(rho*V*3600*Nt*St*cp)))\n",
    "LMTD = ((Ti-Ts)-(dt))/math.log((Ti-Ts)/dt)\n",
    "A = round(math.pi*d*L*N,1)                \t\t\t#m**2, heat transfer area\n",
    "Q = h*A*LMTD\n",
    "\n",
    "# Results\n",
    "print \" the rate of heat transfer to water.is %.2e kcal/h\"%(Q)\n",
    "\n",
    "# Note : Value of LMTD is wrong in book please check."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.12 Page No : 140"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Outlet temp. of water for one pass through the tubes is 51 C\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "# Variables\n",
    "W = 0.057                      \t\t\t#m**3/min/tube, flow rate of water\n",
    "W_ = W*16.66                   \t\t\t#kg/s. water flow rate\n",
    "di = 0.0212                    \t\t\t#m,inside diameter\n",
    "Ti = 32.                        \t\t\t#C, inlet water temp.\n",
    "Tw = 80.                        \t\t\t#C, wall temp.\n",
    "L = 3.                          \t\t\t#m, length of pip\n",
    "\n",
    "#Calculation\n",
    "V = (W/60)*(1/((math.pi/4)*di**2))   \t\t\t#m/s, water velocity\n",
    "#the properties of water at mean liquid temp..\n",
    "mu = 7.65*10**-4                 \t\t\t#m**2/s, vismath.cosity\n",
    "k = 0.623                       \t\t\t#W/m C, thermal conductivity\n",
    "rho = 995.                       \t\t\t#kg/m**3, density of air\n",
    "cp = 4.17                       \t\t\t#kj/kg C, specific heat of air\n",
    "\n",
    "Pr = cp*10**3*mu/k               \t\t\t#Prandtl no.\n",
    "Re = di*V*rho/mu                \t\t\t# Reynold no.\n",
    "#from eq. 4.19, nusslet no.\n",
    "#from dittus boelter eq.\n",
    "Nu = 0.023*Re**0.8*Pr**0.4        \t\t\t#Prandtl no.\n",
    "f = 0.0014+0.125*Re**-0.32       \t\t\t#friction factor\n",
    "#Reynold anamath.logy\n",
    "St = f/2                       \t\t\t#Smath.tanton no.\n",
    "Nu1 = Re*Pr*St\n",
    "#Prandtl anamath.logy\n",
    "St1 = (f/2)/(1+5*(Pr-1)*math.sqrt(f/2))\n",
    "Nu2 = St1*Re*Pr               \n",
    "#colburn analogy\n",
    "Nu3 = Re*Pr**(1./3)*(f/2)\n",
    "h = Nu3*k/(di)               \t\t\t#W/m**2 C av heat transfer coefficient\n",
    "#Q = W_*cp*10**3*(To-Ti) = h*A*LMTD\n",
    "A = math.pi*di*L       \t\t\t#m**2\n",
    "def f(To): \n",
    "    return W_*cp*10**3*(To-Ti)-h*A*((To-Ti)/math.log((Tw-Ti)/(Tw-To)))\n",
    "To = fsolve(f,1)\n",
    "#Revised calculation\n",
    "Tm = (Ti+To)/2               \t\t\t#C, mean liquid temp.\n",
    "#the properties of water at new mean liquid temp..\n",
    "mu1 = 6.2*10**-4                 \t\t\t#m**2/s, vismath.cosity\n",
    "k1 = 0.623                       \t\t\t#W/m C, thermal conductivity\n",
    "rho1 = 991.                       \t\t\t#kg/m**3, density of air\n",
    "cp1 = 4.17                       \t\t\t#kj/kg C, specific heat of air\n",
    "\n",
    "Pr1 = cp1*10**3*mu1/k1               \t\t\t#Prandtl no.\n",
    "Re1 = di*V*rho1/mu1                \t\t\t# Reynold no.\n",
    "#from dittus boelter eq.\n",
    "f1 = 0.0014+0.125*Re1**(-0.32)       \t\t\t#friction factor\n",
    "#colburn anamath.logy\n",
    "Nu4 = Re1*Pr1**(1./3)*(f1/2)\n",
    "h1 = Nu4*k1/(di)               \t\t\t#W/m**2 C av heat transfer coefficient\n",
    "def f(To_): \n",
    "    return W_*cp*10**3*(To_-Ti)-h1*A*((To_-Ti)/math.log((Tw-Ti)/(Tw-To_)))\n",
    "To_ = fsolve(f,1)\n",
    "\n",
    "print \"Outlet temp. of water for one pass through the tubes is %.0f C\"%(To_)\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}