In [2]:

```
print "Principles of Heat Transfer, 7th Ed. Frank Kreith et. al Chapter - 2 Example # 2.1 "
#Heat generation rate in W/m3
qg = 1000000;
#Length along which heat will be dissipated in m (thickness)
L = 0.01;
#Thermal conductivity at the required temperature in W/mK
k = 64;
#Temperature of surrounding oil in degree C
Tinfinity = 80;
#Temperature of heater in degree C to be maintained
T1 = 200;
print "heat transfer coefficient in W/m2K from a heat balance"
#Heat transfer coefficient in W/m2K
h = ((qg*L)/2)/(T1-Tinfinity)
print round(h)
```

In [6]:

```
print "Principles of Heat Transfer, 7th Ed. Frank Kreith et. al Chapter - 2 Example # 2.2 "
print "Case of Uninsualted pipe"
#Calculating resistance to heat flow at internal surface
#Internal radius in m
ri = 0.05;
#Heat transfer coefficient at inner surface for steam condenmath.sing in W/m2K
hci = 10000;
#Resistance in mK/W
R1 = 1/(((2*math.pi)*ri)*hci);
#Calculating resistance to heat flow at external surface
#External radius in m
ro = 0.06;
#Heat transfer coefficient at outer surface in W/m2K
hco = 15;
#Resistance in mK/W
R3 = 1/(((2*math.pi)*ro)*hco);
#Calcualting resistance to heat flow due to pipe
#Thermal conductivity of pipe in W/mK
kpipe = 400;
#Resistance in mK/W
R2 = log(ro/ri)/((2*math.pi)*kpipe);
#Temperatures of steam(pipe) and surrounding(air) in degree C
Ts = 110;
Tinfinity = 30;
print "Heat loss from uninsulated pipe in W/m is therefore"
#Heat loss from uninsulated pipe in W/m
q = (Ts-Tinfinity)/(R1+R2+R3)
print round(q)
print "Case of insulated pipe"
#Calculating additional resistance between outer radius and new outer
#radius
#Thermal conductivity of insulation in W/mK
k = 0.2;
#New outer radius in m
r3 = 0.11;
#Resistance in mK/W
R4 = log(r3/ro)/((2*math.pi)*k);
#Calculating new outer resistance
R0 = 1/(((2*math.pi)*r3)*hco);
print "Heat loss from insulated pipe in W/m is therefore"
#Heat loss from insulated pipe in W/m
q = (Ts-Tinfinity)/(R1+R2+R4+R0)
print int(q)
```

In [10]:

```
print "Principles of Heat Transfer, 7th Ed. Frank Kreith et. al Chapter - 2 Example # 2.3 "
#Outer radius in m
ro = 0.02;
#Inner radius in m
ri = 0.015;
#Thermal conductivity of plastic in W/mK
k = 0.5;
#Internal convection heat transfer coefficient in W/m2K
hc1 = 300.0
#Temperature of fluid in pipe in degree C
Thot = 200.0
#Temperature of outside in degree C
Tcold = 30.0
#External convection heat transfer coefficient in W/m2K
hc0 = 10.0
print "Overall heat transfer coefficient in W/m2K is"
#Overall heat transfer coefficient in W/m2K
U0 = 1/(ro/(ri*hc1)+(ro*math.log(ro/ri))/k+1/hc0)
print round(U0,2)
print "The heat loss per unit length in W/m is"
#The heat loss per unit length in W/m
q = (((U0*2)*math.pi)*ro)*(Thot-Tcold)
print round(q)
```

In [13]:

```
print "Principles of Heat Transfer, 7th Ed. Frank Kreith et. al Chapter - 2 Example # 2.4 "
#Temperature of liquid nitrogen in degree K
Tnitrogen = 77;
#Radius of container in m
ri = 0.25;
#Temperature of surrounding air in degree K
Tinfinity = 300.0;
#Thermal conductivity of insulating silica powder in W/mK
k = 0.0017;
#Outer radius of container with insulation in m
ro = 0.275;
#Latent heat of vaporization of liquid nitrogen in J/kg
hgf = 200000.0;
#convection coefficient at outer surface in W/m2K
hco = 20.0;
#Calcaulting heat transfer to nitrogen
q = (Tinfinity-Tnitrogen)/(1/((((4*math.pi)*ro)*ro)*hco)+(ro-ri)/((((4*math.pi)*k)*ro)*ri));
print " rate of liquid boil-off of nitrogen per hour is"
#rate of liquid boil-off of nitrogen per hour
m = (3600*q)/hgf
print round(m,3)
```

