I was trying to solve Laplace's equation for a spherical capacitor, which is not difficult by hand, just to figure out the commands so I can eventually try something more complicated. Then, I ran into trouble.
I tried to use spherical coordinates, and I got an error of a non real answer, or sometimes null.
leqn = ( Laplacian[V[r,\[Theta],\[Phi]],{r,\[Theta],\[Phi]},"Spherical" ] ==0 //Simplify)
a=1; b=10;
NDSolveValue[{leqn,V[a,\[Theta],\[Phi]]==1,V[b,\[Theta],\[Phi]]==0},V,{r,a,b},{\[Theta],0,\[Pi]},{\[Phi],0,2*\[Pi]}]
So I figured I'd try in Cartesian coordinates in order to figure out my error; it worked:
a=1;b=5
NDSolveValue[{Laplacian[u[x,y],{x,y}] == 0,
DirichletCondition[u[x,y] == 1,Sqrt[x^2+y^2] ==a ],
DirichletCondition[u[x,y] == 0,Sqrt[x^2+y^2] ==b]
}, u, {x, y} \[Element]Annulus[{0,0},{a,b}]]
Plot3D[%[x, y], {x, y} \[Element] Annulus[{0,0},{a,b}]]
But then if I try to be a little more explicit about the boundary conditions it stops working:
a=1;b=5
NDSolveValue[{Laplacian[u[x,y],{x,y}]== 0,
u[x,y] == If[Norm[{x,y}]==a,1],
DirichletCondition[u[x,y] == 0,Sqrt[x^2+y^2] ==b]
}, u, {x, y} \[Element]Annulus[{0,0},{a,b}]]
Plot3D[%[x, y], {x, y} \[Element] Annulus[{0,0},{a,b}]]
Anyway, I still can't figure out why the explicit form of the boundary condition didn't work.
Furthermore, I don't see why the polar version didn't work.
,0.
,0.`}" $\endgroup$