## Activity: Electrostatic potential of four point charges

Computational Physics Lab II 2022
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.
This is a great first programming activity.
Consider a system consisting of four point charges arranged on the corners of a square.
1. Write a python function that returns the potential at any point in space caused by four equal point charges forming a square.

To do this you will need the expression for a the potential due to a single point charge $V= \frac{k_Cq}{r}$ where $r$ is the distance from the point charge. You will also need to use the fact that the total potential is the sum of the potentials due to each individual point charge.

It is important that we ask students first to create a function for the potential, and only then try to visualize the potential. This allows students to reason about the computation for a single point in space (defined in their choice of coordinate systems).

2. Once you have written the above function, use it to plot the electrostatic potential versus position along the three cartesian axes.

Since the students have already written a function for their potential, they can create a plot by creating an array for $x$ (or $y$, or $z$), and then passing that array to their function, along with scalars for the other two coordinates. Many students will discover this simply by modifying an example script they find on the web, replacing $\sin(x)$ or similar with their function. It is well worth showing this easier approach to students who attempt who attempt to write a loop in order to compute the potential at each point in space.

We ask students to explicitly plot the potential along axes because students seldom spontaneously think to create a 1D plot such as this.

3. Label your axes.
4. Work out the first non-zero term in a power series approximation for the potential at large $x$, small $x$, etc. Plot these approximations along with your computed potential, and verify that they agree in the range that you expect.

This may need to be omitted on the first Tuesday of class, since students probably will not yet have seen power series approximations. It may work in this case to at least talk about what is expected at large distance, since "it looks like a point charge" is reasoning students do make.

Students struggle with the $x$ approximations (assuming the square is in the xy plane). Each pair will probably need to have a little lecture on grouping terms according to the power of $x$, and keeping only those terms for which they have every instance.

Extra fun
Create one or more different visualizations of the electrostatic potential.
Dipole fun
Repeat the above (especially the limiting cases!) for four point charges in which half are positive and half negative, with the positive charges neighbors.
Common visualizations for 2D slices of space include contour plots, color plots, and "3D plots". Another option (less easy) would be to visualize an equipotential surface in 3 dimensions. It is worth reminding students to consider other planes than those at $x=0$, $y=0$, and $z=0$.
Repeat the above (especially the limiting cases!) for four point charges in which half are positive and half negative, with the positive charges diagonal from one another. It will help in this case to place the charges on the axes (rotating the square by 45 degrees), since otherwise the potential on each axis will be zero.
• keyboard Electrostatic potential of spherical shell

keyboard Computational Activity

120 min.

##### 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.
• keyboard Electrostatic potential of a square of charge

keyboard Computational Activity

120 min.

##### Electrostatic potential of a square of charge
Computational Physics Lab II 2022

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 Linear Quadrupole (w/o series)

assignment Homework

##### Linear Quadrupole (w/o series)
Static Fields 2022 (3 years) Consider a collection of three charges arranged in a line along the $z$-axis: charges $+Q$ at $z=\pm D$ and charge $-2Q$ at $z=0$.
1. Find the electrostatic potential at a point $\vec{r}$ on the $x$-axis at a distance $x$ from the center of the quadrupole.

2. A series of charges arranged in this way is called a linear quadrupole. Why?

• group Magnetic Vector Potential Due to a Spinning Charged Ring

group Small Group Activity

30 min.

##### Magnetic Vector Potential Due to a Spinning Charged Ring
Static Fields 2022 (5 years)

Power Series Sequence (E&M)

Ring Cycle Sequence

Students work in groups of three to use the superposition principle $\vec{A}(\vec{r}) =\frac{\mu_0}{4\pi}\int\frac{\vec{J}(\vec{r}^{\,\prime})}{\vert \vec{r}-\vec{r}^{\,\prime}\vert}\, d\tau^{\prime}$ to find an integral expression for the magnetic vector potential, $\vec{A}(\vec{r})$, due to a spinning ring of charge.

In an optional extension, students find a series expansion for $\vec{A}(\vec{r})$ either on the axis or in the plane of the ring, for either small or large values of the relevant geometric variable. Add an extra half hour or more to the time estimate for the optional extension.

