Numerical Calculation of an Electric Field of a Half-Ring

Suppose there is a charge distribution that is half a circle with uniform charge. How do you find the electric field due to this half-ring? Here is a picture.

If you wanted to find the electric field at the origin (center of the half-ring), you could do this analytically. If you want to find the electric field somewhere else, you need to do a numerical calculation.

Here is the plan for the numerical calculation.

  • Break the ring into N pieces (where N can be whatever number makes you happy).
  • Treat each of these N pieces as though they were point charges.
  • Calculate the electric field due to each of these pieces and add them all up.
  • The end.

Maybe this updated picture will be useful.

Let’s say the total charge is 5 nC and the ring radius is 0.01 meters. We can find the electric field anywhere, but how about at < 0.03 ,0.04, 0 > meters.

I’m going to break this ring into pieces and let the angle θ determine the location of the piece. That means I will need the change in angular position from one point to the next. The total circle will go from θ = π/2 to 3π/2. The change in angle will be:

d\theta = \frac{\pi}{2N}

I know it’s wrong, but I will just put the first piece right on the y-axis and then space out the rest. Here is what that looks like for N = 7.

Here is the code.

That works. Oh, and here is the link to the code. Go ahead and try changing some stuff. See what happens if you put N = 20.

But there is a problem. If I make these charge balls, I need to also calculate the electric field due to each ball. I was going to make a list (a python list) to put all these balls in, but I don’t think I need it.

Here is my updated code.

With the output of:

I think this is working, but let me go over some of the deets.

  • Line 13: you need to know the charge of each piece—this depends on the number of pieces.
  • Line 12: We need to add up the total electric field from each piece. This means that we need to start with a zero electric field.
  • Line 15: I named the point charges so I can reference them. But here you can see that with this method, there is only one charge—it just moves.
  • Line 16: calculate r from a piece to observation location.
  • Line 17: electric field due to a point charge.

Homework

I’m stopping here. You can do the rest as homework.

  • How do you know this answer is correct? Hint: put the observation location at the origin.
  • How many pieces do you need to get a valid answer?
  • Make a plot of E vs. distance along the x-axis. This graph should show E approaching zero magnitude as you get farther away.
  • What about electric potential with respect to infinity? Oh yeah. That’s a good one.
  • Display the electric field as an arrow at different locations.

Electric Field due to a Uniformly Charged Ring

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?

Analytical Calculation

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:

\vec{E}=\frac{1}{4\pi \epsilon_0} \frac{q\hat{r}}{r^2}

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:

d\vec{E}=\frac{1}{4\pi\epsilon_0}\frac{dq\hat{r}}{r^2}

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.

dE_x = \frac{1}{4 \pi \epsilon_0} \frac{dq}{r^2}\cos\theta

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:

r^2=R^2+x^2

I can also replace the θ by again using the right triangle to write:

\cos \theta = \frac{x}{\sqrt{R^2+x^2}}

Updating the tiny x-electric field:

dE_x = \frac{1}{4 \pi \epsilon_0}\frac{dq}{R^2+x^2}\frac{x}{\sqrt{R^2+x^2}}

This simplifies to:

dE_x = \frac{1}{4 \pi \epsilon_0}\frac{xdq}{(R^2+x^2)^{3/2}}

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.

E_x =  \frac{1}{4 \pi \epsilon_0}\frac{xQ}{(R^2+x^2)^{3/2}}

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.

Numerical Calculation

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)

Some notes.

  • 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

Some notes.

  • 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[0].

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.

Homework

  • 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.

Modeling a falling slinky

I already posted some stuff about the MythBusters Jr. slinky defying gravity thing—here are those notes.

But how do you make a model of a falling slinky? Remember, you don’t fully understand something until you model it.

Also, with a model you can quickly test different situations. What happens if you put a car on one end of the slinky (or massive spring). What kind of spring constant do you need? What if the two masses are different?

All of these questions can be investigated with a model.

Let’s get to it. Of course, I am building my model with python—because I like python (and so should you). Here is my code. This is what most of it looks like (sorry, I can’t embed here).


