In [1]:

```
import math
# Variables
b = 9.; # Thickness of the wall in ft
A = 5.; # Area of wall
k = 0.44; # Thermal conductivity in Btu/hr-ft-degF
Cp = .202; # Specific heat in Btu/lbm-degF
rho = 136.; # Density in lb/ft**3
# Calculations and Results
def derivative(f):
def df(x, h=0.1e-5):
return ( f(x+h/2) - f(x-h/2) )/h
return df
def templength(x): # Temperature function in terms of length
return 90 - 80*x +16*x**2 +32*x**3 -25.6*x**4;
tgo = derivative(templength)(0); # Temperature gradient at x = 0ft
tgl = derivative(templength)(9./12); # Temperature gradient at x = 9/12ft
qo = -k*A*tgo; # Heat entering per unit time in Btu/hr
print "Heat entering per unit time is %.2f Btu/hr "%(qo);
ql = -k*A*tgl; # Heat coming out per unit time in Btu/hr
print " Heat coming per unit time is %.2f Btu/hr "%(ql);
q3 = qo-ql; #Heat energy stored in Btu/hr
print " Heat energy stored in wall is %.2f Btu/hr "%(q3);
a = k/(rho*Cp); # Thermal diffusivity
def doublederivative(y): # Derivative of tempearture with respect to length in degF/ft
return -80+32*y+96*y**2-102.4*y**3;
timeder0 = a*derivative(doublederivative)(0); # derivative of temperature wrt time at x = 0 in degF
print " Time derivative of temperature wrt time at x = 0ft is %.2f degF/hr"%(timeder0);
timeder1 = a*derivative(doublederivative)(9./12); # derivative of temperature wrt time at x = 9/12 in degF
print " Time derivative of temperature wrt time at x = 9/12ft is %.2f degF/hr"%(timeder1);
```

In [2]:

```
import math
# Variables
b = 9.; # thickness of the wall in ft
A = 5.; # area of wall in ft**2
k = 0.44; # Thermal conductivity in Btu/hr-ft-degF
Cp = .202; # Specific heat in Btu/lbm-degF
rho = 136.; # density in lb/ft**3
# Calculations and Results
def derivative(f):
def df(x, h=0.1e-5):
return ( f(x+h/2) - f(x-h/2) )/h
return df
def templength(x):
return 90 - 8*x-80*x**2;
tgo = derivative(templength)(0); # temperature gradient at x = 0ft
tgl = derivative(templength)(9./12); # temperature gradient at x = 9/12ft
qo = -k*A*tgo; # Heat entering per unit time in Btu/hr
print "Heat entering per unit time is %.2f Btu/hr "%(qo);
ql = -k*A*tgl; # Heat coming out per unit time in Btu/hr
print " Heat coming per unit time is %.2f Btu/hr "%(ql);
q3 = qo-ql; #Heat energy stored in Btu/hr
print " Heat energy stored in wall is %.2f Btu/hr "%(q3);
a = k/(rho*Cp); # Thermal diffusivity in ft**2/hr
def doublederivative(y): # derivative of tempearture with respect to length in degF/ft
return -8-160*y;
timeder0 = a*derivative(doublederivative)(0); # derivative of temperature wrt time at x = 0 in degF
print " Time derivative of temperature wrt time at x = 0ft is %.2f degF/hr"%(timeder0);
timeder1 = a*derivative(doublederivative)(9./12); # derivative of temperature wrt time at x = 9/12 in degF
print " Time derivative of temperature wrt time at x = 9/12ft is %.2f degF/hr"%(timeder1);
print " Teperature at each part of wall decreases equally";
```

In [8]:

```
import math
# Variables
t = 10.; # time elapsed in hr
Ti = 70.; # tempearature of wall initially in degF
Ts = 1500.; # temperature of surface when suddenly changed in degF
a = 0.03; # thermal diffusivity in ft**2/hr
k = 0.5; # thermal conductivity in Btu/hr-ft-degF
A = 10.; # area of wall in sq ft
x = 7./12; # distance from surface where tempearture is to be found in ft
f = x/(2*math.sqrt(a*t));
# From gaussian error function table erf can be found
errorf = 0.55; # Referred from table
# Calculations and Results
T = Ts+(Ti-Ts)*errorf;
print "Temperaure at a distance of 7/12ft from surface is %.1f degF "%(T);
q = -k*A*(Ti-Ts)*math.exp(-x**2/(4*a*t))/math.sqrt(t*math.pi*a); # heat flow rate at a distance
qtot = -k*A*(Ti-Ts)*2*math.sqrt(t/(math.pi*a)); # total heat flowing after 10 hrs in Btu
print " Heat flowing at a distance of 7/12 ft from surface is %d Btu/hr"%(q);
print " Total heat flow after 10hrs is %.f Btu"%(qtot);
# note : book answer are wrong.
```

In [9]:

```
# Variables
d = 16./12; # Diameter of sphere in ft
t = 20./60; # Time elapsed in hr
a = 0.31; # thermal diffusivity of steel in ft**2/hr
Ti = 80.; # Temperature of steel sphere initially in degF
Ts = 1200.; # Temperature of surface suddenly changed in degF
# Calculations
s = 4*a*t/d**2; # A parameter
# From table the value of F(s) can be known
Fs = 0.20;
Tc = Ts+(Ti-Ts)*Fs; # Tempearture at the center of sphere in degF
# Results
print "The tempearture at the center of steel sphere after 20 mins is %d degF"%(Tc);
```

In [11]:

```
import math
# Variables
t = 24.; # Time period of tempearture wave in hr
k = 0.6; # Thermal conductivity of wall in Btu/hr-ft-degF
Cp = 0.2; # Specific heat capacity of wall in Btu/lb-degF
y = 110.; # specific gravity in lb/ft**3
x = 8./12; # distance from surface in ft
# Calculations
a = k/(y*Cp); # Thermal diffusivity in ft**2/hr
n = 1./t; # frequency in /hr
delr = x/(2*math.sqrt(a*math.pi*n)); # Time lag in hr
# Results
print "Time lag of the temperature at a point 8 in from surface is %.1f hr"%delr;
# book answer is wrong.
```

In [12]:

```
import math
# Variables
T1 = -15.; # Min temperature at surface in degF
T2 = 25.; # Max temperature at surface in degF
t = 24.; # time gap in hrs
k = 1.3; # thermal conductivity in Btu/hr-ft-degF
Cp = 0.4; # heat capacity in lb/ft-degF
y = 126.1; # specific gravity in lb/ft**3
n = 1./t; # frequency in /hr
Tm = (T1+T2)/2;
a = k/(y*Cp); # thermal diffusivity in ft**2
# Calculations and Results
x1 = 2;
x2 = 6;
th0 = (T1-T2)/2;
th1 = th0*-math.exp(-x1*math.sqrt(math.pi*n/a)); # temperature range at 2 ft depth
th2 = th0*-math.exp(-x2*math.sqrt(math.pi*n/a)); # temperature range at 6 ft depth
print "Amplitude of tempearture at 2ft deep is %.2f degF"%(th1);
print " Amplitude of tempearture at 6ft deep is %.2f degF"%(th2);
print " At a depth of 2ft , temperature varies from 4.78 degF to 5.22 degF and \
at a depth of 6 ft, temperature remains constant at 5 degF"
delr1 = x1/2*math.sqrt(1/(a*math.pi*n)); # time lag at 2 ft depth
delr2 = x2/2*math.sqrt(1/(a*math.pi*n)); # time lag at 6 ft depth
print " Lag of temperature wave at a depth 2 ft is %.1f hr "%(delr1);
print " Lag of temperature wave at a depth 6 ft is %.1f hr "%(delr2);
```

In [14]:

```
import math
# Variables
T1 = 10.; # Min temperature at surface in degF
T2 = -10.; # Max temperature at surface in degF
t1 = 24.;
t2 = 5.; # Time gap in hrs
k = 0.3; # Thermal conductivity in Btu/hr-ft-degF
Cp = 0.47; # Heat capacity in lb/ft-degF
y = 100.; # Specific gravity in lb/ft**3
n1 = 1/t1; # Frequency in /hr
Tm = (T1+T2)/2;a = k/(y*Cp); # thermal diffusivity in ft**2
n = 1./t1; # Frequency in /sec
x1 = 1.;
x2 = 1.;
# Calculations and Results # Depth in ft
th0 = (T1-T2)/2;th1 = th0*math.exp(-x1*math.sqrt(math.pi*n/a)); # temperature range at 2 ft depth
th2 = th0*math.exp(-x2*math.sqrt(math.pi*n/a)); # Temperature range at 6 ft depth
print "Amplitude of tempearture at 2ft deep is %.2f degF"%(th1);
delr1 = x1/2*math.sqrt(1/(a*math.pi*n)); # Time lag at 2 ft depth
print " Lag of temperature wave at a depth 2 ft is %.1f hr "%(delr1);
# To calculate the temperature at a depth of 1 ft , 5 hr after the srface temperature reaches the minimum temperature
r = 3/(4*n); # Time at which minimum surface temperature occurs for the first time in hr
r1 = r+5; # Time ar which temperature is to be found out in degF
th3 = th0*math.exp(-x1*math.sqrt(math.pi*n/a))*math.sin(2*math.pi*r1/24-4.53);
Tr = Tm+th3; # Temperature to be found out in degF
print " The temperaure at 1 ft depth is %.2f degF "%(Tr);
```

In [15]:

```
import math
# Variables
a = 0.02; # thermal diffusivity in ft**2/hr
M = 4.; # the value of 4 is selected for M
# Calculations and Results
x = 9./12; # thickness of wall in ft
delx = 1.5/12;
delr = delx**2/(a*M); # at time interval the heat transfeered will change the temperature of math.sink from tb2 to tb2o
print "The time interval is to be of %.3f hr "%(delr);
t1o = 370;
t2o = 435;
t3o = 480;
t4o = 485;
t5o = 440;
t6o = 360;
t7o = 250;
# tempetaures at different positions at wall in degF initially
# we know qo = Z*delx*dely*rho*Cp(tb2'-tb2)/delr So on solving equations we get tb2' = (tb1+tb3+ta2+tc2)/4
# using above formula, temperaures at different positions as shown below can be calculated in degF
ta = [370, 430, 470, 473, 431, 352, 250];
tb = [370, 425, 461, 462, 422, 346, 250];
tc = [370, 420, 452, 452, 413, 341, 250];
td = [370, 415, 444, 442, 404, 336, 250];
print " The temperatures at different positions 0.78 hr after, are as follows "
for i in range(7):
print " The temperature at point %d is %d degF "%(i,td[i]);
```

In [16]:

```
# Variables
a = 0.53; # thermal diffusivity in ft**2/hr
M = 4.; # the value of 4 is selected for M
x = 6./12; # thickness of wall in ft
delx = 2./12;
delr = delx**2/(a*M); # at time interval the heat transfeered will change the temperature of math.sink from tb2 to tb2o
print "the time interval is to be of %.3f hr "%(delr);
# the temperature is consmath.tant in the whole wall initiallt 100 degF and afterwards it changes to 1000 degF.
# we know qo = Z*delx*dely*rho*Cp(tb2'-tb2)/delr So on solving equations we get tb2' = (tb1+tb3+ta2+tc2)/4
# using above formula we can calculate the different temperatures as given below in degF
ta = [100, 550, 775, 888, 944];
tb = [100, 550, 775, 888, 944];
tc = [100, 550, 775, 888, 944];
td = [100, 550, 775, 888, 944];
print " the temperatures at different positions 0.052 hr after, are as follows "
print " the temperature at point a is %d degF "%ta[4]
print " the temperature at point a is %d degF "%tb[4]
print " the temperature at point a is %d degF "%tc[4];
print " the temperature at point a is %d degF "%td[4]
```