Mapping the Electric Field and Stuff

This is really a note for Future Rhett. You’re welcome, Future Rhett. If anyone else wants to read this, please have fun.

OK, here is the problem. How do you describe the electric field around some region? Maybe that region is a dipole, or parallel plates, or some other random charge distribution?

Here are some options:

  • Equipotential lines. I assume you know what these are.
  • Electric field lines.
  • Electric field vector plot.

Let’s talk about these three. I don’t think I’m going to make example plots because I’m not sure what I want to do. Yes, I will probably do something in the near future.

Electric Field Vector Plot

Imagine you have a dipole (a positive and negative charge separated by some distance). The electric field vector can be calculated at any position (x,y,z). So for every location, there’s a vector.

But how do you display this visually? Well, you could just pick some points and plot the electric field as an arrow. Actually, I’ve done this before so I have a picture.

Image result for rhett allain dipole

Another option is to just plot the E field every cm (or some other set distance). Of course, this too has problems:

  • What about 3D?
  • What if the electric field gets too big and you have giant arrows?
  • What if the arrows are too small?
  • Can you do this on paper?

Still, I think this is probably the best option. Historically, no one ever did it this way because you pretty much need a computer to draw all those tiny arrows.

Equipotential Lines

I want to draw a picture here. OK, this is just a rough sketch.

Each of these lines represents a series of points at the same electric potential (with respect to infinity). They are fairly easy to draw and they give a good representation of the field—even though they aren’t the field. It’s just like getting the idea of a the shape of a mountain by looking at a topographical map. It’s the same thing.

How would you create these with a computer? That’s really what I want—that will make it useful for some strange charge distribution that you would have to calculate the field using a numerical calculation. Here’s what I would do:

  • Decide on the voltage line values. Do I want to do every volt or every 0.1 volts?
  • Pick a point. I don’t know where you would start—maybe near one of the charges?
  • Calculate the electric potential. I assume it’s not an even value of the potential lines. If you get 5.5 volts, you want to move down to 5 volts.
  • Now move in some direction. Check the voltage again. Did it go down? Keep moving that way. If it goes up, go the other way. If it didn’t change, turn 90 degrees.
  • Once you get to 5 volts, plot a point.
  • Move again, but find another point that is at 5 volts. Plot it.
  • Keep doing this until you get some set distance away from the starting point or you get back to the starting point.

This seems unnecessarily complicated. There’s got to be a better way. Figure it out Future Rhett.

Oh! What about this method?

  • Calculate the electric field every dx, dy point (so like on a cm grid). If the potential is a whole number 5, 4, 3, 2, 1 volts – plot a point.
  • I like this method better. More brute force.

Electric Field Lines

I feel like electric field lines are dumb. Oh sure, they give a good sketch of the electric field, but what do they mean? From my intro physics course (many years ago), I remember the following:

  • Field lines are always perpendicular to equipotential lines.
  • When field lines are closer together, the value of the electric field is greater.
  • The electric field vector is tangent to the electric field lines.

That’s about it. But how do you create these with a computer?

Here’s what I want to try:

  • Start at some point near a charge.
  • Calculate the value of the electric field vector.
  • Move in the direction of the electric field vector (some distance dr)
  • Again calculate E and make another move.
  • Keep doing this until either the electric field gets too big (in case you get near another charge) or the distance from the starting point gets over some distance.

I think this would work. I want to try it. That’s for you, Future Rhett.

Finding the Electric Field from the Electric Potential (difference)

I’m way behind on this one. My plan was to write up something when this question came up in the summer section of algebra-based physics. It was a great question and deserved a full answer. Also, I wanted to make this a tutorial on trinket.io—but maybe I will do that after I write about it here.

So, here’s how it goes. We start off the semester calculating the electric field due to a point charge and then due to multiple point charges (you know—like 2). After that we get into the electric potential difference. Both the potential and the field follow the superposition principle. If you calculate the value due to two charges individually, you can add these together to get the total field or potential.

But there is a big difference. The electric potential difference is a scalar value where as the electric field is a vector. That means that when using the superposition with electric fields, you have to add vectors. Students would prefer to just add scalars—I’m mean, that seems obvious. Does that means that you could just find the electric potential difference for some set of point charges and then use that potential to find the electric field? Yup. You can. And we will.

Let me start with the definition of the electric potential difference. Since it’s really just based on the work done by a conservative force (the electric field), this looks a lot like the definition of work.

\Delta V = -\int_a^b \vec{E}\cdot d\vec{r}

Yes, that’s an integral. Yes, I know I said this was for an algebra-based course. But you can’t deny the truth. The “a” and “b” on the limits of integration are the starting and ending points—because remember, it’s really an integral. Also, the “dr” is in the direction of the path from a to b. It doesn’t technically have to be a straight line.

What about an algebra-based course? Really, there are only two options. The most common approach gives the following two equations for electric potential.

V = k\frac{q}{r}

\Delta V = -E\Delta r \cos \theta

The first expression is the electric potential of a point charge with respect to infinity (so the starting point for the integral is an infinite distance away). The second expression is the change in electric potential due to a constant electric field when there is an angle between the field and the displacement.

