## Activity: Electrostatic potential of spherical shell

Computational Physics Lab II 2022
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.
Now consider a spherical shell of charge with uniform surface charge density $\sigma$.
1. Decide which coordinate system to use for the point where you are asking the potential, and which coordinate system to use for locating your point on the surface.
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.
2. Write down on paper an integral to find the potential.

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.

3. Write a python function $V(\vec r)$ that returns the electrostatic potential at a specified point in space.
4. Once you have written the above function, use it to plot the electrostatic potential versus position in the three cartesian directions.

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.

5. Show (by plotting) that your potential at large distances converges to the potential of a point charge with the same total charge as your sphere.
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.
6. Try constructing other visualizations.
Creating a 2D plot (a contourf or a pcolor is a bit challenging if their $V$ takes spherical coordinates. The simplest approach in this case is to define an X, Y = np.meshgrid(x,y) and then compute the spherical coordinates from those using arc-trig. To do this correctly almost requires arctan2.
Extra fun
Modify your code to find the potential of one octant of a spherical shell (e.g. the portion when $x>0$ and $y>0$ and $z>0$). Do your visualizations still all make sense?
This is a great way to discover that there were bugs in the visualization, e.g. using arctan rather than arctan2. I'd rather enable students to discover that they have bugs using symmetry if at all possible.
Solid fun
Try a solid sphere of charge only if you have done all the tasks above. How does it behave inside the sphere?
• assignment Gravitational Field and Mass

assignment Homework

##### Gravitational Field and Mass
Static Fields 2023 (5 years)

The gravitational field due to a spherical shell of matter (or equivalently, the electric field due to a spherical shell of charge) is given by: \begin{equation} \vec g = \begin{cases} 0&\textrm{for } r<a\\ -G \,\frac{M}{b^3-a^3}\, \left( r-\frac{a^3}{r^2}\right)\, \hat r & \textrm{for } a<r<b\\ -G\,\frac{M}{r^2}\, \hat r & \textrm{for } r>b \\ \end{cases} \end{equation}

This problem explores the consequences of the divergence theorem for this shell.

1. Using the given description of the gravitational field, find the divergence of the gravitational field everywhere in space. You will need to divide this question up into three parts: $r<a$, $a<r<b$, and $r>b$.
2. Briefly discuss the physical meaning of the divergence in this particular example.
3. For this gravitational field, verify the divergence theorem on a sphere, concentric with the shell, with radius $Q$, where $a<Q<b$. ("Verify" the divergence theorem means calculate the integrals from both sides of the divergence theorem and show that they give the same answer.)
4. Briefly discuss how this example would change if you were discussing the electric field of a uniformly charged spherical shell.

• group Total Charge

group Small Group Activity

30 min.

##### Total Charge
Static Fields 2023 (6 years)

Integration Sequence

In this small group activity, students integrate over non-uniform charge densities in cylindrical and spherical coordinates to calculate total charge.
• group Equipotential Surfaces

group Small Group Activity

120 min.

##### Equipotential Surfaces

Students are prompted to consider the scalar superposition of the electric potential due to multiple point charges. First a single point charge is discussed, then four positive charges, then an electric quadrupole. Students draw the equipotential curves in the plane of the charges, while also considering the 3D nature of equipotentials.
• assignment Electric Field and Charge

assignment Homework

##### Electric Field and Charge
divergence charge density Maxwell's equations electric field Static Fields 2023 (4 years) Consider the electric field \begin{equation} \vec E(r,\theta,\phi) = \begin{cases} 0&\textrm{for } r<a\\ \frac{1}{4\pi\epsilon_0} \,\frac{Q}{b^3-a^3}\, \left( r-\frac{a^3}{r^2}\right)\, \hat r & \textrm{for } a<r<b\\ 0 & \textrm{for } r>b \\ \end{cases} \end{equation}
1. Use step and/or delta functions to write this electric field as a single expression valid everywhere in space.
2. Find a formula for the charge density that creates this electric field.
3. Interpret your formula for the charge density, i.e. explain briefly in words where the charge is.
• assignment Spherical Shell Step Functions

assignment Homework

##### Spherical Shell Step Functions
step function charge density Static Fields 2023 (6 years)

One way to write volume charge densities without using piecewise functions is to use step $(\Theta)$ or $\delta$ functions. If you need to review this, see the following link in the math-physics book: https://paradigms.oregonstate.eduhttps://books.physics.oregonstate.edu/GMM/step.html

Consider a spherical shell with charge density $\rho (\vec{r})=\alpha3e^{(k r)^3}$ between the inner radius $a$ and the outer radius $b$. The charge density is zero everywhere else. Use step functions to write this charge density as a single function valid everywhere in space.

• keyboard Electrostatic potential of four point charges

keyboard Computational Activity

120 min.

##### Electrostatic potential of four point charges
Computational Physics Lab II 2023 (2 years)

Students write python programs to compute and visualize the potential due to four point charges. For students with minimal programming ability and no python experience, this activity can be a good introduction to writing code in python using numpy and matplotlib.
• group Gravitational Potential Energy

group Small Group Activity

60 min.

##### Gravitational Potential Energy

Students examine a plastic “surface” graph of the gravitational potential energy of an Earth-satellite system to explore the properties of gravitational potential energy for a spherically symmetric system.
• keyboard Electrostatic potential and Electric Field of a square of charge

keyboard Computational Activity

120 min.

##### Electrostatic potential and Electric Field of a square of charge
Computational Physics Lab II 2023 (2 years)

Students write python programs to compute the potential due to a square of surface charge, and then to visualize the result. This activity can be used to introduce students to the process of integrating numerically.
• assignment Total Charge

assignment Homework

##### Total Charge
charge density curvilinear coordinates

Integration Sequence

Static Fields 2023 (6 years)

For each case below, find the total charge.

1. A positively charged (dielectric) spherical shell of inner radius $a$ and outer radius $b$ with a spherically symmetric internal charge density \begin{equation} \rho(\vec{r})=3\alpha\, e^{(kr)^3} \end{equation}
2. A positively charged (dielectric) cylindrical shell of inner radius $a$ and outer radius $b$ with a cylindrically symmetric internal charge density \begin{equation} \rho(\vec{r})=\alpha\, \frac{1}{s}\, e^{ks} \end{equation}

• face Central Forces Introduction Lecture Notes

face Lecture

5 min.

##### Central Forces Introduction Lecture Notes
Central Forces 2022

Learning Outcomes
• ph366: 1) Write functions and entire programs in python
• ph366: 2) Apply the python programming language to solve scientific problems
• ph366: 3) Use the matplotlib and numpy packages
• ph366: 4) Model the physical systems studied in the course