In [1]:

```
import math
from __future__ import division
#Variable declaration
di=0.02; #inner radius m
do=0.04; #inner radius m
ri=di/2; #inner radius m
ro=do/2; #inner radius m
k=0.58; #thermal conductivity of tube material w/m K
ti=70; #degree C
to=100; #degree C
l=1; #per unit length m
#calculations
q=l*2*(3.14)*k*(ti-to)/math.log(ro/ri);
#result
print"Heat flow per unit length is",round(q,4),"W/m";
```

In [2]:

```
import math
from __future__ import division
#Variable declaration
di=0.02; #inner radius
do=0.04; #outer radius
ri=di/2; #inner radius
ro=do/2; #outer radius
k=0.58; #thermal conductivity of tube material
ti=70; #degree C
to=100; #degree C
l=1; #per unit length
h=5000; #W/m^2 K
#calculations
Rthtube=(math.log(ro/ri))/(2*3.14*k*l); #thermal resistance of tube per unit length
Rthcond=1/(3.14*do*l*h); #thermal resistance of condensing steam per unit length
q=l*2*(3.14)*k*(ti-100)/math.log(ro/ri); #heat flow rate per unit meter
#result
print"Thermal resistance of tube per unit length is",round(Rthtube,4),"K/W";
print"Thermal resistance of condensing steam perunit length is",round(Rthcond,5),"K/W";
print"Heat flow per unit length is",round(q,4),"K/W";
```

In [3]:

```
import math
from __future__ import division
#Variable declaration
hw=140; #heat transfer coefficient on water side
ho=150; #heat transfer coefficient on oil side
k=30; #thermal conductivity
ro=0.1; #inner diameter of GI pipe on inside
ri=0.008; #outer diameter of GI pipe on inside
l=1; #per unit length
#calculations
RinnerGI=math.log((ro/ri))/(2*3.14*k*l); #Thermal resistance of inner GI pipe
Roilside=1/(ho*3.14*2*ri*l); #Thermal resistanceon the oil side per unit length
Rwaterside=1/(hw*3.14*2*ro*l); #Thermal resistanceon the water side per unit length
#result
print"Thermal resistance of inner GI pipe =",round(RinnerGI,5),"K/W";
print"Thermal resistance on the oil side perunit length =",round(Roilside,5),"K/W";
print"Thermal resistance on cold water side per unit length =",round(Rwaterside,5),"K/W";
print"So,Engineer in-charge has made a bad decision";
```

In [4]:

```
import math
from __future__ import division
#Variable declaration
ti=300; #Internal temp of hot gas in degree Celsius
od=0.1; #Outer diameter of long metal pipe in meters
i_d=0.04; #Internal diamtere of long metal pipe in meters
ki=0.052; #thermal conductivity of mineral wood in W/mK
to=50; #Outer surface temperature in degree celsius
hi=29; #heat transfer coefficient in the inner side in W/m^2 K
ho=12; #heat transfer coefficient in the outer pipe W/m^2 K
t=25; # Surrounding temperature in degree celsius
#Calculation
#Determination of thickness of insulation
#By solving the following two equations by trial and error method for r3
#q_L=2*3.14*0.047*(t1-t)/(1/hi+(0.047/ki)*2.303*math.log(r3/od/2)+(0.047/h0*r3));
#q_L=2*3.14*h0*(to-t);
#By trial and error we get
r3=0.082; #in m
t=r3-(od/2);
#Heat loss per unit length
q=600*(22/7)*r3;
#Result
print"Thickness of insulation =",t*100,"cm";
print"Heat loss per unit length =",round(q,1),"W/m";
```

In [5]:

```
import math
from __future__ import division
import matplotlib.pyplot as plt
import numpy as np
#Variable declaration
ti=90; #Temp on inner side in degree celsius
to=30; #Temp on outer side in degree celsius
hi=500; #heat transfer coeffcient in W/m^2 K
ho=10; #heat transfer coeffcient in W/m^2 K
i_d=0.016; #Internal diameter in meters
od=0.02; #Outer diameter in meters
from pylab import linspace
%matplotlib inline
#Calculation
r3=np.linspace (0.01,0.06,12);
t=[0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5]
q_L=(2*(3.14)*(i_d/2)*(ti-to))/((1/hi)+(0.008/0.2)*np.log(r3/0.01) + (0.008/r3*(1/ho)));
#Result
print "Insulaion thickness (cm)", " r3 (m)"," Heat loss rate per meter (W/m) "
print " ",t[0]," ",0.01," ",round(q_L[0],1),"(roundoff error)"
print " ",t[1]," ",0.015," ", round(q_L[1],1),"(roundoff error)"
print " ",t[2]," ",0.02," ",round(q_L[2],1),"(roundoff error)"
print " ",t[4]," ",0.03," ",round(q_L[4],1),"(roundoff error)"
print " ",t[6]," ",0.04," ",round(q_L[6],1),"(roundoff error)"
print " ",t[8]," ",0.05," ",round(q_L[8],1),"(roundoff error)"
print " ",t[10]," ",0.06," ",round(q_L[10],1),"(roundoff error)"
plt.plot (t,q_L);
plt.title ("Variation of heat loss rate with insulation thickness");
plt.xlabel(" Insulation thickness in cm");
plt.ylabel(" Heat Loss in W/m ");
plt.show();
```

In [6]:

```
import math
from __future__ import division
#Variable declaration
hnatural = 10; #heat transfer coefficient for natural
hforced = 50; #heat transfer coefficient for forced
k1 = 0.2; #thermal conductivity
k2 = 0.05; #thermal conductivity
#result
print"critical radius of insulation in cm";
print"\n h=10 h=50";
print"\nAsbestos ",k1 *100/ hnatural," ", k1*100/ hforced;
print"\nMineral wool ",k2 *100/ hnatural," ", k2*100/ hforced;
```

In [7]:

```
import math
from __future__ import division
#Variable declaration
h=5; #Height
l=10; #Length
t=1; #thickness
k=1.05; #W/m K
q=58; #W/m^3
t1=35; #c
h=11.6; #Heat transfer coefficient
#calculations
b=t/2;
tmax=t1+q*b*(b/(2*k)+1/h);
#result
print"Maximum Temperature =",round(tmax,3),"degree c";
```

In [8]:

```
import math
from __future__ import division
#Variable declaration
#The bar will have two dimensional variation in temperature
#the differential equation is subject to boundary conditions
x1 = 0; #cm
Tx1 = 30; #C
x2 = 5; #cm
Tx2 = 30; #C
y1 = 0; #cm
Ty1 = 30; #C
y2 = 10; #cm
Ty2 = 130; #C
#substituting theta = T-30 and using eqn 2.6.11
#putting x = 2.5cm and y = 5cm in infinite summation series
n = 1;
x1 = (1- math.cos ( 3.14*3.14/180 *n))/( math.sinh (2*3.14* 3.14/180 *n))*math.sin(n**(3.14*3.14/180 /2))*math.sinh (n*3.14*3.14/180);
n = 3;
x2 = (1- math.cos ( 3.14*3.14/180 *n))/( math.sinh (2*3.14* 3.14/180 *n))*math.sin(n**(3.14*3.14/180 /2))*math.sinh (n*3.14*3.14/180);
n = 5;
x3 = (1- math.cos ( 3.14*3.14/180 *n))/( math.sinh (2*3.14* 3.14/180 *n))*math.sin(n**(3.14*3.14/180 /2))*math.sinh (n*3.14*3.14/180);
x = x1+x3+x3;
T = x *100+30;
#result
print "Steady statetemper a ture= ",T,"c (roundoff error)";
```

In [9]:

```
import math
from __future__ import division
#Variable declaration
k = 330; #thermal conductivity
a = 95*10**(-6); #thermal expansion coefficient
R = 0.01; #radius in meters
To = 77; #temperature in kelvins
Tf = 273+50; #temperature in kelvins
theta1 = To - Tf;
T = 273+10; ##temperature in kelvins
theta = T - Tf;
h = 20; #heat transfer coefficient in W/m^2 K
print"Theta1 =",theta1,"K";
print"Theta =",theta,"K";
print"v/A =",R/2,"m";
print"k/a =",round((k/a)*10**(-6),4),"*10^(6)J/m^3 K";
time =(k/a)*(R/2)/h*math.log(theta1/theta);
print"Time taken by the rod to heat up =",round(time,1),"secs";
Bi = h*R/k;
#result
print"Biot number Bi =",round(Bi*10**4,2),"*10^(-4)";
print"Since Biot number is much less than 0.1,therefore assumption that internal temper a ture gradients are negligible is a good one";
```

