Question: pdsolve numeric plot problems

I tried a partial differential equation example from a Robert Lopez example.  The answer shows a nice smooth graphical representation of heat transfer. 

However why does my method here, using numeric pdsolve, not produce the same results? 

Also pdsolve using numeric does not use the default timestep of 1/20.  Explicitly telling Maple to use timestep of 1/20 produces a different graph telling me that the default value is not being used in pdsolve.

So here is the example.  The heat distribution is described by the piecewise function f(x)=0   0<=x<1,  f(x)=1   1<=x<=2,  and f(x)=0 otherwise

eq:=diff(u(x,t),x)=k*diff(u(x,t),t,t):

k:=.5:
L:=Pi:

f := x-> piecewise(0 <= x and x < 1, 0, 1 <= x and x <= 2, 1, 0) :

ibc:=u(0,t)=0,u(L,t)=0,u(x,0)=f(x): # initial boundary conditions

sol:=pdsolve({eq},{ibc},numeric):

p1:=sol:-plot3d(u,x=0..Pi,t=0..2,shading=z):

plots:-display(p1)

 

I tried 'optimize'=true (didn't really do anything) 'spacestep'=1/20 (that's the default but it plots better) smaller spacestep numbers reduce the spikes.  This similar to my piecewise question to which no one could answer except that this example here I found was done in Maple to which I could compare the same method in the same software.  The other software to which I refer to in my other question was produced by Matlab by the way.

So what's with the noticeable spikes at x=1 and x=2 boundaries?  How do I get a smooth graph?

Please Wait...