# Heat Equation with Dirichlet Boundary Conditions

Here we will solve the initial-boundary value problem

∂u/∂x=[Graphics:heateq2gr1.gif] [Graphics:heateq2gr2.gif]u/∂

[Graphics:heateq2gr3.gif]

subject to the Dirichlet boundary conditions

u(0, t) = u(l, t) = 0,

and initial conditions

u(x, 0) = f(x).

[Graphics:heateq2gr4.gif]

As an example, we choose Problem 1(f) on page 586 where l = 2 and f(x) = 1, if 0 < x < 1, and 0, otherwise.

c=1; l=2; nn = 50;

f[x_]=If[0<x<1,1,0];

a[n_]:=2/l NIntegrate[f[x] Sin[n Pi x/l], {x, 0, 2}];

coeffs=Table[a[n], {n, 1, nn}];

Print["The Fourier coefficients of are"];

Print[" "];

Print[coeffs];

u[x_, t_]=Sum[coeffs[[n]] Exp[-n^2 Pi^2 c^2 t/l^2] Sin[n Pi x/l], {n, 0, nn}];

Plot[Evaluate[Table[u[x,t], {t, 0, 1, 0.1}]], {x, 0, l}]

The Fourier coefficients of are:

Note several features of this program and its output:

1. NIntegrate gives several warnings about oscillatory integrands and whether the value of the integral is really zero. Ignore these warnings.

2. Even with N = 50, the partial sum of the initial datum is still rather choppy. However, the graphs of u(x,t) for values of t larges than 0 are all smooth.

3. The equilibrium solution of this problem is u = 0, which should be obvious from the physics of this problem. Note, however, that the temperature of the right-half of the medium (where x is between 1 and 2) goes up before it goes down to zero again. This is the result of heat conduction between neighboring points in heat-conducting medium; in the neighborhood of x = 1 there is a very large (actually, infinite) thermal gradient that the medium first attempts to make uniform by heat conduction. Thus the temperature of the points immediately to the right of x =1 goes up. After a while, however, the effect of the boundary at x = 2 (which continuously removes heat from the system) takes over.

Here is how the graph of the evolution of heat that the particle x= 3/2 experiences:

Plot[u[3/2,t], {t, 0, 1}]

4. Here is the 3-D rendering of the temperature profile.

ParametricPlot3D[{t,x, u[x,t]}, {t, 0, 1}, {x, 0, 2}, PlotPoints->20, PlotRange->All]

-Graphics 3D -

5. Note that at time 0 infinitely many points in the medium have the same temperature but that as time evolves only pairs of points have the same temperature. Here is how one determines the set of points in the medium that have temperature 0.1 at time t= 0.2:

FindRoot[u[x,0.2]==0.1, {x, 0.1, 0.11}]

FindRoot[u[x,0.2]==0.1, {x, 0.9, 0.91}]