Hold on to your pants. Let’s do this.
Suppose I have an electrically charged ring. The radius of this ring is R and the total charge is Q. The axis of the ring is on the x-axis. What is the value of the electric field along this x-axis?
You can’t directly find the electric field due to a charge distribution like this. Instead, you have to break the object into a bunch of tiny pieces and use the superposition principle. The super position principle says that the total electric field at some point is the vector sum of the electric field due to individual point charges.
Of course the electric field due to a single point change can be found as:
So, if I break this ring into a bunch of tiny points I can find the electric field due to each of these points and add them up. Yes, the smaller the points the better the answer. In fact, if I take the limit in which the point size goes to zero I will turn this into an integral. Calculus for the win (CFTW).
Let’s take a look at one of these pieces on the ring of charge. Here is a view of the ring from the side.
I can find the little bit of electric field from this little bit of charge at the top of the ring. This electric field would be:
Of course the direction of r and thus the electric field will change directions as you go around this ring and add up tiny electric fields. But WAIT! We can cheat. OK, it’s not cheating–it’s just being smart. What if you also consider the tiny piece of charge at the bottom of the ring? This would also make a tiny electric field at this same location. It would have the same magnitude as the electric from the top piece since it’s the same charge and distance. However, the y-components of these two electric fields would cancel and leave only an x-component of the field.
In fact, for every tiny piece on the ring there is a corresponding piece on the opposite side of the ring. The only surviving components of electric field will be in the x-direction. So that’s all we need to calculate.
Looking at the diagram above, I can find the x-component of this tiny electric field by using the angle θ (which I don’t explicitly know). However, I can still write down this new x-component of the tiny electric field.
Yes, this is no longer a vector. It’s the x-component of the electric field such that it’s just a scalar. But there’s still a problem. I want to add up (thus integrate) all these tiny electric fields due to the tiny charges. However, I have these two variables that I don’t like. There is θ and r. I need to replace those.
For the r, it’s clear that I can use R and x and the pythagorean triangle to get:
I can also replace the θ by again using the right triangle to write:
Updating the tiny x-electric field:
This simplifies to:
Now we need to get a better integration variable—we can’t integrate over dq. Or can we? Yes, we can. Take a look at the equation above. As you move around the circle, which of those variables change? The answer: none of them.
As I integrate over dq, I just get the sum of the dq’s—which would be Q. Boom. That’s it. Here is my final expression for the x-component of the electric field along the x-axis of this ring.
Now for a couple of checks on this result. I will let you make sure these are ok.
- Does this expression have the correct units for electric field?
- What about the limit that x>>R? Does this expression look like the field due to a point charge?
- What is the electric field in the center of the ring?
One last thing to think about. What if you want to find the electric field at some location that is NOT on the x-axis? Then the above derivation wouldn’t work. Too bad.
Let’s do this again. However, this time I am going to create a numerical calculation instead of an analytical calculation. What’s the difference?
- The analytical calculation takes the sum of charge pieces in the limit as the size of the pieces goes to zero.
- The numerical calculation uses numerical values for a finite number of pieces to calculate the electric field.
That’s really the only difference.
OK, let’s just get into this. I’m going to give you a link to the code and then I will go over every single important part of it. Honestly, you aren’t going to understand this code until you play with it and probably break it.
Here is the code on trinket.io. Sorry—I can’t embed the code in this wordpress blog (I wish I could).
This is where I start.
k=9e9 Q=10e-9 R=0.01
I like to start with some constants and stuff. Here I am using k for the constant. I also had to pick a value for the total charge and the radius of the ring. Remember, you can’t do a numerical calculation without numbers.
Now let’s make the ring.
cring=ring(pos=vector(0,0,0),axis=vector(1,0,0), radius=R,thickness=R/10, color=color.yellow)
- This isn’t really needed for the calculation—but it allows us to make a visualization of the thingy.
- “ring” is a built in object in VPython (glowscript).
- The important attributes of this object are the position (pos), the axis—which is a vector in the direction of the axis of the ring. Radius and thickness and color should make sense.
For the next part, I need to break this ring into pieces. If I use N pieces, then I can find the location of each of the tiny charges by using an angle to indicate the location. I also need to find the charge on each tiny piece. Here is the important code.
N=20 theta=0 dtheta=2*pi/N dq=Q/N
The “dtheta” is the angular shift between one piece and the next. It’s like a clock. It’s a clock that only ticks N times and doesn’t really tell time. But each “tick” is another tiny charge. Maybe that’s a terrible analogy.
But how do we deal with all these tiny charges? What if N is equal to 50? I don’t want to make 50 variables for the 50 charges. I’m too lazy. So instead, I am going to make a list. Lists in python are super awesome.
I won’t go into all the details of lists (maybe I will make tutorial later), instead I will just show the code and explain it. Here’s where I make the tiny charge pieces.
points= while theta<2*pi: points=points+[sphere(pos=R*vector(0,cos(theta),sin(theta)),radius=R/8)] theta=theta+dtheta
- First, I made an empty list called “points”.
- Next I went through all the angular positions around the ring. That’s what the while loop does.
- Now I create a sphere at that angular position and add it to the points list.
- Update theta and repeat.
- In the end I have a list of points—the first one at points.
Next part—make the observation location. This is the spot at which I will calculate the electric field.
obs=sphere(pos=vector(.03,0.03,0), radius=R/10) E=vector(0,0,0)
The “E” is the base electric field, it starts at the zero vector.
Now for the physics.
for p in points: r=obs.pos-p.pos dE=k*dq*norm(r)/mag(r)**2 E=E+dE print("E = ",E," N/C")
Here you can see the full power of a list. Once I make the list of tiny charges, it is very simple to go through the list one tiny charge at a time—using the “for loop”.
Essentially, this loop does the following:
- Take a tiny charge piece.
- Find the vector from this piece to the observation location
- Find the tiny component of the electric field using the equation for a point charge.
- Add this tiny electric field to the total electric field and then move on to the next piece.
Boom. That’s it. Print that sucker out. Maybe you should compare this electric field to the analytical solution. Oh wait. There’s a bunch of homework questions. Actually, I was going to do some of these but this post is already longer than I anticipated.
- Pick a value of N = 10 and an observation location of x = 0.1 meters. How well does the analytical and numerical calculations agree? What if you change to N = 50? What about N = 100?
- Create a graph that shows the magnitude of the electric field as a function of x (along the ring axis). In this graph include the analytical solution and plots for N = 10, 30, 50, 100.
Actually, I wanted to make that last graph. It would be great.
Oh wait! I forgot about the most important thing. What if I want to calculate the electric field at a location that is NOT on the x-axis? Analytically, this is pretty much impossible. But it’s pretty easy with a numerical calculation. Here’s what that would look like.
Oh, if you like videos—here is the video version of this post.