This is not a answer, only some investigations that are worth to be shared.
Here is the code of the OP, exactly :
ss=NDSolve[{D[u[x, t], t, t] == D[u[x, t], x, x],
u[x, 0] == HeavisideTheta[x - 1] HeavisideTheta[2 - x] ,
u[0, t] == 0, u[Pi, t] == 0}, u, {x, 0, Pi}, {t, 0, 3}]
Plot[u[x, t] /. ss /. t -> 0, {x, 0, Pi}]
The aim of the following approach is to discover :
- the method used by
NDSolve
So far I know there are 3 possibilites :
1) Method of Lines + Tensor Product Grid
2) Method of Lines + Finite Element Method
3) Finite Element Method for all the independent variables, including what is generally considered as time (here t) and is treated with the Method of Lines.
- What is the real mesh used by FEM. Is it responsible of the problem of the OP (answer : Yes)
extraction of the interpolatingFunction :
ssFunction=ss[[1,1,2]]

First question : Was FEM used ?
This subject is discuted here
ssFunction["ElementMesh"]
ElementMesh[{{0., 3.14159}, {0., 3.}}, {QuadElement["<" 420 ">"]}]
So FEM was used.
Second Question : Was it a purely finite element method or was the temporal variable treated with the Method of Lines ?
The following code permits to have the answer. It comes from the documentation "finite element Programming":
{state}=NDSolve`ProcessEquations[{D[u[x, t], t, t] == D[u[x, t], x, x],
u[x, 0] == HeavisideTheta[x - 1] HeavisideTheta[2 - x] ,
u[0, t] == 0, u[Pi, t] == 0}, u, {x, 0, Pi}, {t, 0, 3}]
{NDSolve`StateData["<" "SteadyState" ">"]}
"SteadyState" indicates that there no temporal variable. If t
were considered as a temporal variable, then the code above would have returned :
{NDSolve`StateData["<" 0. ">"]}
What is the Mesh used by FEM ?
Since the problem is treated without special consideration for the variable t
, the mesh is of dimension 2.
In fact we are mainly interested in the spacial grid at time t=0.
To analyse this, I propose to change the problem from kind 3) to kind 2). (that has the problem of the OP, I mean the bumps, too).
Here is the new code :
ssValue=NDSolve[{D[u[x, t], t, t] == D[u[x, t], x, x],
u[x, 0] == HeavisideTheta[x - 1] HeavisideTheta[2 - x] ,
(D[u[x, t],t] /. t -> 0) == 0,
u[0, t] == 0, u[Pi, t] == 0}, u, {x, 0, Pi}, {t, 0, 3},
Method -> {"MethodOfLines",
"TemporalVariable" -> t,
"SpatialDiscretization" -> {"FiniteElement","MeshOptions"->
{"MaxCellMeasure"-> 3. 10^-1}}}]
ssValueFunction=ssValue[[1,1,2]]
Note that I have added (D[u[x, t],t] /. t -> 0) == 0
in your code. This is necessary for the wave equation : see here.
I'm surprised that you can obtain an answer with your code.
Now, one can retrieve the mesh and the coordinates :
Point00=Point[ssValueFunction["ElementMesh"] ["Coordinates"] //
(First /@ # &) //
({#,ssValueFunction[#,0]}& /@ # &)]
Finally, a plot explains what happens in the OP's question :
Plot[ ssValueFunction[x,0.], {x, 0, Pi},Mesh-> All,ImageSize->900,AspectRatio->0.2,
Epilog-> {AbsolutePointSize[8],Red,Point00}]

The red points are the points of the mesh used by the FEM.
It's the interpolation in the function returned by NDSolve
that is the origin of the bumps.
Derivative[0,1][u][x,0]=…
is missing. $\endgroup$D[u[x, t], t]
rather thanD[u[x, t], t, t]
. $\endgroup$