Oh wait! I forgot to list the value of k. This is the Coulomb constant.

k = 9\times 10^9\text{ N*m}^2\text{/C}^2

Students can understand the second expression because it’s pretty much the same as the definition of work (for a constant force). The first equation is mostly magic. The one way you can show students where it comes from is to do a numerical calculation of the electric potential difference since they can’t integrate. Did I write about that before? I feel like I did.

Ok, that’s a good start. Now for a problem.

Electric potential due to two point charges

Suppose I have two charges that are both located on the x-axis. Charge 1 is at the origin with a charge of 6 nC. Charge 2 is at x = 0.02 meters with a charge of -2 nC. Here’s a diagram—just for fun.

Let’s start off with the electric potential—as a warm up. What is the value of the electric potential (with respect to infinity) at the location of x = 0.02 meters? Using the equation above for the electric potential due to a point charge, I need to find the potential due to point 1 and then the potential due to point 2—then just add them together (superposition).

First for point 1.

r_1 = 0.02\text{ m} - 0\text{ m} = 0.02

V_1 = k\frac{q_1}{r_1}

Now for point 2.

r_2 = 0.02\text{ m} - 0.01\text{ m} = 0.01

V_2 = k\frac{q_2}{r_2}

This gives a total electric potential:

V = V_1 + V_2 = k\left(\frac{q_1}{r_1} + \frac{q_2}{r_2}\right) = 175.3\text{ Volts}

Finding the Electric Field

Now to find the electric field at that same point. I don’t know how to say this in a nice way, so I will just say it. Since the electric potential is calculated based on an integral of the electric field, the electric field would be an anti-integral. Yes, this means it’s a derivative. But wait! The electric field is a vector and the electric potential is a scalar? How do you get a vector from a scalar? Well, in short—it looks like this.

\vec{E} =-\nabla V

That upside delta symbol is the del operator. It also looks like this:

\nabla V = \frac{\partial V}{\partial x}\hat{x} + \frac{\partial V}{\partial y}\hat{y} + \frac{\partial V}{\partial z}\hat{z}

Yes, those are partial derivatives. Sorry about that. But you do get a vector in the end. But how can we do this without taking a derivative? The answer is a numerical derivative. Here’s how it works.

Suppose I find the electric potential at three points on the x-axis. The first point is where I want to calculate the electric field. I will call this x_0. The next point is going to be a little bit higher on the x-axis at a location of x_0+dx. The final point will be a little bit lower on the x-axis at x_0-dx. Maybe this diagram will help.

When I take these two end points (not the middle one), I can find the slope. That means the x-component of the electric field will be:

E_x(x_0) = -\frac{V(x_0+dx)-V(x_0-dx)}{2dx}

Let’s do this. I’m going to find the x-component of the electric field at that same location (x = 0.02 meters). I don’t want to write it out, so I’m going to do it in python. Here is the link (I wish I could just embed the trinket right into this blog post).

Umm..wow. It worked. Notice that I printed the electric field twice. The first one is from the slope and the second one is by just using the superposition for the electric field. Yes, I knew it SHOULD work—but it actually worked. I’m excited.

Also, just for fun—here is a plot of the electric potential as a function of x. The negative of this slope should give you the x-component of the electric field.

Here you can see something useful. Where on this plot is the electric field (the x-component) equal to zero? Answer: it’s where the slope of this plot is zero (yes, it’s there). Remember, just because the electric field is zero that doesn’t mean the electric potential is zero.

Homework

How about this? See if you can find the electric field due to these two charges at a location y = 0.01 and x = 0.0 meters. This is right on the y-axis, but now the electric field clearly has both an x and a y-component. That means you are going to have to do this twice.

Numerical Calculation for Work Done Near a Dipole

I’ll be honest. This connection between the electric potential (change in electric potential) and the electric field can get sort of crazy. But let’s just start with a problem and then solve it in more ways than you wanted.

Here is the problem.

Let’s start with the energy to bring an electron to point B. The energy needed would be equal to the change in electric potential energy which is equal to:

\Delta U_E = q\Delta V

That means I just need to calculate the change in electric potential from infinity to point B. Yes, you could also calculate the work needed to move the charge—I’ll do that also.

Since I am dealing with two point charges, I can use the following expression for the potential due to a point charge (with respect to infinity):

V = k\frac{q}{r}