Here is a gif of the output.

Some notes:

  • The balls wait a short time before dropping—just to make it dramatic.
  • I have calculated the position of the bottom mass so that it starts in equilibrium. If you don’t do that, the bottom mass will just oscillate up and down and ruin the whole thing.
  • I added two objects—a stick on the side and a free falling ball. That way you can see how the spring thingy falls.
  • Oh, you should absolutely try changing things up and running the model.

Here is how the model works.

  • There are two masses (the ball1 and ball2)—just ignore the other objects, they don’t matter.
  • Once the top mass is let go, there are two forces on the two balls. The downward gravitational force and then the spring force. Whatever the spring force on the bottom ball is, the top ball has the opposite.
  • The gravitational force is easy to calculate.
  • For the spring force, you need to know the natural length of the spring and the distance between the masses. The spring force depends on the difference between the distance and the natural length—then just multiply by the spring constant. Yes, I often mess up the sign on this force so that the two objects get pushed away in a weird motion.
  • After that, you are pretty much done. Use this force to update the momentum and then use the momentum to update the position.

Homework.

Here are some things for you to try.

  • What if the top mass is 0.1 times the bottom mass? Does this still work?
  • What if the bottom mass is 0.1 times the top mass?
  • See if you can calculate and plot the vertical motion of the center of mass of the two ball system.
  • What if the spring also has mass? There is a way to model this, but I’m going to make you think about it first.
  • Suppose I want to do this with a 2000 kg car. What spring constant would I need? What natural length of a spring should I use?

Thanksgiving Physics

I am honestly not quite sure how many blog posts I have about Thanksgiving.  It’s probably about 1 per year for 8 years.  I’m going to guess it’s 8.  Here goes my internet search.

This is what I found.

Intro to Chaos in Mechanics

This is really just for me so that I won’t forget.  I mean, I will forget—but then I can look back at this post and remember stuff.  Here’s to you Future Rhett.

What is a chaotic system?  Really, that’s the question—isn’t it?  There is the classic example of the double pendulumHere is some code for a double pendulum. And this is what it looks like.

Nov-11-2018 15-57-59.gif

But this isn’t the best system.  The problem is that there are two coordinates—the angle for the top bar and the angle for the bottom bar.  Sure, it’s cool—but what if you want to plot angle vs. time or something.  You have to plot both angles vs. time and that’s a bummer.

OK, how about a model of bounded population growth?  That’s just one dimensional, right?  Actually, it doesn’t even have to be population, it’s just an equation—something like this.

x_{n+1} = 4rx_n(1-x_n)

In this expression, r is some parameter—it really doesn’t matter what.  Let’s just model this expression for different values of r.  I’ll use a starting x value of 0.1 and r values of 0.7 and 0.9.   Here is the code.

GlowScript IDE 2018-11-11 17-55-15.png

Notice that when r = 0.7, the population reaches some stable value—but this is not true for r = 0.9.

Bifurcation Diagram

Now for another way to look at a chaotic systems—the bifurcation diagram.  Honestly, I didn’t really understand these things until I made one.  Here’s what we are going to do.

  • Start with some initial value of x (just pick something—I’m going to use 0.5).  Pick a value for r also.  Let’s just start at 0.1.
  • Run the model for 200 iterations and throw out that data.  This should allow us to look at the long term behavior for that particular value of r (throws out the transient behavior).
  • Now run the model for 100 additional iterations and save these.
  • Create a plot of these final x values vs. r.
  • Next increase the r value a little bit (I will increase it by 0.001)
  • Repeat until you get bored.

So if the model is stable after the initial stuff, then it will just keep plotting the same value of x after the first 200 iterations and you will just get a dot.  If it’s not stable after the first stuff, then you will get a bunch of dots with different x values.

OK, let’s do it.  Here is the code.  Oh, I made a function to iterate the model.  I probably should put more comments in there.

This is what it looks like.

GlowScript IDE 2018-11-12 09-08-29.png

