Student handout: Electrostatic potential and Electric Field of a square of charge

Computational Physics Lab II 2023
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.
Consider a square sheet of charge with side \(L\) and uniform charge density \(\sigma\).
  1. Write a python function that discretizes a charged square into a sauqre of point charges. Make sure the python function maintians the total charge constant.
  2. Write a python function that returns the electrostatic potential from your discretized charge distribution at an arbitrary point in space.
  3. Once you have written the above function, use it to plot the electrostatic potential versus position in the three cartesian directions.
  4. Label your axes.
  5. On the same figures, plot the potential due to a point charge located at the center of the square, with the same charge as the square (in total). This potential should very closely match your computed potential at distances which are not all that far from your square.
  6. Make a 2D contour plot of the equipotential lines in the \(z=0\) plane.
  7. Write a python function that computes the three components of the electric field vector using \(\vec{E}(\vec{r})=\frac{1}{4\pi\epsilon_0}\frac{q}{\lVert\vec{r}\rVert^2}\frac{\vec{r}}{\lVert\vec{r}\rVert^2}\)
  8. Compute the electric field vector at a position through which one of your contur level passes and visualize it with an arrow.
  9. Compute the electric field vector as \(\vec{E}(\vec{r})=-\nabla V(\vec{r})\) and plot it on your graph. What do you notice about teh two electric field vectors? What is their relationship with the equipotential line?
More fun
What happens when you change the number of grid points used to perform the integral?
Subtle fun
What do you expect your potential to look like close to the center of the square of charge? See if you can make a prediction using Gauss's Law, if you can remember it from your introductory physics. With or without a prediction, you can examine the behavior close to the center of the square of charge.
Evan more fun
Try a different charge distribution, for example a hollow sphere.

Keywords
integration electrostatic potential surface charge density
Learning Outcomes