Students solve numerically for the potential due to a spherical shell of charge. Although this potential is straightforward to compute using Gauss's Law, it serves as a nice example for numerically integrating in spherical coordinates because the correct answer is easy to recognize.
The integral needs to be done in spherical coordinates. The point where the potential is evaluated can be given in either rectangular or shperical coordinates. Life is easier if it's given in rectangular, but most students use spherical.
The hard things here are to find the distance between the two points, and to remember how to find the small chunk of area.
Also remembering to specify where they are finding the potential. i.e. we frequently see things like: \begin{align} V &= \int_0^{\pi}\int_{0}^{2\pi} \frac{k\sigma}{\sqrt{R^2+r^2-2rR(\cos\theta\cos\theta' +\sin\theta\sin\theta'\cos(\phi-\phi'))}} R^2\sin\theta d\phi d\theta \end{align} where it's not clear or consistent which thing has the primes. We try to emphasize to the class that it is essential to write \(V(r,\phi,\theta)\) (or whatever) on the left hand side of the equations. It's also common to have no equals sign at all, which is of course even worse.
It is very common at this point is to use negative \(r\) values when plotting the potential e.g. as a function of \(x\). This does give correct plots, but is also a bit weird. At this stage, we should probably let it pass.
You will probably also find students expecting the potential to be zero inside the sphere, because they know the electric field is zero inside a solid sphere. I think it's worth engaging with students who think this, asking if the potential is continuous at the surface (if not, then the electric field must be infinite), and bringing them towards remembering that the potential is the integral of the electric field.
It is common at this stage for students to still believe that where there is charge the potential should be infinite. Looking at their numerical results can sometimes help, but it is also helpful to ask students why they think the potential should be infinite. One can then bring in Gauss's Law (if it has been covered) to help clear up why the electric field is infinite for a point charge, and not for a planar charge distribution.
Creating a 2D plot (acontourf
or apcolor
is a bit challenging if their \(V\) takes spherical coordinates. The simplest approach in this case is to define anX, Y = np.meshgrid(x,y)
and then compute the spherical coordinates from those using arc-trig. To do this correctly almost requiresarctan2
.
This is a great way to discover that there were bugs in the visualization, e.g. usingarctan
rather thanarctan2
. I'd rather enable students to discover that they have bugs using symmetry if at all possible.