Up to an r value of about 0.75, you only get one final x value.  After that, you get two different values . With r over 0.9, it gets crazy.

OK, that’s enough for now.  I just want to make sure future Rhett knows how to make a bifurcation diagram.

Video Analysis of Soyuz MS-10

There should be a grave yard for blog posts that start, but never get published.  Fortunately, I have this site.  Here I can share with you my failed posts.  Get ready.

It starts with this epic video from the Soyuz MS-10 failed launch.

That’s pretty awesome.  It’s doubly awesome that the astronauts survived.

Ok, so what is the blog post?  The idea is to use video analysis to track the angular size of stuff on the ground and from that get the vertical position of the rocket as a function of time.  It’s not completely trivial, but it’s fun.  Also, it’s a big news event, so I could get a little traffic boost from that.

How do you get the position data?  Here are the steps (along with some problems).

The key idea is the relationship between angular size, actual size and distance.  If the angular size is measured in radians (as it should be), the following is true L = r\theta where L is the length (actual length), theta is the angular size, and r is the distance.

Problem number 1 – find the actual distance of stuff on the ground.  This is sort of fun.  You can get snoop around with Google maps until you find stuff.  I started by googling the launch site.  The first place I found wasn’t it.  Then after some more searching, I found Gagarin’s Start.  That’s the place.  Oh, Google maps lets you measure the size of stuff.  Super useful.

Finding the angular size is a little bit more difficult.  I can use video analysis to mark the location of stuff (I use Tracker Video Analysis because it’s both free and awesome).  However, to get the angular distance between two points I need to know the angular field of view—the angular size of the whole camera view.  This usually depends on the camera, which  I don’t know.

How do you find the angular field of view for the camera?  One option is to start with a known distance and a known object. Suppose I start off with the base of the Soyuz rocket.  If I know the size of the bottom thruster and the distance to the thruster, I can calculate the correct angular size and use that value to scale the video.  But I don’t the exact location of the camera.  I could only guess.

As Yoda says, “there is another”.  OK, he was talking about another person that could become a Jedi (Leia)—but it’s the same idea here.  The other way to get position time data from some other source and then match that up to the position-time data from the angular size.  Oh, I’m in luck.  Here is another video.

This video shows the same launch from the side.  I can use normal video analysis in this case to get the position as a function of time.  I just need to scale the video in terms of size.  Assuming this site is legit, I have the dimensions of a Soyuz rocket.  Boom, that’s it (oh, I need to correct for the motion of the camera—but that’s not too difficult).  Here is the plot of vertical position as a function of time.sideviewsoyuzaccel.png

Yes, that does indeed look like a parabola—which indicates that it has a constant acceleration (at least for this first part of the flight).  The term in front of t2 is 1.73 m/s2 which is half of the acceleration.  This puts the launch acceleration at around 2.46 m/s2.  Oh, that’s not good.  Not nearly good enough.  I’m pretty sure a rocket has an acceleration of at least around 3 g’s—this isn’t even 1 g.  I’m not sure what went wrong.

OK, one problem won’t stop me.  Let’s just go to the other video and see what we can get.  Here is what the data looks like for a position of one object on the ground.

Data Tool 2018-11-04 13-31-41.png

You might not see the problem (but it sticks out when you are doing an analysis).  Notice the position stays at the same value for multiple time steps?  This is because the video was edited and exported to some non-native frame rate.  What happens is that you get repeating frames.  You can see this if you step through the video frame by frame.

It was at this point that I said “oh, forget it”.  Maybe it would turn out ok, but it was going to be a lot of work.  Not only would I still have to figure out the angular field of view for the camera, but I need to export the data for two points on the ground to a spreadsheet so that I can find the absolute distance between them (essentially using the magnitude of the vector from point A to point B). Oh, but that’s not all.  When the rocket gets high enough, the object I was using is too small to see.  I need to switch to a larger object.

Finally, as the rocket turns to enter low Earth orbit, it no longer points straight up.  The stuff in the camera is much farther away than the altitude of the rocket.

