A Numerical Calculation of the Electric Field Due to a Charge Distribution


It’s time for another physics example. In this case, I am going to calculate the electric field due to an electric charged rod. Of course you could do this analytically using a bit of calculus. This is a fairly standard example in most introductory physics textbooks. Here is an example where I calculate the electric field along the same axis as the rod.


But what if you want to find the electric field at any point? For instance, like this:


Sketches Fall 14 key


You can set up an integral to determine electric field at that point, but it won’t be easy to evaluate. But the cool thing is that both the analytical and numerical methods in this case use the same idea. In both cases, you will break the charged rod into a whole bunch of tiny pieces. The electric field due to each of these tiny pieces is just like the electric field due to a point charge (if the pieces are small enough). Then the total electric field at the point of interest is just the same of the tiny electric fields due to the tiny pieces of the rod. Really, the only difference is that in the analytical method you take the limit as the piece size approaches zero.


Ok, let’s set up a numerical method for calculating the electric field due to the rod. Here is the recipe.



  • Break the rod into N pieces (where you can change the value of N).

  • For each tiny little piece, calculate the charge and the position. The charge of each piece would just be Q/N.

  • Find the vector that goes from each piece of the rod to the point where you want to find the electric field.

  • Use the equation for the electric field to find the contribution to the total electric field due to each piece.

  • Add up all the contributions to the electric field due to all the pieces.


That’s it. It’s really not too complicated. In fact, you don’t even need a computer to do this. If you preak the rod into 10 pieces, you could easily calculate the field due to each of these 10 pieces. Of course if you want to break it into 100 pieces, the calculations still might not be difficult, but the process might drive you insane.


Before getting into the program, let’s say that I want to find the electric field at some vector location ro. Here is how you would calculate the electric field due to one of the pieces.


Sketches Fall 14 key


Now for the program. Wait. I’m not going to show this part to you. I know, that sort of stinks – but that’s the way things are going to be. There are probably many introductory physics classes that use this problem as part of a homework assignment or something. I don’t want to spoil the solution. Sorry. However, I will show you what it looks like.


Vpython


Yes. That looks very pretty, but it’s not that useful. In order to determine the accuracy of this numerical model, I need to calculate the electric field along an axis perpendicular to the rod and in the center of the rod. This is a region that I can also calculate the electric field using calculus such that I can see how well the two methods agree.


Skipping the derivation, I have two expressions for the magnitude of the electric field along an axis perpendicular to the center of the rod. The second formula is an approximation if the length of the rod is long compared to the distance from the rod.


La te xi t 1


Ok, let’s get to a calculation. I want to plot the magnitude of the electric field as a distance from the rod for all three methods (the two equations and the numerical method). Here are my starting parameters.



  • Rod length = 0.5 meters.

  • Total charge = 1 x 10-8 Coulombs.

  • Number of pieces (for the numerical calculation) = 100.


Here is the plot. The horizontal axis is the ratio of the distance to the rod divided by the length of the rod.


Here you can see that there is clearly a difference between the approximation and the other two methods of calculating the electric field. This is especially true as the observation point gets further away from the rod and the approximation that z is much smaller than L is obviously not true.


Now that this method seems to be working, let’s test the numerical model. How dependent is the solution on the number of pieces that the rod is broken into? This is a plot of the magnitude of the electric field in the middle of the rod at a distance of 0.1L.


Why is it all zig-zaggy? My original guess was that it had to do with whether the rod was broken into an even or odd number of pieces. Looking at that data more closely, this is not the case. Perhaps it’s some sort of rounding error. I’m not sure.


So, how many pieces should you break the rod into? Obviously more is better. In this case even breaking the rod into 1000 pieces doesn’t take any significant calculation time and it gives a fairly reasonable answer. Of course for other situations, the calculation time could be important. You would have to pick some balance between fast-cheap-and accurate.


In the calculation above, it seems like the analytical solution is superior in every way. But wait! It’s not. The analytical solution only works on that line that runs perpendicular to the rod and through the middle of the rod. So let’s do something that the analytical solution can’t do. What if I want to calculate the value of the electric field along a line at some angle. Here is a diagram.


Sketches Fall 14 key


Here is a plot of the electric field along the line y = x. Actually, I will plot the component of the electric field in the direction of the line (instead of the magnitude of the electric field).


Ok, that’s cool – but how do I know if it is legit? Well, there is one trick I can use. What if I get really far away from this rod? In that case, the electric field should be similar to the electric field due to a point charge. At large distances, a rod just looks like a point.


Here is a plot of the component of the electric field along a diagonal for large distances along with the calculation of the field due to a point charge.


That’s nice. Actually, I am sort of surprised that the two electric fields are so close even at a distance of just L away from a rod of length L.


But there you go. That’s the electric field due to a charged rod. There would only be one thing that would make this whole process better – experimental data for the electric field due to a rod. That would be pretty tough. It’s difficult to create a uniformly charged electric rod and even harder to measure the electric field at different points in space.


What if you did a similar calculation for the magnetic field due to a straight wire with current or even the magnetic field due to a loop of wire? The nice thing about the magnetic field is that you could also experimentally measure the magnetic field. Wouldn’t that be cool? Why don’t you do that for homework?



No comments:

Post a Comment