In [10]:

```
import math
from __future__ import division
#Variable declaration
b = 0.005; #m
t = 5*60; #time, [sec]
Th = 200; #C
Tw = 20 ; #C
h = 150; #W/m^2 K
rho = 2200; #kg/m^3
Cp = 1050; #J/kg K
k = 0.4; #W/m K
ratiob0 = 0.12;
ratiob1 = 0.48;
lambda1b = 1.0498;
#calculations
theta = Th - Tw;
Biotno = h*b/k;
a = k/( rho*Cp); #alpha
Fourierno = a*t/b**2;
thetaxb0 = theta*ratiob0;
Txb0 = thetaxb0+Tw;
thetaxb1 = theta*ratiob1 ;
Txb1 = thetaxb1+Tw ;
x = (2*math.sin((lambda1b)))/(lambda1b+((math.sin((lambda1b)))*(math.cos((lambda1b)))));
thetaxb0 = theta*x*(math.exp((-lambda1b**2)*Fourierno));
Txb0 = thetaxb0+Tw;
#result
print"Temperature at b=0 is",round(Txb0,4),"degree";
```

In [11]:

```
import math
from __future__ import division
#Variable declaration
b = 0.005; #m
t = 5*60; #time, [sec]
Th = 200; #C
Tw = 20; #C
h = 150; #W/m^2 K
rho = 2200; #kg/m^3
Cp = 1050; #J/kg K
k = 0.4; #W/m K
ratiob0 = 0.12;
ratiob1 = 0.48;
lambda1b = 1.0498;
#calculations
theta = Th - Tw;
Biotno = h*b/k;
a = k/( rho *Cp);
Fourierno = a*t/b**2;
thetaxb0 = theta * ratiob0;
Txb0 = thetaxb0 + Tw;
thetaxb1 = theta * ratiob1;
Txb1 = thetaxb1 + Tw;
x = 2*math.sin(((lambda1b)))/(lambda1b + (math.sin(((lambda1b))))*(math.cos((lambda1b))));
thetaxb1 = thetaxb0*(math.cos (lambda1b *1));
Txb1 = thetaxb1+Tw;
#result
print"Temperature at b=1 is",round(Txb1,3),"degree C\n";
```

In [12]:

```
import math
from __future__ import division
#Variable declaration
D = 0.05 ; #m
To = 450 ; #degree C
Tf = 90 ; #degree C
T = 150 ; #degree C
h = 115 ; #W/m^2 K
rho = 8000 ; #kg/m^3
Cp = 0.42*1000 ; #kg/m^3
k = 46 ; #W/m K
R = D/2;
#calculations
t1 = rho*Cp*R /(3* h)* math.log ((To -Tf)/(T-Tf)); #sec
t1min = t1 /60 ; #min
#result
print"Time taken by the centre of the ball to reach 150 degree C if internal gradients are neglected is",round(t1,4),"seconds i.e.",round(t1min,4),"minutes";
```

In [13]:

```
import math
from __future__ import division
#Variable declaration
D = 0.05 ; #m
To = 450 ; #degree C
Tf = 90 ; #degree C
T = 150 ; #degree C
h = 115 ; #W/m^2 K
rho = 8000 ; #kg/m^3
Cp = 0.42*1000 ; #kg/m^3
k = 46 ; #W/m K
R = D/2;
lambda1R = 0.430;
y = 5;
#calculations
ratio = (T-Tf)/( To - Tf);
Bi = h*R/k;
x = 2* (math.sin(lambda1R)- lambda1R * math.cos(lambda1R))/ (lambda1R - math.sin ( lambda1R)*math.cos( lambda1R));
t=(math.log (ratio/x))/(-1*(k/(Cp*rho*R**2))*lambda1R**2);
tmin = t /60;
#result
print"Time taken by the centre of the ball to reach 150 degree"
print "C if internal temperature gradients are not neglected is",round(t,3),"seconds i.e",round(tmin,3),"min (roundoff error)";
```

In [14]:

```
import math
from __future__ import division
#Variable declaration
a = 0.12 ; #m
T = 400 ; #C
To = 25 ; #C
t = 100/60 ; #hour
h = 10 ; #W/m^2 K
k = 1.0 ; #W/m K
alpha = 3.33*10** -3 ; #m^2/h
ratiox = 0.82 ;
ratioy = 0.41;
ratioz = 0.30;
#calculations
x1 = h*a/k ;
x2 = k/(h*a);
x3 = alpha *t/a**2;
totalratio = ratiox * ratioy * ratioz ;
Tcentre = To + totalratio *(T-To) ;
ratiox = 1.1310* math.exp ( -(0.9036**2) *0.385) ;
ratioy = 1.0701* math.exp ( -(0.6533**2) *2.220) ;
ratioz = 1.0580* math.exp ( -(0.5932**2) *3.469) ;
ratio = ratiox * ratioy * ratioz ;
Tcentre = To + totalratio *(T-To) ;
#result
print"Temperature at the centre of the brick =",round(Tcentre,3),"degree c";
print"Alternatively, obtaining Biot number and values of lambda1b and using eqn 2.7.20, we get";
print"Temperature at the centre of the brick =",round(Tcentre,3),"degree c";
```

In [15]:

```
import math
from __future__ import division
#Variable declaration
D = 0.003 ; #m
L = 0.03 ; #m
h = 10 ; #W/m^2
Tf = 20 ; #C
T1 = 120 ; #C
k = 350 ; #W/m K
#calculations
m = (4* h/(k*D)) **(1/2) ;
ml = m *0.03 ;
T = Tf + (T1 -Tf)/ math.cosh (m*L);
#result
print"ml=",round(ml,4);
print"Temperature at the tip of fin made of copper is",round(T,4),"degree c";
```

In [16]:

```
import math
from __future__ import division
#Variable declaration
D = 0.003 ; #m
l = 0.03 ; #m
h = 10 ; #W/m^2
Tf = 20 ; #C
T1 = 120 ; #C
k = 15 ; #W/m K
#calculations
m = (4*h/(k*D)) **(1/2) ;
ml = m *0.03 ;
T = Tf + (T1 -Tf)/ math.cosh (m*l);
#result
print"ml=",round(ml,4);
print"Temperature at the tip of fin made of steel is",round(T,4),"degree c";
```

In [17]:

```
import math
from __future__ import division
#Variable declaration
D = 0.003 ; #m
L = 0.03 ; #m
h = 10 ; #W/m^2
Tf = 20 ; #C
T1 = 120 ; #C
k = 0.35 ; #W/m K
#calculations
m = (4* h/(k*D)) **(1/2) ;
mL = m *0.03 ;
T = Tf + (T1 -Tf)/ math.cosh (m*L);
#result
print"ml=",round(mL,4);
print"Temperature at the tip of fin made of teflon is",round(T,4),"degree c";
```

In [18]:

```
import math
from __future__ import division
#Variable declaration
L = 0.02 ; #M
t = 0.002 ; #M
b = 0.2 ; #M
theta1 = 200 ; #C
h = 15 ; #W/m^2 K
k = 45 ; #W/m K
#calculations
Bi = h*(t /2) /k ;
P = 2*( b+t); #m
A = b*t ;
mL = math.sqrt((h*P)/(A*k))*L;
n = math.tanh(mL)/mL;
qloss = n*h *40.4*2*10**-4*200;
#result
print"Fin Effectiveness =",round(n,3);
print"Heat loss rate from fin surface =",round(qloss,3);
```

In [19]:

```
import math
from __future__ import division
#Variable declaration
h = 15 ; #W/m^2 .K
k = 300; #W/m.K
T = 200; #C
Tsurr = 30; #C
d = .01; #M
L = .1; #M #
A = .5*.5; #M^2
n = 100; #Number of Pins
#calculations
Bi = h*d /2/ k; #Biot Number
mL = (h *4/ k/d) **.5* L;
zi = math.tanh (mL)/mL;
Res1 = 1/h/A; #Thermal resistance without fins
Res2 = 1/(h*(A - n*3.14 /4* d**2 + zi *(n* 3.14 *d*L))); #Thermal resistance with fins
delRes = Res1 - Res2 ; #heat transfer rate
q = (T- Tsurr )/ Res2 - (T- Tsurr )/ Res1 ;
#result
print"Decrease in thermal resistaneat surface",round(delRes,4),"k/w","\nIncrease in heattransfer rate",round(q,1);
```