In [16]:

```
print "Principles of Heat Transfer, 7th Ed. Frank Kreith et. al Chapter - 2 Example # 2.5 "
#Heat generation rate in W/m3
qg = 75000000;
#Outer radius of rods in m
ro = 0.025;
#Temperature of water in degree C
Twater = 120;
#Thermal cinductivity in W/mk
k = 29.5
#Heat transfer coefficient in W/m2K
hco = 55000;
#Since rate of flow through the surface of the rod equals the rate of internal heat generation
#and
#The rate of heat flow by conduction at the outer surface equals the rate
#of heat flow by convection from the surface to the water
#Surface Temperature in degree C
T0 = (qg*ro)/(2*hco)+Twater;
print "Maximum temperature in degree C"
#Maximum temperature in degree C
Tmax = T0+((qg*ro)*ro)/(4*k)
print round(Tmax)
```

In [19]:

```
print "Principles of Heat Transfer, 7th Ed. Frank Kreith et. al Chapter - 2 Example # 2.6 "
#diameter of fin in m
d = 0.0025;
#Perimeter in m
P = math.pi*d;
#Area in m2
A = ((math.pi*d)*d)/4;
#Surface temperature in degree C
Ts = 95;
#Ambient temperature in degree c
Tinfinity = 25;
#Heat transfer coefficient in W/m2K
hc = 10;
#From table 12, value of thermal conductivity in W/mK
k = 396;
print "Case of an infinitely long fin"
print "Heat loss for the â€œinfintely longâ€? fin in W is"
#Heat loss for the â€œinfintely longâ€? fin in W
qfin = ((((hc*P)*k)*A)**0.5)*(Ts-Tinfinity)
print round(qfin,3)
print "Case 2: Fin length of 2.5cm"
#Length in cm
L = 2.5/100;
#Parameter m
m = ((hc*P)/(k*A))**0.5;
print "Heat loss in this case in W is"
#Heat loss in this case in W
qfin = qfin*((math.sinh(m*L)+(hc/(m*k))*math.cosh(m*L))/(math.cosh(m*L)+(hc/(m*k))*math.sinh(m*L)))
print round(qfin,3)
print "For the two solutions to be within 5%"
#((math.sinh(m*L)+(hc/(m*k))*math.cosh(m*L))/(math.cosh(m*L)+(hc/(m*k))*math.sinh(m*L))) must
#be less than 0.95
print "L must be greater than 28.3cm"
```

In [21]:

```
print "Principles of Heat Transfer, 7th Ed. Frank Kreith et. al Chapter - 2 Example # 2.7 "
#Thermal conductivity of alumunium in W/mK
k = 200;
#Outer radius of system in m
ro = 5.5/200;
#Inner radius of system in m
ri = 2.5/200;
#Thickness of fin in m
t = 0.1/100;
#Temperature of pipe in degree C
Ts = 100;
#Temperature of surrounding in degree C
Tinfinity = 25;
#Heat transfer coefficient in W/m2K
h = 65;
#calculating fin efficiency
#From Fig. 2.22 on page 103, the fin efficiency is found to be 91%.
#Area of fin
A = (2*math.pi)*((ro+t/2)**2-ri*ri);
print "The rate of heat loss from a math.single fin in W is"
#The rate of heat loss from a math.single fin in W
q = ((0.91*h)*A)*(Ts-Tinfinity)
print round(q,1)
```

In [29]:

```
print "Principles of Heat Transfer, 7th Ed. Frank Kreith et. al Chapter - 2 Example # 2.8 "
#Diameter of pipe in m
D = 0.1;
#Depth under which it is sunk in m
z = 0.6;
#Temperature of pipe in degree C
Tpipe = 100.0;
#Temperature of soil in degree C
Tsoil = 20.0;
#Thermal conductivity in W/mK
k = 0.4;
#From table 2.2 on page 112, calculating shape factor
#Shape factor
S = (2*math.pi)/math.acosh((2*z)/D);
print " rate of heat loss per meter length in W/m is"
#rate of heat loss per meter length in W/m
q = (k*S)*(Tpipe-Tsoil)
print round(q,1)
# the other parts of question are theoritical hence not solved here
```

In [33]:

