Wolfram Language

Partial Differential Equations

Model the Flow of Heat in an Insulated Bar

Model the flow of heat in a bar of length 1 that is insulated at both ends.

In[1]:=
Click for copyable input
heqn = D[u[x, t], t] == D[u[x, t], {x, 2}];

Specify that no heat flows through the ends of the bar.

In[2]:=
Click for copyable input
bc = {Derivative[1, 0][u][0, t] == 0, Derivative[1, 0][u][1, t] == 0};

Specify an initial condition.

In[3]:=
Click for copyable input
ic = u[x, 0] == 20 + 80 x;

Solve the heat equation subject to these conditions.

In[4]:=
Click for copyable input
sol = DSolve[{heqn, bc, ic}, u[x, t], {x, t}]
Out[4]=

Extract a few terms from the Inactive sum.

In[5]:=
Click for copyable input
approxsol = u[x, t] /. sol[[1]] /. {Infinity -> 4} // Activate // Expand
Out[5]=

Visualize the evolution of the temperature to the steady-state value of 60°.

In[6]:=
Click for copyable input
Plot[Table[approxsol, {t, 0.02, 0.9, 0.07}] // Evaluate, {x, 0, 1}, AxesOrigin -> {0, 0}, PlotRange -> All]
Out[6]=

Related Examples

de es fr ja ko pt-br ru zh