I was answering different question How Can I Visualize a PDE Boundary Condition? and in the process, found that DSOlve
solution to the laplace PDE does not agree with the BC.
Then I tried NDSolve
and the plot now shows agreement.
Did I do something wrong here, or could this be a bug in DSolve
?
First, here is plot of the BC on its own
ClearAll [theta, r, u]
bcf = 2*Pi*theta - theta^2;
ParametricPlot3D[{r Cos[theta], r Sin[theta], bcf}, {r, 1 - .01,
1 + .01}, {theta, 0, 2 Pi}, BoxRatios -> {1, 1, 1}]
Hence the solution to the PDE should match the above on the BC. But it does not:
ClearAll [theta, r, u]
pde = Laplacian[u[r, theta], {r, theta}, "Polar"] == 0;
bcf = 2*Pi*theta - theta^2;
bc = u[1, theta] == bcf;
sol = u[r, theta] /. First@DSolve[{pde, bc}, u[r, theta], {r, theta}];
sol = sol /. K[1] -> n;
sol = sol /. Infinity -> 50 (*more than enough terms*)
Plotting the solution with the BC together shows mismatch on some interval
Show[
ParametricPlot3D[{r Cos[theta], r Sin[theta], Activate[sol]}, {r, 0,
1}, {theta, 0, 2 Pi}, PlotStyle -> Opacity[.6],
BoxRatios -> {1, 1, 1}],
ParametricPlot3D[{r Cos[theta], r Sin[theta], bcf}, {r, 1 - 0.1,
1 + 0.1}, {theta, 0, 2 Pi}, PlotStyle -> Opacity[1],
BoxRatios -> {1, 1, 1}], PlotRange -> All
]
Now compare with NDSolve
for same PDE and same BC
solNumerical =
First@NDSolve[{pde, bc}, u, {r, 0, 1}, {theta, 0, 2 Pi}];
Show[
ParametricPlot3D[{r Cos[theta], r Sin[theta],
Evaluate[u[r, theta] /. solNumerical]}, {r, 0, 1}, {theta, 0,
2 Pi}, PlotStyle -> Opacity[1], BoxRatios -> {1, 1, 1}],
ParametricPlot3D[{r Cos[theta], r Sin[theta], bcf}, {r, 1 - 0.1,
1 + 0.1}, {theta, 0, 2 Pi}, PlotStyle -> Opacity[1],
BoxRatios -> {1, 1, 1}], PlotRange -> All
]
What is going on? Why DSolve
solution does not agree with BC? Did I make mistake somewhere?
V 12.3.1 on windows 10