```
print "Principles of Heat Transfer, 7th Ed. Frank Kreith et. al Chapter - 2 Example # 2.9 "
#Thermal conductivity in W/mC
k = 1.04;
#For square length and breadth are equal and are in m
D = 0.5;
#Area in m2
A = D*D;
#Thickness in m
L = 0.1;
#Inside temperature in degree C
Ti = 500.0;
#Outside temperature in degree C
To = 50.0;
#Shape factor for walls
Sw = A/L;
#Shape factor for corners
Sc = 0.15*L;
#Shape factor for edges
Se = 0.54*D;
#There are 6 wall sections, 12 edges, and 8 corners, so that the total
#shape factor is
S = 6*Sw+12*Se+8*Sc;
print "Heat flow in kW is"
#Heat flow in W
q = (k*S)*(Ti-To)/1000
print round(q,2)
```

In [38]:

```
import matplotlib.pyplot as plt
%matplotlib inline
import numpy
print "Principles of Heat Transfer, 7th Ed. Frank Kreith et. al Chapter - 2 Example # 2.10 "
#Diameter of copper wire in m
D = 0.1/100;
#Initial temperature in degree C
To = 150.0;
#Final surrounding temperature in degree C of air and water
Tinfinity = 40.0;
#From table 12, appendix 2, we get the following data values for copper
#Thermal conductivity in W/mK
k = 391.0;
#Specific heat in J/kgK
c = 383.0;
#Density in kg/m3
rho = 8930.0;
#Surface area of wire per unit length in m
A = math.pi*D;
#Volume of wire per unit length in m2
V = ((math.pi*D)*D)/4;
#Heat transfer coefficient in the case of water in W/m2K
h = 80.0;
#Biot number in water
bi = (h*D)/(4*k);
#The temperature response is given by Eq. (2.84)
#For water Bi*Fo is 0.0936t
#For air Bi*Fo is 0.0117t
x=numpy.zeros((1,130))
Twater=numpy.zeros((1,130))
Tair=numpy.zeros((1,130))
for i in range (0,120):
#Position of grid
x[0,i] = i;
# Temperature of water in degree C
Twater[0,i] = Tinfinity+(To-Tinfinity)*math.exp(-0.0936*i);
# Temperature of air in degree C
Tair[0,i] = Tinfinity+(To-Tinfinity)*math.exp(-0.0117*i);
plt.grid('on')
ax = pylab.gca()
#Plotting curve
plt.plot(x[0,:120],Twater[0,:120],label="water")
#Plotting curve
plt.plot(x[0,:120],Tair[0,:120],label="air")
#Labelling axis
xlabel("time")
ylabel("temperature")
plt.legend(loc='upper right');
plt.show()
print "Temperature drop in water is more than that of air"
```

In [34]:

```
print "Principles of Heat Transfer, 7th Ed. Frank Kreith et. al Chapter - 2 Example # 2.11 "
#Initial temperature of soil in degree C
Ti = 20;
#Surface temperature of soil
Ts = -15;
#Critical temperature (Freezing temperature) in degree C
Tc = 0;
#Time in days
t = 60;
#Density of soil in kg/m3
rho = 2050.0;
#Thermal conductivity of soil in W/mK
k = 0.52;
#Specific heat in J/kgK
c = 1840.0;
#Diffusivity in m2/sec
alpha = k/(rho*c);
#Finding the value of following to proceed further
#Z value
z = (Tc-Ts)/(Ti-Ts);
#From table 43, it corresponds to an error function value of 0.4,
#proceeding
print "Minimum depth at which one must place a water main below the surface to avoid freezing in m is"
#Minimum depth at which one must place a water main below the surface to avoid freezing in m
xm = (0.4*2)*((((alpha*t)*24)*3600)**0.5)
print round(xm,2)
```

In [41]:

```
print "Principles of Heat Transfer, 7th Ed. Frank Kreith et. al Chapter - 2 Example # 2.12 "
#Length of steel component in m
L = 2;
#Radius of steel component in m
ro = 0.1;
#Thermal conductivity of steel in W/mK
k = 40;
#Thermal diffusivity in m2/s
alpha = 0.00001;
#Initital temperature in degree C
Ti = 400;
#Surrounding temperature in degree C
Tinfinity = 50;
#Heat transfer coefficient in W/m2K
h = 200;
#time of immersion in mins
t = 20;
#Since the cylinder has a length 10 times the diameter, we can neglect end
#effects.
#Calculating biot number
bi = (h*ro)/k;
if (bi>0.1):
#Calculating fourier number
fo = ((alpha*t)*60)/(ro*ro);
#The initial amount of internal energy stored in the cylinder per unit
#length in Ws/m
Q = ((((k*math.pi)*ro)*ro)*(Ti-Tinfinity))/alpha;
#The dimensionless centerline temperature for 1/Bi= 2.0 and Fo= 1.2 from
#Fig. 2.43(a)
#Centreline temperature in degree C
T = Tinfinity+0.35*(Ti-Tinfinity);
print "Centreline temperature in degree C is"
print T
#The surface temperature at r/r0= 1.0 and t= 1200 s is obtained from Fig. 2.43(b) in terms of the centerline temperature
#Surface temperature in degree C
Tr = Tinfinity+0.8*(T-Tinfinity);
print "Surface temperature in degree C is"
print Tr
#Then the amount of heat transferred from the steel rod to the water can be obtained from Fig. 2.43(c). Since Q(t)/Qi= 0.61,
print "The heat transferred to the water during the initial 20 min in kWh is"
#The heat transferred to the water during the initial 20 min in Wh
Q = ((0.61*L)*Q)/(3600*1000)
print round(Q,1)
```

In [44]:

```
print "Principles of Heat Transfer, 7th Ed. Frank Kreith et. al Chapter - 2 Example # 2.13 "
#Thickness of wall in m
L = 0.5;
#Initial temperature in degree C
Ti = 60;
#Combustion gas (Surrounding) temperature in degree C
Tinfinity = 900;
#Heat transfer coefficient in W/m2K
h = 25;
#Thermal conductivity in W/mk
k = 1.25;
#Specific heat in J/KgK
c = 837;
#Density in kg/m3
rho = 500;
#Thermal diffusivity in m2/s
alpha = 0.000003;
#Required temperature to achieve in degree C
Ts = 600;
#Calculating temperature ratio
z = (Ts-Tinfinity)/(Ti-Tinfinity);
#Reciprocal biot number
bi = k/(h*L);
#From Fig. 2.42(a) we find that for the above conditions the Fourier number= 0.70 at the midplane.
#Time in hours
t = ((0.7*L)*L)/alpha;
print "Time in hours is"
#Time in hours
t = t/3600.0
print round(t,1)
#The temperature distribution in the wall 16 h after the transient was
#initiated can be obtained from Fig. 2.42(b) for various values of x/L
print "Temperature distribution in degree C is"
print " (x/l) = 1.00 0.80 0.60 0.40 0.20"
print "Fraction = 0.13 0.41 0.64 0.83 0.96"
#The heat transferred to the wall per square meter of surface area during
#the transient can be obtained from Fig. 2.42(c).
print "Heat transfer in J/m2 is"
#Heat transfer in J/m2
Q = ((c*rho)*L)*(Ti-Tinfinity)
print "{:.3e}".format(Q)
```

In [48]:

```
print "Principles of Heat Transfer, 7th Ed. Frank Kreith et. al Chapter - 2 Example # 2.14 "
#Radius of cylinder in m
ro = 0.05;
#Length of cylinder in m
L = 0.16;
#Thermal conductivity in W/mK
k = 0.5;
#Thermal diffusivity in m2/s
alpha = 0.0000005;
#Initial temperature in degree C
Ti = 20.0;
#Surrounding temperature in degree C
Tinfinity = 500.0;
#Heat transfer coefficient in W/m2K
h = 30.0;
#Time in mins
t = 30.0;
#Biot number
bi = (h*ro)/k;
#Fourier number
fo = ((alpha*t)*60)/((L*L)/4);
#From fig. 2.42(a)
#Po
P0 = 0.9;
#From fig. 2.42(a) and (b)
#Pl
PL = 0.243;
#From fig. 2.43(a)
#Co
C0 = 0.47;
#From fig. 2.43(a) and (b)
#Cr
CR = 0.155;
print "Minimum temperature in degree C"
#Minimum temperature in degree C
Tmin = Tinfinity+((Ti-Tinfinity)*P0)*C0
print round(Tmin)
print "Maximum temperature in degree C"
#Maximum temperature in degree C
Tmax = Tinfinity+((Ti-Tinfinity)*PL)*CR
print round(Tmax)
```