+
Chargesweeper (similar to Minesweeper)

Developed by Deva O'Neil - Published July 19, 2018

This project creates a game in which the user clicks on boxes that initially hide the electric field due to a distribution of point charges. As a piece of the field is revealed with each click, the users can guess where the charges are located. The student builds the physics behind the game, applying Coulomb's Law to calculate the correct electric field for the point charge distribution. This Exercise Set provides practice in constructing relative position vectors, unit vectors, and superposed fields.
Subject Area Electricity & Magnetism
Level First Year
Available Implementation Glowscript
Learning Objectives
* Construct the relative position vector that points from source to field point, given the position of the source and the field point (neither necessarily at the origin). (Exercise 1) * Calculate the unit vector for the relative position vector. (Exercise 2) * Calculate the E field due to a single point charge. (Exercise 3) * Apply the principle of superposition of charges to find the field of two or more charges. (Exercise 4)
Time to Complete 50-100 min

These exercises are not tied to a specific programming language. Example implementations are provided under the Code tab, but the Exercises can be implemented in whatever platform you wish to use (e.g., Excel, Python, MATLAB, etc.).

*Exercise 1* A positive charge is located at position $\vec{r}_s$. This charge is the source of an electric field that we are going to simulate with arrows. Our goal is to determine the E field at a point P, at position $\vec{r}_P = (x_P,y_P,z_P)$. This is called the "field point." The electric field at point $\vec{r}_P$ due to the source [charge] at $\vec{r}_s$ is $\vec{E} = \frac{k q\hat{r}}{r^2}$. The vector $\vec{r}$ points from the source to the field point. This program will be effectively two-dimensional, so we will take $z_P = z_S = 0.$ 1. Open the template for Exercise 1, which shows a sphere (representing charge) placed at a position $\vec{r}_s.$ The field point P is shown at $\vec{r}_P.$ The arrows represent the position vector of each. 2. Create an arrow that starts at the source (not the origin) and ends at the field point P. This arrow is the $r$ that appears in the equation for $\vec{E}$. 3. The electric field due to a positive charge should be in the same direction as $\vec{r}$. Looking at the arrow you've created, make sure that it is in the same direction as what you would expect for the E field at point P. *Exercise 2* 1. Once your arrow $\vec{r}$ is in the correct position, have your program calculate and print its magnitude (denoted |$\vec{r}$| or simply $r$). 2. The unit vector is defined as $\hat{r} = \vec{r}/r$. Create an arrow that represents $\hat{r}$. 3. What magnitude will any unit vector have? 4. Check your new arrow for plausibility (use print statements as needed). What should be true of its length? Of its direction? *Exercise 3* Start a new program with the template for Exercise 3. The goal is to create a game that is similar to Minesweeper. In Minesweeper, a grid of boxes hides a landmine, and the goal is to figure out the location of the mines by clicking on the boxes around them, without uncovering the mines themselves (which explode if they are uncovered). Here, we start with an electric field due to a distribution of point charges (the "mines"). As in minesweeper, the field is covered by a grid of boxes. ![](images/Chargesweeper/charges.PNG "") As a piece of the field is revealed with each click, the users can guess where the charges are located. 1. Run the program. Notice that clicking a box reveals a field arrow. The first click takes a few seconds to work, so be patient. 2. Notice that the field is not physically correct; it is just a constant field. Change the field so that it represents the electric field of a charge $q = 2\cdot 10^{-10} C$ (which can be represented as 2e-10). Hint: You'll need to define r and rhat, but rP and rS are already defined for you in the code. 3. Run your code and edit your program until a plausible result is obtained. 4. Predict how this visualization would be different if the charge was negative. Test your predictions. *Exercise 4* 1. Add a second point charge to the simulation. Adjust the electric field so that is the superposition of the E fields of the individual point charges. In other words, each box will still only have one arrow, with axis given by $\vec{E} = \vec{E_1}+\vec{E_2}$. 2. Check the output for plausibility: * What do you expect to see if the program happens to place the two charges at the same location? (You'll only see one sphere - but how will the arrows be affected?) * Test the situations where the two charges are the same sign * Test two opposite charges (color-code them so you know which is positive). _Optional_ * Add in functionality that prevents the two charges from being placed at the same grid point. (For those with programming experience.) * Play around with the number of grid points. If you have a large number of grid points, you may need to increase the scene range to accommodate all the boxes. You also may want to add more charges. * Since the actual game Minesweeper stops the game when a mine is triggered, you could have the program stop if the user clicks a charge and show a notification that the game is lost. As written, all the template does is turn that grid point yellow when the mine is triggered. This is boring - can you make the triggering of a mine more exciting? Make everything explode or something?

Download Options

Share a Variation

Did you have to edit this material to fit your needs? Share your changes by Creating a Variation

Credits and Licensing

Deva O'Neil, "Chargesweeper (similar to Minesweeper)," Published in the PICUP Collection, July 2018.

The instructor materials are ©2018 Deva O'Neil.

The exercises are released under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 license

Creative Commons Attribution-NonCommercial-ShareAlike 4.0 license