Version 12 on windows 10.
I can't figure what should be changed in this call to NDSolve
to make it happy.
This PDE is solved by DSolve
, but NDSolve
gives many warnings. and when trying to plot the solution it gives after long time, Manipulate
just aborts, as each step takes very long time. So there is something wrong in the solution due to these warnings.
This wave PDE is standard one, on rectangle, all 4 edges are fixed, with initial position and zero initial velocity.
ClearAll[t, U, x, y];
L = 2; (*x dimension*)
H = 3; (*y dimension*)
c = 0.3; (*wave speed*)
f1[x_?NumericQ] := Piecewise[{{x, 0 <= x <= L/2}, {L - x, L/2 < x <= L}}];
f2[y_?NumericQ] := Piecewise[{{y, 0 <= y <= H/2}, {H - y, H/2 < y <= H}}];
pde = D[U[x, y, t], {t, 2}] == c^2*Laplacian[U[x, y, t], {x, y}];
ic = {U[x, y, 0] == f1[x]*f2[y], Derivative[0, 0, 1][U][x, y, 0] == 0};
bc = {U[x, 0, t] == 0, U[0, y, t] == 0, U[L, y, t] == 0, U[x, H, t] == 0};
numericalSol = First@NDSolve[{pde, ic, bc}, U, {x, 0, L}, {y, 0, H}, {t, 0, 20}]
Even though Manipulate shows the initial position correctly, it is very slow to play. Each steps takes for ever to move.
I tried using these options as suggested in comment here
Method -> {"MethodOfLines",
"SpatialDiscretization" -> {"TensorProductGrid", "MaxPoints" -> 101}}
And tried increasing the "MaxPoints", but they had no effect. I think NDSolve
does not like something about the initial position above, given using Piecewise
but I see nothing wrong with it:
Plot3D[f1[x]*f2[y], {x, 0, L}, {y, 0, H}]
Here is the Manipulate code which is meant to play the solution over time if needed
Manipulate[
Plot3D[{Evaluate[U[x, y, t] /. numericalSol]}, {x, 0, L}, {y, 0, H},
BaseStyle -> 15,
ImageMargins -> 5,
Mesh -> 25,
PerformanceGoal -> "Speed",
BoxRatios -> {1, 1, 0.4},
PlotRange -> {Automatic, Automatic, {-1, 1.4}},
ImageSize -> 500,
ColorFunctionScaling -> False,
ColorFunction -> ColorData[{"TemperatureMap", {0, 1}}],
AxesLabel -> {"x", "y", "U(r,0)"},
SphericalRegion -> True,
ViewPoint -> {0.796 , -2.725 , 0.5471}
],
{{t, 0, "time"}, 0, 20, .1, Appearance -> "Labeled"}
]
Any suggestions what to change in the call to NDSolve
above to remove these warnings and Make manipulate work better?