About
Developed by L. Engelhardt
In introductory physics, students learn two equations that involve heat: $Q=mc\mathrm{\Delta}T$, describes the amount of heat transferred in calorimetry; and $\frac{Q}{\mathrm{\Delta}t}={k}_{t}A\frac{\mathrm{\Delta}T}{\mathrm{\Delta}x}$ describes the rate of steady state heat flow through a window. In this Exercise Set we combine these two equations to explore the dynamics of heat flow and temperature change in one dimension. Specifically, we will explore the temperature of a frying pan handle as a function of both position and time, and we will see how this temperature profile depends on the material properties of the handle.
Subject Area  Thermal & Statistical Physics 

Levels  First Year and Beyond the First Year 
Available Implementations  IPython/Jupyter Notebook and Python 
Learning Objectives 
Students will be able to:

Time to Complete  120 min 

In the exercises below, you will simulate heat transfer along a $L=15$ cm long frying pan handle for a frying pan that is heated on a stove for 10 minutes.
Exercise 1: Mathematical Derivation
Derive an equation for the temperature of slice number $N$ at the end of a onedimensional rod, ${T}_{N}^{j}$. Your derivation, and the resulting equation, will be very similar to the derivation and result for the other slices of the rod (for $i\le N1$). The only difference is that there is no heat flow in/out of the right side of this slice.
Exercise 2: x
and t
Write lines of code to generate two onedimensional arrays: one for the discrete values of position, ${x}_{i}$, and one for the discrete values of time, ${t}^{j}$.
Exercise 3: Material Properties
You will simulate the handle of a frying pan, using handles made of (1) stainless steel and (2) Bakelite. Look up the relevant material properties for both stainless steel and Bakelite. What are the numerical values for each of these properties for each material?
Exercise 4: Dimensionless constant, r
Compute the constant “$r$” for stainless steel. What value do you obtain? If it is greater than 0.5, you will need to adjust your discretization of the position and/or the time to decrease the values of $r$.
Exercise 5: 2D array and initial temperature
Generate a 2D array that will be used to store temperature as a function of both position and time, ${T}_{i}^{j}$.
The temperature of the frying pan handle will begin at a room temperature of ${T}_{i}^{0}={72}^{\circ}$ F. Store this initial ($j=0$) value in the 2D array for all slices of the rod (for all $i$).
Exercise 6: Temperature of the pan
You will need to generate an array of temperatures for the frying pan (at the left edge of the handle) as a function of time, ${T}_{0}(t)$. The frying pan will start out at room temperature at time $t=0$. A typical frying pan will then heat up quicky for the first minute or two after a stove is turned on, and then it will reach a constant temperature of around 350 to ${400}^{\circ}$ F. This behavior can be reproduced using the equation
with ${T}_{room}={72}^{\circ}$ F, $\mathrm{\Delta}{T}_{stove}={300}^{\circ}$ F, and $\tau =60$ seconds. “tanh” is the “hyperbolic tangent” function, which is one of the standard builtin functions for any computer math library.
Use this equation to compute an array of ${T}_{0}(t)$ values, and then plot ${T}_{0}$ versus $t$ to verify that the temperature of you frying pan agrees with the following plot:
Once you have verified that ${T}_{0}(t)$ is correct, use the 1D array of ${T}_{0}(t)$ values to set the temperature of the left ($i=0$) edge of the handle in the 2D array, ${T}_{0}^{j}$, for all values of time (for all $j$).
Exercise 7: Conversions
You will need to convert the 2D array, ${T}_{i}^{j}$ from units of Fahrenheit to Celsius before beginning the simulation. Then convert back from Celsius to Fahrenheit after the simulation. What will you need to do in order to perform both of these conversions?
Exercise 8: Computing for many i
and j
Complete the line of code to compute ${T}_{i}^{j}$ for all positions, $1\le i\le N1$, and all times, $j>0$.
Exercise 9: End of the handle
Complete the line of code to compute ${T}_{N}^{j}$ at the end of the handle for all times, $j>0$. (You derived this equation in Exercise 1.)
Exercise 10: Plotting
Plot the temperature of the rod versus position, $T(x)$, for a few different values of time, $t$. Make sure that your results seem reasonable. Discuss if/why the results seem reasonable.
Note: It is likely that your program won’t work right away! If your code generates errors, or if the results just don’t seem physically reasonable, you will need to debug your code.
Exercise 11: Convergence
Decrease the values of $\mathrm{\Delta}x$ and $\mathrm{\Delta}t$, and rerun the simulation to check for convergence. If the temperature results change when you change the discretization, that means that $\mathrm{\Delta}x$ and/or $\mathrm{\Delta}t$ are too big, and you need to make them smaller. (But make sure that $r<\mathrm{0.5.})$
Exercise 12: Animating
Create an animation showing temperature versus position at many different moments in time. Again, make sure that the results seem reasonable, and check for convergence. Discuss.
Exercise 13: Contour plots
Create a contour plot that shows temperature as a function of both position and time in a single static plot. Again, make sure that the results seem reasonable, and check for convergence. Discuss.
Exercise 14: Analysis
At a temperature of 150${}^{\circ}$ F, an object will quickly cause a burn if touched. (You can also get burned by cooler objects, but not immediately – only if you continue to touch the object for an extended period of time.) Based on the results of your simulations, discuss where you would – and would not – be able to safely touch the handle of the pan at different moments in time.
Exercise 15: Repeat for other material
Repeat the exercises above for a frying pan handle that is made of Bakelite rather than stainless steel. Discuss your results.
# # Author: Larry Engelhardt (July, 2016)
# Material properties for a few different materials are listed below
#
# 1. Thermal conductivity: `k_t`
# 2. Specific heat capacity: `c`
# 3. Density: `rho`
#
# Stainless Steel
k_t = 16 # W / (m C)
c = 500 # J / (kg C)
rho = 8000 # kg / m^3
# Bakelite
k_t = 0.2 # W / (m C)
c = 920 # J / (kg C)
rho = 1300 # kg / m^3
# Oak
k_t = 0.17 # W / (m C)
c = 2000 # J / (kg C)
rho = 700 # kg / m^3
# Fiberglass
k_t = 0.04 # W / (m C)
c = 700 # J / (kg C)
rho = 2000 # kg / m^3
# BEGINNING THE PROGRAM:
from pylab import *
# Discretizing space
L = 0.15 # Length of handle in meters
Nx = 76 # Number of positions in space
x = linspace(0, L, Nx) # Array of positions
dx = L / (Nx  1) # Values of delta x (meters)
# Discretizing time
tMax = 600 # Maximum time in seconds
Nt = 1801 # Number of time steps
t = linspace(0, tMax, Nt) # Array of time values
dt = tMax / (Nt  1) # Size of time step (seconds)
T0 = 72 # Initial temperature (Farenheit)
dT_stove = 300 # Temperature increase of the stove (F)
# Stainless Steel's material properties
k_t = 16 # W / (m C)
c = 500 # J / (kg C)
rho = 8000 # kg / m^3
r = k_t * dt / (c * rho * dx**2) ## THE PARAMETER! (dimensionless) ##
print('r:', r) # Check to make sure that r < 0.5
# Preparing 2D array of temperatures
T = zeros((Nt, Nx)) # 2D array for temperature. NOTE THE ORDER: [time, space]
T[0, :] = T0 # Initial values (time t = 0)
tau = 60 # Used in tanh function, units of seconds
T[:, 0] = T0 + dT_stove * tanh(t/tau) # Edge of rod (at x=0) in deg. F
T = (T  32) / 1.8 # Convert all temperatures to Celsius
# Verifying that \(T(t)\) for the pan (\(x=0\)) looks correct:
Tpan = T0 + dT_stove * tanh(t/tau)
plot(t, Tpan, lw=2)
grid(True)
xlabel('Time (sec)')
ylabel('Pan Temperature (F)')
grid(True); show()
# Computing the temperature of the handle for all `x` and `t`:
for j in range(1, Nt): # Loop thru TIME
for i in range(1, Nx1): # Loop thru SPACE
T[j,i] = r*T[j1, i+1] + (1  2*r)*T[j1,i] + r*T[j1, i1]
T[j, 1] = (1r)*T[j1,i] + r*T[j1,i1] # End of rod (x=L)
T = 1.8*T + 32 # Convert back to F from C
x = x * 100 # Convert from meters to cm
# Plotting \(T(x)\) for a few moments in time
jValues = [30, 180, 540, 1] # A few values of the time index (1 for last element)
for j in jValues:
plot(x, T[j,:], linewidth=2, label='Time (seconds): '+str(t[j]))
legend()
title('Stainless Steel')
xlim([0, 15])
xlabel('Position (cm)')
ylabel('Temperature (\(^{\circ}\)F)')
grid(True);
savefig('StainlessSteel_T_vs_x.png')
show()
# Creating a contour plot of \(T(x, t)\)
colorvals = linspace(70, 160, 91) # colors for contour plot (min, max, num)
contourf(x, t, T, colorvals) # (xaxis, yaxis, z(x,y))
title('Stainless Steel')
xlabel('x (cm)')
ylabel('Time (sec)')
colorbar()
grid(True)
savefig('StainlessSteel_contour.png')
show()
# Repeating using Bakelite
# Discretizing space
L = 0.15 # Length of handle in meters
Nx = 76 # Number of positions in space
x = linspace(0, L, Nx) # Array of positions
dx = L / (Nx  1) # Values of delta x (meters)
# Discretizing time
tMax = 600 # Maximum time in seconds
Nt = 1801 # Number of time steps
t = linspace(0, tMax, Nt) # Array of time values
dt = tMax / (Nt  1) # Size of time step (seconds)
T0 = 72 # Initial temperature (Farenheit)
dT_stove = 300 # Temperature increase of the stove (F)
# Bakelite's material properties
k_t = 0.2 # W / (m C)
c = 920 # J / (kg C)
rho = 1300 # kg / m^3
r = k_t * dt / (c * rho * dx**2) ## THE PARAMETER! (dimensionless) ##
print('r:', r) # Check to make sure that r < 0.5
# Preparing 2D array of temperatures
T = zeros((Nt, Nx)) # 2D array for temperature. NOTE THE ORDER: [time, space]
T[0, :] = T0 # Initial values (time t = 0)
tau = 60 # Used in tanh function, units of seconds
T[:, 0] = T0 + dT_stove * tanh(t/tau) # Edge of rod (at x=0) in deg. F
T = (T  32) / 1.8 # Convert all temperatures to Celsius
for j in range(1, Nt): # Loop thru TIME
for i in range(1, Nx1): # Loop thru SPACE
T[j,i] = r*T[j1, i+1] + (1  2*r)*T[j1,i] + r*T[j1, i1]
T[j, 1] = (1r)*T[j1,i] + r*T[j1,i1] # End of rod (x=L)
T = 1.8*T + 32 # Convert back to F from C
x = x * 100 # Convert from meters to cm
jValues = [30, 180, 540, 1] # A few values of the time index (1 for last element)
for j in jValues:
plot(x, T[j,:], linewidth=2, label='Time (seconds): '+str(t[j]))
legend()
title('Bakelite')
xlim([0, 15])
xlabel('Position (cm)')
ylabel('Temperature (\(^{\circ}\)F)')
grid(True);
savefig('StainlessSteel_T_vs_x.png')
show()
colorvals = linspace(70, 160, 91) # colors for contour plot (min, max, num)
contourf(x, t, T, colorvals) # (xaxis, yaxis, z(x,y))
title('Bakelite')
xlabel('x (cm)')
ylabel('Time (sec)')
colorbar()
grid(True)
savefig('Bakelite_contour.png')
show()
Translations
Code  Language  Translator  Run  

Software Requirements
Android  iOS  Windows  MacOS  
with best with  Chrome  Chrome  Chrome  Chrome 
support fullscreen?  Yes. Chrome/Opera No. Firefox/ Samsung Internet  Not yet  Yes  Yes 
cannot work on  some mobile browser that don't understand JavaScript such as.....  cannot work on Internet Explorer 9 and below 
Credits
Fremont Teng; Loo Kang Wee
end faq
Version
 https://www.compadre.org/PICUP/exercises/exercise.cfm?I=138&A=heatflow_1d
 http://weelookang.blogspot.com/2018/06/heatflowdynamicsof1drod.html