(* Thermal diffusivity and domain parameters *)
alpha = 0.1;
L = 1; (* Length of rod *)
tmax = 3; (* Maximum time *)
DT=0;
(* Heat equation setup *)
heatEquation = D[u[t, x], t] == alpha D[u[t, x], {x, 2}];
initialCond = u[0, x] == Exp[-40(x-.5)^2]+0*Sin[nu x]+x DT; (* Initial temperature profile *)
boundaryConds = {u[t, 0] == 0, u[t, L] == DT}; (* Fixed temperature at ends *)
(* Solve the PDE *)
sol = NDSolve[{
heatEquation,
initialCond,
boundaryConds
}, u, {t, 0, tmax}, {x, 0, L}]
(* Visualize the solution *)
Plot3D[u[t, x] /. sol, {t, 0, tmax}, {x, 0, L},
PlotRange -> All,
AxesLabel -> {"Time", "Position", "Temperature"},
ColorFunction -> "TemperatureMap"]
(* Animated temperature evolution *)
Manipulate[
Plot[u[t, x] /. sol, {x, 0, L},
PlotRange -> {0, 1+DT},
AxesLabel -> {"Position", "Temperature"},
PlotLabel -> Row[{"t = ", t}]],
{t, 0, tmax}]