How Does Heat Dissipate?

Introduction

OBJECTIVE:  Observe the physical interpretations of the contour and level curve plots and see an application of the Fourier Series.

Do you want to see physical interpretations of the contours and level curves you have been drawing? This exploration of the heat equation will enable you to do so.  The heat equation is a partial differential equation and its solution employs the Fourier series in a meaningful way. 
Note:  Part II requires knowledge of the Fourier series.

Technology Guidelines

NOTE:  If you have just finished a module, restart Mathematica or Quit Kernel under the Evaluation pull-down menu before executing a new module.
TO OPEN CELLS, click on the arrow to the left of the cell or put your cursor on the right cell bracket and double click. To open all cells, highlight the bracket on the far right and select Grouping under the Cell pull-down menu and select Open All Subgroups.
TO STOP AN EXECUTION
Select the Evaluation pull-down menu and click on Abort Evaluation.
ORDER OF EXECUTION
Execute cells in the order given. Do not skip any Input cells within a given notebook.
SAVING NOTEBOOKS
You can save anytime to any directory you choose, and it is wise to save often. However, before you do your final save to reduce the size of your file, it is a good idea to delete all your output by selecting the Delete All Output selection under the Cell pull-down menu.
EXPERIENCING MAJOR PROBLEMS
Save if appropriate, then shut down Mathematica and start it up again.

Background

The following problems represent solutions to the partial differential heat equation:  (Subscript[w, xx])=(1/(c^2))(Subscript[w, t]), where w(x,t) represents the temperature at position x at time t in a thin rod of length L with perfectly insulated sides. The value of the positive constant (c^2) is determined by the material from which the rod is made.

Part 1: Fixed End Temperatures

We first examine a very simple solution to the problem where we assume that the ends of the rod are immersed in ice and are maintained at a temperature of (0^0)C. If the rod is of length 4, the 0 degrees at both ends is represented by the boundary conditions w(0,t) = w(4,t) = 0. Assume also that the initial temperature distribution within the rod is given by w(x,0) = sin 2πx.

We first show that w(x,t) = (e^(-3t))sin(2π x) is a solution to the differential equation with these boundary and initial conditions. Also determine the value of the constant c for this problem.

w[x_,t_]:=(E^(-3t))Sin[2π x]
Print["The temperature at the left end of the rod is ",w[0,t]]
Print["The temperature at the right end of the rod is ",w[4,t]]
Print["The initial temperature distribution is ",w[x,0]]
Print["The second derivative of the temperature with respect to position is ",wxx =D[w[x,t],{x,2}]]
Print["The first derivative of the temperature with respect to time is ",wt=D[w[x,t],{t,1}]]
c=(Sqrt[(wt/wxx)]);
Print["c = ",c," or ",N[c]]
If[wxx==1/(c^2) wt,Print[w[x,t]," satisfies the differential equation."],Print["The equation is not satisfied."]]

Plot the temperature function at various positions along the rod as a function of time.

xlevelplots=Plot[{w[0,t],w[0.8`,t],w[1.6`,t],w[2.4`,t],w[3.2`,t],w[4,t]},{t,0,1},PlotStyle->{RGBColor[1,0,0],RGBColor[1,1,0],RGBColor[0,1,0],RGBColor[0,1,1],RGBColor[1,0,1],RGBColor[0,0,1]},AxesLabel->{t,"w"},PlotLabel->"X-Level Plots"]

Interpret these plots. What is happening to the temperature along different parts of the rod?

Plot the temperature function at various times as a function of the position on the rod.

tlevelplots=Plot[{w[x,0],w[x,0.2`],w[x,0.4`],w[x,0.6`],w[x,0.8`],w[x,1]},{x,0,4},PlotStyle->{RGBColor[1,0,0],RGBColor[0,1,1],RGBColor[0,1,0],RGBColor[0,1,1],RGBColor[1,0,1],RGBColor[0,0,1]},PlotRange->All,AxesLabel->{x,"w"},PlotLabel->"T-Level Plots"]

Interpret the results. What is happening to the temperature function as time goes on?

Plot the contours for the temperature function and the temperature function as a surface.

ContourPlot[w[x,t],{x,0,4},{t,0,1},PlotPoints->40,Axes->True,AxesLabel->{x,t}]
Plot3D[w[x,t],{x,0,4},{t,0,1},PlotPoints->40,AxesLabel->{x,t,"w"}]

What is happening as t->∞ ? Is this what you would expect? Why?

You Try It: Part I-Insulated Ends

We will next examine a very simple solution to the problem in which it is assumed that the ends of the rod are insulated so that no heat can escape. If the rod is of length 4, this is represented by the boundary conditions (Subscript[w, x])(0,t) = (Subscript[w, x])(4,t) = 0. 

Why? Can you explain this in your own words?

Assume also that the initial temperature distribution within the rod is given by w(x,0) = cos {2π x).
Show that  w(x,t)= (e^(-3t))cos(2π x} is a solution to the differential equation with these boundary and initial conditions. Also identify the constant c.

First define the function.

Clear[x,t,w]
w[x_,t_]:=Exp[-3t]Cos[2 π x]

