Activity: 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.
Consider a square sheet of charge with side \(L\) and uniform charge density \(\sigma\).

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
  1. 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?”
  2. Omitting an \(=\) so they don't have an equation. “That doesn't mean anything. It can't be true or false.”

  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.

    1. Many students will need to be told to write down the integral on paper first.
    2. 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.
    3. 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.
    4. 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” (or float) works well.

  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.

    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.

  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.
  • 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)

    electrostatic potential python

    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.
  • keyboard Mean position

    keyboard Computational Activity

    120 min.

    Mean position
    Computational Physics Lab II 2023 (2 years)

    probability density particle in a box wave function quantum mechanics

    Students compute probabilities and averages given a probability density in one dimension. This activity serves as a soft introduction to the particle in a box, introducing all the concepts that are needed.
  • keyboard Electrostatic potential of spherical shell

    keyboard Computational Activity

    120 min.

    Electrostatic potential of spherical shell
    Computational Physics Lab II 2022

    electrostatic potential spherical coordinates

    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.
  • assignment ISW Position Measurement

    assignment Homework

    ISW Position Measurement
    time evoluation infinite square well Quantum Fundamentals 2023

    A particle in an infinite square well potential has an initial state vector \[\left|{\Psi(0)}\right\rangle = A\big(\left|{\phi_1}\right\rangle -\left|{\phi_2}\right\rangle +i\left|{\phi_3}\right\rangle \big)\]

    where \(|\phi_n\rangle\) are the energy eigenstates. You have previously found \(\left|{\Psi(t)}\right\rangle \) for this state.

    1. Use a computer to graph the wave function \(\Psi(x,t)\) and probability density \(\rho(x,t)\). Choose a few interesting values of \(t\) to include in your submission.

    2. Use a computer to calculate the probability of measuring the particle to be near the middle of the well (within 1% on either side) as a function of time. Include both your symbolic result and a graph in your submission.

    3. Choose another location in the well, different from the location above. Use a computer to calculate the probability of measuring the particle to be near your chosen location (within 1% on either side) as a function of time. Include both your symbolic result and a graph in your submission.

    4. Are there any locations in the well where the probability is independent of time? Explain how you determined your answer.

    5. The time dependence for a wave function like this is complicated. Write a lengthy description in words about the major features of this wave function and its probability density, how they change in time, and why they change the way they do. Comment on any interesting features you noticed that you have not already discussed in the questions above and describe any additional things you learned from the process of solving this problem.

  • keyboard Sinusoidal basis set

    keyboard Computational Activity

    120 min.

    Sinusoidal basis set
    Computational Physics Lab II 2023 (2 years)

    inner product wave function quantum mechanics particle in a box

    Students compute inner products to expand a wave function in a sinusoidal basis set. This activity introduces the inner product for wave functions, and the idea of approximating a wave function using a finite set of basis functions.
  • group Representations of the Infinite Square Well

    group Small Group Activity

    120 min.

    Representations of the Infinite Square Well
    Quantum Fundamentals 2023 (3 years)

    Warm-Up

  • assignment Fourier Series for the Ground State of a Particle-in-a-Box.

    assignment Homework

    Fourier Series for the Ground State of a Particle-in-a-Box.
    Oscillations and Waves 2023 (2 years) Treat the ground state of a quantum particle-in-a-box as a periodic function.
    • Set up the integrals for the Fourier series for this state.

    • Which terms will have the largest coefficients? Explain briefly.

    • Are there any coefficients that you know will be zero? Explain briefly.

    • Using the technology of your choice or by hand, calculate the four largest coefficients. With screen shots or otherwise, show your work.

    • Using the technology of your choice, plot the ground state and your approximation on the same axes.
  • assignment Wavefunctions

    assignment Homework

    Wavefunctions
    Quantum Fundamentals 2023 (3 years)

    Consider the following wave functions (over all space - not the infinite square well!):

    \(\psi_a(x) = A e^{-x^2/3}\)

    \(\psi_b(x) = B \frac{1}{x^2+2} \)

    \(\psi_c(x) = C \;\mbox{sech}\left(\frac{x}{5}\right)\) (“sech” is the hyperbolic secant function.)

    In each case:

    1. normalize the wave function,
    2. plot the wave function using Mathematica or other computer plotting tool (be sure to include the code you used and label your plots/axes appropriately),
    3. find the probability that the particle is measured to be in the range \(0<x<1\).

  • keyboard Position operator

    keyboard Computational Activity

    120 min.

    Position operator
    Computational Physics Lab II 2022

    quantum mechanics operator matrix element particle in a box eigenfunction

    Students find matrix elements of the position operator \(\hat x\) in a sinusoidal basis. This allows them to express this operator as a matrix, which they can then numerically diagonalize and visualize the eigenfunctions.
  • assignment One-dimensional gas

    assignment Homework

    One-dimensional gas
    Ideal gas Entropy Tempurature Thermal and Statistical Physics 2020 Consider an ideal gas of \(N\) particles, each of mass \(M\), confined to a one-dimensional line of length \(L\). The particles have spin zero (so you can ignore spin) and do not interact with one another. Find the entropy at temperature \(T\). You may assume that the temperature is high enough that \(k_B T\) is much greater than the ground state energy of one particle.

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