E Field Superposition

Activity Information

Learning Goals

  • Develop models of the electric field from various uniform distributions of charge
  • Understand superposition and how it relates to electric fields
  • Understand the utility of computation

Prior Knowledge Required

  • Vectors
  • Electric Field from a Point Charge
  • For loop syntax in python

Code Manipulation

  • Interpret existing code
  • create new code from mathematical equations

Activity

Handout – Super Superposition

handout  

The Mid-Michigan paranormal society has recently come into the possession of four strange objects: a ring, a collection of rings, a square plate and a cube. They think that these objects may have supernatural properties, but they’ve hired you to put this to the test with your physics knowledge.

After running several tests, you’ve found that these objects appeared to be supernatural because they all have 9E-10 C of charge spread out evenly across them, which creates an electric field. The paranormal society is dubious of your claims and has requested that you create models of the electric field from each distribution.

Here’s what you have so far for each distribution:

Ring

Rings

Square Plate

Cube

When the codes are complete, they should produce an arrow that represents the electric field vector at its location.

Hint: Try developing a general code that will work for all of the distributions. You’ll have to add up the E Field from all of the dq spheres.

Post-Coding Questions

  1. What’s different between the four starter codes? What’s the same?
  2. How are you using superposition?
  3. These codes are approximate models. How could you make them more accurate?
  4. What is the purpose of the following line of code:
dq = q/len(qlist)

5. Try moving around the location where the arrow is being created. What do you observe?

Optional bonus problem:
Modify one of your codes so that it creates several E-Field arrows, in any shape you would like.

Code

Ring

GlowScript 3.1 VPython

dtheta = pi/8
theta = 0
r = 1
q = 9e-10
loop = ring(pos = vec(0,0,0), radius = r,thickness = 0.05*r, axis = vec(0,0,1), color = color.yellow)
qlist = []

while theta < 2*pi:
  dq = sphere(pos = vec(r*cos(theta),r*sin(theta),0),radius = r*0.1, color = color.red)
  qlist.append(dq)
  theta = theta + dtheta

dq = q/len(qlist)
k = 9e9
E = vec(0,0,0)

obs = vec(0,0,0.1)
obssphere = sphere(pos = obs, radius = 0.01)



Earrow = arrow(pos = obs, axis = E, color = color.cyan)

Rings

GlowScript 3.1 VPython

dtheta = pi/8
theta = 0
z = 0
dz = 1

r = 1
q = 9e-10

qlist = []

while z < 5:
  theta = 0
  loop = ring(pos = vec(0,0,z), radius = r,thickness = 0.05*r, axis = vec(0,0,1), color = color.yellow)
  while theta < 2*pi:
    dq = sphere(pos = vec(r*cos(theta),r*sin(theta),z),radius = r*0.1, color = color.red)
    qlist.append(dq)
    theta = theta + dtheta
  z = z + dz
  
dq = q/len(qlist)
k = 9e9
E = vec(0,0,0)

obs = vec(0,0,0)
obssphere = sphere(pos = obs, radius = 0.01)


  
Earrow = arrow(pos = obs, axis = E, color = color.cyan)

Plate

GlowScript 3.1 VPython

scene.center = vec(0,0,0) # view stuff, might need to mess around with it to get it to look right
scene.range = 3

y = -2
x = -2
dy = 1
dx = 1

plate = box(pos = vec(0,0,0), size = vec(4,4,0.05), color = color.yellow)
r = 1
q = 9e-10

qlist = []

while x <= 2:
  y = -2
  while y <= 2:
    dq = sphere(pos = vec(x,y,0),radius = r*0.1, color = color.red)
    qlist.append(dq)
    y = y + dy
  x = x + dx
  
dq = q/len(qlist)
k = 9e9
E = vec(0,0,0)

obs = vec(0,0,1)
obssphere = sphere(pos = obs, radius = 0.01)


  
Earrow = arrow(pos = obs, axis = E, color = color.cyan)

Cube

GlowScript 3.1 VPython

scene.center = vec(0,0,0) # view stuff, might need to mess around with it to get it to look right
scene.range = 5

dtheta = pi/8
theta = 0
y = -2
x = -2
z = -2
dy = 1
dx = 1
dz = 1

plate = box(pos = vec(0,0,0), size = vec(4,4,4), color = color.yellow, opacity = 0.8)
r = 1
q = 9e-10

qlist = []

while x <= 2:
  y = -2
  while y <= 2:
    z = -2
    while z <= 2:
      
      dq = sphere(pos = vec(x,y,z),radius = r*0.1, color = color.red)
      qlist.append(dq)
      z = z + dz
    y = y + dy
  x = x + dx
  
dq = q/len(qlist)
k = 9e9
E = vec(0,0,0)

obs = vec(0,2,2.5)
obssphere = sphere(pos = obs, radius = 0.01)


  
Earrow = arrow(pos = obs, axis = E, color = color.cyan)

Answer Key

Handout

Though this problem may seem daunting, with 4 different distributions, the same few lines can be used to solve all of them.

These lines will loop over all of the dq charges in qlist, and add up the E field contribution at the observer location from each one. This loop will go between the obssphere and Earrow lines in each starter code.

First, we can start with a for loop that loops over qlist:

for charge in qlist:

Now we need the separation vector that points from each bit of charge to the observer location, which is given by the equation:

In the code, this looks like:

for charge in qlist:
  rsep = obs - charge.pos

Next, we can add the equation for the electric field from a point charge, which is:

In the code:

for charge in qlist:
  rsep = obs - charge.pos
  E = k*dq*rsep/(mag(rsep)**3)

Finally, we need to make sure we are adding up the E field from each bit of charge:

for charge in qlist:
  rsep = obs - charge.pos
  E = E + k*dq*rsep/(mag(rsep)**3)

Or equivalently:

for charge in qlist:
  rsep = obs - charge.pos
  E += k*dq*rsep/(mag(rsep)**3)

Adding this bit of code to each of the starter codes completes the coding portion of this problem.

Post-Coding Questions:

  1. Each starter code is putting the total charge in different arrangements, the yellow object represents the object itself and the red spheres represent the point particles of charge we are using to create an approximation. Otherwise, the starter codes are identical.
  2. Here we are using superposition by adding up the E field from each red sphere.
  3. We could increase the accuracy of these models by increasing the number of red spheres we are using to approximate the true object. To do this in the code, we would make the values of dtheta, dx,dy, etc. smaller.
  4. This line of code is ensuring that each red sphere has an equal amount of charge, and that the total charge will add up to 9E-10 C.
  5. Answers will vary.

Code

Ring

GlowScript 3.1 VPython

dtheta = pi/8
theta = 0
r = 1
q = 9e-10
loop = ring(pos = vec(0,0,0), radius = r,thickness = 0.05*r, axis = vec(0,0,1), color = color.yellow)
qlist = []

while theta < 2*pi:
  dq = sphere(pos = vec(r*cos(theta),r*sin(theta),0),radius = r*0.1, color = color.red)
  qlist.append(dq)
  theta = theta + dtheta

dq = q/len(qlist)
k = 9e9
E = vec(0,0,0)

obs = vec(0,0,0.1)
obssphere = sphere(pos = obs, radius = 0.01)

for charge in qlist:
  rsep = obs - charge.pos
  E = E + k*dq*rsep/(mag(rsep)**3)
  
Earrow = arrow(pos = obs, axis = E, color = color.cyan)

Rings

GlowScript 3.1 VPython

dtheta = pi/8
theta = 0
z = 0
dz = 1

r = 1
q = 9e-10

qlist = []

while z < 5:
  theta = 0
  loop = ring(pos = vec(0,0,z), radius = r,thickness = 0.05*r, axis = vec(0,0,1), color = color.yellow)
  while theta < 2*pi:
    dq = sphere(pos = vec(r*cos(theta),r*sin(theta),z),radius = r*0.1, color = color.red)
    qlist.append(dq)
    theta = theta + dtheta
  z = z + dz
  
dq = q/len(qlist)
k = 9e9
E = vec(0,0,0)

obs = vec(0,0,0)
obssphere = sphere(pos = obs, radius = 0.01)

for charge in qlist:
  rsep = obs - charge.pos
  E = E + k*dq*rsep/(mag(rsep)**3)
  
Earrow = arrow(pos = obs, axis = E, color = color.cyan)

Plate

GlowScript 3.1 VPython

scene.center = vec(0,0,0) # view stuff, might need to mess around with it to get it to look right
scene.range = 3

y = -2
x = -2
dy = 1
dx = 1

plate = box(pos = vec(0,0,0), size = vec(4,4,0.05), color = color.yellow)
r = 1
q = 9e-10

qlist = []

while x <= 2:
  y = -2
  while y <= 2:
    dq = sphere(pos = vec(x,y,0),radius = r*0.1, color = color.red)
    qlist.append(dq)
    y = y + dy
  x = x + dx
  
dq = q/len(qlist)
k = 9e9
E = vec(0,0,0)

obs = vec(0,0,1)
obssphere = sphere(pos = obs, radius = 0.01)

for charge in qlist:
  rsep = obs - charge.pos
  E = E + k*dq*rsep/(mag(rsep)**3)
  
Earrow = arrow(pos = obs, axis = E, color = color.cyan)

Cube

GlowScript 3.1 VPython

scene.center = vec(0,0,0) # view stuff, might need to mess around with it to get it to look right
scene.range = 5

dtheta = pi/8
theta = 0
y = -2
x = -2
z = -2
dy = 1
dx = 1
dz = 1

plate = box(pos = vec(0,0,0), size = vec(4,4,4), color = color.yellow, opacity = 0.8)
r = 1
q = 9e-10

qlist = []

while x <= 2:
  y = -2
  while y <= 2:
    z = -2
    while z <= 2:
      
      dq = sphere(pos = vec(x,y,z),radius = r*0.1, color = color.red)
      qlist.append(dq)
      z = z + dz
    y = y + dy
  x = x + dx
  
dq = q/len(qlist)
k = 9e9
E = vec(0,0,0)

obs = vec(0,2,2.5)
obssphere = sphere(pos = obs, radius = 0.01)

for charge in qlist:
  rsep = obs - charge.pos
  E = E + k*dq*rsep/(mag(rsep)**3)
  
Earrow = arrow(pos = obs, axis = E, color = color.cyan)