Compute the derivatives and the constant c.

Print["The second derivative of the temperature with respect to position is ",wxx =D[w[x,t],{x,2}]]
Print["The first derivative of the temperature with respect to time is ",wt=D[w[x,t],{t,1}]]
c=(Sqrt[(wt/wxx)]);
Print["c = ",c," or ",N[c]]

Verify that the function satisfies the partial differential equation and the initial and boundary conditions.

Print["The change in temperature at the left end of the rod is ",D[w[x,t],x]/.x->0]
Print["The change in temperature at the right end of the rod is ",D[w[x,t],x]/.x->4]
Print["The initial temperature distribution, ",w[x,0]]
If[wxx==1/(c^2) wt,Print[w[x,t],", satisfies the differential equation."],Print["The equation is not satisfied."]]

Plot the temperature function at various positions along the rod as a function of time.

xlevelplots=Plot[{w[0,t],w[0.8`,t],w[1.6`,t],w[2.4`,t],w[3.2`,t],w[4,t]},{t,0,1},PlotStyle->{RGBColor[1,0,0],RGBColor[1,1,0],RGBColor[0,1,0],RGBColor[0,1,1],RGBColor[1,0,1],RGBColor[0,0,1]},AxesLabel->{t,"w"},PlotLabel->"X-Level Plots"]

Interpret these plots. What is happening to the temperature along different parts of the rod?

Plot the temperature function at various times as a function of the position on the rod.

tlevelplots=Plot[{w[x,0],w[x,0.2`],w[x,0.4`],w[x,0.6`],w[x,0.8`],w[x,1]},{x,0,4},PlotStyle->{RGBColor[1,0,0],RGBColor[0,1,1],RGBColor[0,1,0],RGBColor[0,1,1],RGBColor[1,0,1],RGBColor[0,0,1]},PlotRange->All,AxesLabel->{x,"w"},PlotLabel->"T-Level Plots"]

Interpret the results. What is happening to the temperature function as time goes on?

Plot the contours for the temperature function and the temperature function as a surface.

ContourPlot[w[x,t],{x,0,4},{t,0,1},PlotPoints->40,Axes->True,AxesLabel->{x,t}]
Plot3D[w[x,t],{x,0,4},{t,0,1},PlotPoints->40,AxesLabel->{"x","t","w"}]

What is happening as t->∞ ? Is this what you would expect? Why? 

How does this differ from the temperature function in the rod with fixed ends?

Part II: Insulated Ends and Use of the Fourier Series (demonstration only)

If you have not learned the Fourier series, you should not do this part of the module.

Suppose that the rod of length 4 has insulated ends, that is,  (Subscript[w, x])(0,t) = (Subscript[w, x])(4,t) = 0. Assume a discontinuous initial temperature distribution that is  - 12 for the left 1/4 of the rod and 0 elsewhere. This discontinuous initial temperature function necessitates the use of the Fourier series in order to get a continuous approximation to this discontinuous initial state. 

First, we determine the Fourier Series corresponding to the initial temperature state for the rod.

a[n_]:=a[n]=(1/2) (∫_0^1)12 Cos[((n π x)/4)]\[DifferentialD]x
Print["The Fourier cosine series out to n = 30 is ",fourcos[x_,30]=N[((a[0])/2)+(∑_(j=1)^30)a[j] Cos[((j π x)/4)]]]
Plot[fourcos[x,30],{x,0,4}]

Clear[w] 
w[x_,t_]= a[0]/2+Sum[a[j]Exp[-(j Pi/4)^2 * t]Cos[j Pi x/4],{j,1,30}] //N

xlevelplots=Plot[ {w[0,t],w[.8,t],w[1.6,t],w[2.4,t],w[3.2,t],w[4,t]},{t,0,5}, PlotStyle->{RGBColor[1,0,0],RGBColor[1,1,0],RGBColor[0,1,0],RGBColor[0,1,1],RGBColor[1,0,1],RGBColor[0,0,1]},AxesLabel->{t,"w"},PlotLabel->"x-Level Plots"]

Interpret these plots. What is happening to the temperature along different parts of the rod?

Plot the temperature function at various times as a function of the position on the rod.  Interpret the results.

tlevelplots=Plot[{w[x,0],w[x,0.3`],w[x,6],w[x,1],w[x,1.5`],w[x,2]},{x,0,4},PlotStyle->{RGBColor[1,0,0],RGBColor[1,1,0],RGBColor[0,1,0],RGBColor[0,1,1],RGBColor[1,0,1],RGBColor[0,0,1]},PlotRange->All,AxesLabel->{x,"w"},PlotLabel->"T-Level Plots"]

Interpret the results. What is happening to the temperature function as time goes on?

Plot the contours for the temperature function and the temperature function as a surface.

ContourPlot[w[x,t],{x,0,4},{t,0,5},Axes->True,AxesLabel->{x,t}]
Plot3D[w[x,t],{x,0,4},{t,0,5},AxesLabel->{x,t,"w"}]

What is happening as t->∞ ? Is this what you would expect? Why?