• assignment Linear Quadrupole (w/ series)

assignment Homework

##### Linear Quadrupole (w/ series)

Power Series Sequence (E&M)

Static Fields 2022 (5 years)

Consider a collection of three charges arranged in a line along the $z$-axis: charges $+Q$ at $z=\pm D$ and charge $-2Q$ at $z=0$.

1. Find the electrostatic potential at a point $\vec{r}$ in the $xy$-plane at a distance $s$ from the center of the quadrupole. The formula for the electrostatic potential $V$ at a point $\vec{r}$ due to a charge $Q$ at the point $\vec{r'}$ is given by: $V(\vec{r})=\frac{1}{4\pi\epsilon_0} \frac{Q}{\vert \vec{r}-\vec{r'}\vert}$ Electrostatic potentials satisfy the superposition principle.
2. Assume $s\gg D$. Find the first two non-zero terms of a power series expansion to the electrostatic potential you found in the first part of this problem.

• 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.
• group Magnetic Field Due to a Spinning Ring of Charge

group Small Group Activity

30 min.

##### Magnetic Field Due to a Spinning Ring of Charge
Static Fields 2022 (6 years)

Power Series Sequence (E&M)

Ring Cycle Sequence

Students work in groups of three to use the Biot-Savart law $\vec{B}(\vec{r}) =\frac{\mu_0}{4\pi}\int\frac{\vec{J}(\vec{r}^{\,\prime})\times \left(\vec{r}-\vec{r}^{\,\prime}\right)}{\vert \vec{r}-\vec{r}^{\,\prime}\vert^3} \, d\tau^{\prime}$ to find an integral expression for the magnetic field, $\vec{B}(\vec{r})$, due to a spinning ring of charge.

In an optional extension, students find a series expansion for $\vec{B}(\vec{r})$ either on the axis or in the plane of the ring, for either small or large values of the relevant geometric variable. Add an extra half hour or more to the time estimate for the optional extension.

• group Electrostatic Potential Due to a Pair of Charges (without Series)

group Small Group Activity

30 min.

##### Electrostatic Potential Due to a Pair of Charges (without Series)
Static Fields 2022 (3 years) Students work in small groups to use the superposition principle $V(\vec{r}) = \frac{1}{4\pi\epsilon_0}\sum_i \frac{q_i}{\vert\vec{r}-\vec{r}_i\vert}$ to find the electrostatic potential $V$ everywhere in space due to a pair of charges (either identical charges or a dipole). This activity can be paired with activity 29 to find the limiting cases of the potential on the axes of symmetry.
• group Electric Field Due to a Ring of Charge

group Small Group Activity

30 min.

##### Electric Field Due to a Ring of Charge
Static Fields 2022 (7 years)

Power Series Sequence (E&M)

Ring Cycle Sequence

Students work in groups of three to use Coulomb's Law $\vec{E}(\vec{r}) =\frac{1}{4\pi\epsilon_0}\int\frac{\rho(\vec{r}^{\,\prime})\left(\vec{r}-\vec{r}^{\,\prime}\right)}{\vert \vec{r}-\vec{r}^{\,\prime}\vert^3} \, d\tau^{\prime}$ to find an integral expression for the electric field, $\vec{E}(\vec{r})$, everywhere in space, due to a ring of charge.

In an optional extension, students find a series expansion for $\vec{E}(\vec{r})$ either on the axis or in the plane of the ring, for either small or large values of the relevant geometric variable. Add an extra half hour or more to the time estimate for the optional extension.

• computer Using Technology to Visualize Potentials

computer Mathematica Activity

30 min.

##### Using Technology to Visualize Potentials
Static Fields 2022 (5 years)

Begin by prompting the students to brainstorm different ways to represent a three dimensional scalar field on a 2-D surface (like their paper or a whiteboard). The students use a pre-made Sage code or a Mathematica worksheet to visualize the electrostatic potential of several distributions of charges. The computer algebra systems demonstrates several different ways of plotting the potential.

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