OK, that’s no excuse.  I should have kept calm and carried on.  But I bailed.  The Soyuz booster failure was quite some time ago and this video analysis wouldn’t really add much to the story.  It’s still a cool analysis—I’ve started it here so you can finish it for homework.

Also, you can see what happens when I kill a post (honestly, this doesn’t happen very often).

Actually, there is one other reason to not continue with this analysis.  I have another blog post that I’m working that deals with angular size (ok, I haven’t started it—but I promise I will).  That post will be much better and I didn’t want two angular size posts close together.

The end.

List of Teaching and Learning Posts

Here is a collection of post for students and faculty – all about learning to help with the start of the semester.

 

Thinking about labs

I need to redo all my physics labs.  They are terrible.  I want to make them even MORE about model building.

With that in mind, I saw this:

 

One sentence labs.  Leave the procedure up to the students.  I think I will need some type of turn in sheet for these labs though.  What about informal lab reports?

Reflections on Student Video Assessments

After the summer session of physics (algebra-based), I have the following comments.

  • It seems like every other video has a problem with vector notation.  Students often set a vector equal to a scalar.  Frustrating.
  • Students seem to confuse two standards: The Momentum Principle and Collisions.  I have students submit videos for the momentum principle that are just a collision.  The key point is that the momentum principle deals with force, time and change in momentum.  I guess this is my fault. I offered suggested homework problems from a textbook and it covered momentum and collisions in the same chapter.  I guess they thought they were the same thing.
  • Students are not very skilled at picking problems to solve.  They like the lowest level of something like “mass is 2 and velocity is 3, what is the momentum?”. I tried to help them, but it didn’t seem to work.  I showed a bunch of questions in class and had them “rate” them then discuss what makes a good problem. (I think I wrote about that here on my blog).
  • I’m still not happy with the “student review”.  I want students to watch other student videos – but I don’t know how to implement that.
  • Students like to procrastinate.  I’m getting a bunch of redos on the last day of submissions.  That sucks to grade.
  • I hate vertical videos – but I hate videos that are recorded sideways even more.  I stopped accepting the sideways videos since they can fix it and send it back to me.
  • I try to give meaningful feedback in my responses – but sometimes I just give a grade (score out of 5 points).
  • I’m trying to give higher scores.  If they do well on the in-class assignment and submit multiple videos that aren’t wrong, I typically will at least give a 4/5.

What is a good problem?

Part of the reassessment process has students pick problems to solve that they think are good demonstrations of their understanding of the material (or the standard).

For me (as the evaluator), I can learn quite a bit about what a student thinks just based on the problem they pick to solve.  However, it seems that students really don’t want to pick problems.  They would prefer to have me just tell them what problems to solve.

OK, let’s do this.  Let’s look at some problems and see which ones are good and which ones are not so good.  In this case, it will be for the Position-Velocity-Acceleration standard.  For this standard, students should show that they understand and can use the definitions of position, velocity, and acceleration in 1 dimension.  So here are some questions.  You get to pick which one is the best.  Actually, why don’t you score them from 0-10 (11 being the best).

Problem A.

A plane has a mass of 1120 kg and is landing on a runway.  The landing speed of the plane is 50 m/s and the runway is 2140 meters long.  What is the acceleration of the plane?

Problem B.

Your car is the fastest all around.  No one can beat you.  It has an acceleration of 8.2 m/s2.  Suppose you start from a rest (because, don’t all drag racers do this).  How long would it take your awesome car to get to a speed of 55 m/s?  What is this speed in mph?  What is the average speed during this time?  How far did you go?

Problem C.

A police car starts from rest and can accelerate at 5.5 m/s2.  The police car starts accelerating as soon as a speeding car passes by with a speed of 25 m/s.  Assuming the police car has a constant acceleration and the other car has a constant speed, where does the police car catch up to the other car?

Problem D.

Can you have a hang time of over 2 seconds when jumping?

Problem E.

A rocket is in space traveling with a speed of 328 m/s.  It fires its rockets to create an acceleration of -10.7 m/s2 (slowing down).  What is the speed after 5.8 seconds?

Problem F.

no words