Where k is the Coulomb constant (k = 9 \times 10^9 \text{ Nm}^2\text{/C}^2 and r is the distance from the point charge to the final location. Since there are two point charges, the total potential will just be the sum of the two potentials. Let me call the positive charge “1” and the negative charge “2”. That means the total potential will be:

V = V_1 + V_2 = k\frac{q_1}{r_1} +k\frac{q_2}{r_2}

From the original problem, q_1 = 2 \times 10^{-9}\text{ C} and q_2 = -2 \times 10^{-9}\text{ C} . The distance r_1 will be 6 mm and the distance r_2 will be 4 mm (need to convert these to meters).

Putting this all together, I get the following. I will do my calculations in python. Here is the code.

Running gives the following output.

Boom. There is your first answer. What about point A instead of B? Well, in this case, I just have different distances. The distance for both r_1 AND r_2 are the same. Since they have the same distances but equal and opposite charges, the two potentials will be opposite. When added together, the total potential is zero volts. Yes, the energy needed to put a point charge at A from infinity is zero Joules.

What? Yes. How about this? Suppose you take the electron from infinity on the positive y-axis. As you move down the axis to point A, the electric field is in the x-direction. That means the electric force is in the negative x-direction. You would have to push it in the positive x-direction and move in the y-direction. But that requires ZERO work since the force and displacement are perpendicular.

Oh. You want to get to A from a point of infinity on the positive x-axis? OK. That still works. Remember that for electric potential, the path doesn’t matter—only the change in position (path independent). I can take whatever path I like. I’m going to move in a circle from positive infinity x to positive infinity y. The electric field is zero out there, so that requires zero work. Now I’m at positive infinity y—and I just did that problem. Zero work.

Another way—by calculating the work

Remember that work-energy principle? It says this:

W = \Delta E

And the work can be defined as the following (if the force and displacement are constant):

W = F\Delta s \cos \theta

Oh, and the force will be the opposite of the electric force where:

\vec{F} = q\vec{E}

So, as you push a charge towards point B (point A is boring—for now) the electric field changes. That means we have a problem. We can’t use the above formula to calculate the work—unless we cheat. Let’s cheat.

Instead of calculating the total work to move the charge to point B, I’m just going to move it a tiny bit. During this tiny move, the electric field (and thus the force) will be approximately constant. Then I can do another tiny move. Keep repeating this until I get to point B. Here is a diagram.

If this distance is short (\Delta \vec{s}) then the force is approximately constant. That means the tiny amount of work (which I will call \Delta W) would be equal to:

\Delta W = eE\Delta s

OK, just to be clear. This is the force needed to PUSH the electron (with a charge e)—it’s not the electric force on the electron (which is in the opposite direction). Also, the angle between F and the displacement is zero. That means the cosine term is just one. I wrote the force and displacement as scalars because it’s just the magnitude that matters.

Now we are ready for some stuff. Here are the steps I am going to use.

  • Start at some position far away (but not actually infinity because that would be crazy). It just needs to be far enough away such that the electric force is negligible.
  • Calculate the total electric field and the force needed to push the electron at this point.
  • Move some short distance towards point B.
  • Over this distance, assume the force is constant and calculate the small work done—add this to the total work.
  • Repeat until you get to point B.

Before making this one program, I’m going to just make a program to plot the electric field from some value up to point B. Here is the plot from that program. (here is the code)

Note that I started from just 5 cm away from the origin—which is TOTALLY not infinity. However, it makes the graph look nice. But still, this is good because it looks like the calculation is working. Now I can use this same calculation go find the work needed to move the electron. Here is the code.

And the output:

Notice that gives a close, but wrong answer (compared to my previous calculation). Why is it wrong? Is it because I started at y = 0.5 meters (I just realized I’ve been using the variable y instead of x—but it should be fine). Or is it wrong because my step size is too big?

The answer can be found by just changing up some stuff. If you move the starting point to 1 meter, you get about the same answer. However, if you change dy to 0.0001, you get the following output.

That works. Oh, I added some more stuff to the output.

Non-straight Path

One more thing (and then I will look at the electric field in another post). What if I use a different path to get to point B? Instead of coming along the x-axis (which I previously called “y”), I come parallel to the axis a distance of 2 mm above it. Once I get right over point B, I turn down.

Like this.

This introduces some “special” problems.

  • I can break this path into two straight pieces (path 1 is parallel to x-axis and path 2 is parallel to y-axis).
  • Along path 1, the force needed to push the electron is NOT parallel to the path. So, the angle is not zero in \cos \theta. This means I’m going to have to calculate the actual vector value of the electric field at every step along this path.
  • The same is true along path 2.
  • But in the end, I should get the same work required—right?

OK, hold on because this is going to get a little more complicated. Let me just include one sketch and then I will share the code for this new path. Here is how to calculate the electric field and work for a particular step in path 1.

Here’s what needs to happen to calculate the electric field (and force) for each step:

  • Find the vector from the positive charge to step location.
  • Use this vector to find a unit vector (to give the electric field a direction).
  • Use that vector to also find the magnitude of the electric field.
  • Calculate the electric field due to the positive charge (as a vector).
  • Repeat this for the negative charge.
  • Add the two vector values for the electric field to get the total electric field.
  • Multiply by the charge to get the force (which would be in the opposite direction).

Now, to calculate the work done during each small step, I could use the angle between the force and displacement. But I don’t know that. Instead, I can use the vector definition of work:

W = \vec{F} \cdot \Delta \vec{s}

Yes, that is the dot product. Fortunately, the dot product is already built into VPython (Glowscript). So, once I get a vector value for the force and the displacement I can just use the “dot()” function.

OK, let’s do it. Here is the code (warning—vector stuff in the code) and the output.

Wow. I didn’t think that would work the first time. I’m pumped.

OK, the real reason for this post was to look at the connection between the electric field and the change in electric potential. I’ll make that in a follow up post.