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.
Be aware that pairs may take an hour or more to simply write down the integral that they need to solve. When this happens, remember that it means that the students are getting valuable practice at a skill that is most necessary for them to learn as a physicist!
Issues on paper
- We want students to always write \(V(x,y,z)\) or \(V(\vec r)\) or similar on the left side of an equation like \(V=\int\cdots\). Ask students “\(V\) of what?” or “where is that potential?”
- Omitting an \(=\) so they don't have an equation. “That doesn't mean anything. It can't be true or false.”
Write a python function that returns the electrostatic potential from your discretized charge distribution at an arbitrary point in space.
- Many students will need to be told to write down the integral on paper first.
- We also want to proactively look for students using
scipy
quadrature (i.e. numerical integration) functions, and ask them to not use those functions, but instead to program the computation by hand.- When students are confused as to how to do an integral numerically, ask then what an integral really is, and after a few statements they may get to either Riemann sums or chopping and adding, and either way works well. One can also think of it as treating the sheet as if it were a whole bunch of point charges.
- Another common student challenge here is wanting to use the
range
function with non-integer inputs. You can point out this error, and ask what they might google to find a better function. Something like “python range non-integer” (orfloat
) works well.
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.
The most frequent bug is to omit the dx
in the integral, and this reveals itself when they do this comparison, but often students don't even notice. They think it agrees because both curves approach zero. So you need to actually look and inform them that there is a problem.