# Modeling the Motion of a Charge Near a Dipole

Suppose you have an electric dipole that is either very massive or fixed in space (you get to pick). Near this dipole is another small electric charge that is free to move. How will it move?

Oh, why would anyone even care about this problem? Well, I care. Actually, there is something really cool that happens. Trust me.

**Calculating the Electric Field.**

Let me start with a diagram. Here are the three charges.

Of course negative charges are blue. I don’t know why —they just are. The two fixed charges (+Q and -Q) are separated by a distance *s. *These two charges create an electric field at the location of the other small charge. Such that the total electric field would be:

Note that the constant out front is just the Coulomb stuff. Also, you have to have the unit vectors (the stuff with the “hat” over them) so that you can get the vector value of the electric field. This isn’t a terribly difficult thing to calculate, but it can be tedious (that’s why I’m going to make a computer program do it).

**Numerical Calculations**

Once I calculate the total electric field at the location of the moving charge, I can find the vector force on that charge.

With this electric force, I can use the momentum principle to find the change in momentum of the charge during some short time interval.

The key here is that even though the force is not constant, if I pick a small enough time interval, I can make some approximations to calculate the change in momentum and the change in position of the charged particle. This is the key idea of a numerical calculation — -take a difficult problem and break it into a whole bunch of simpler problems.

So, here is the basic recipe to model the motion of this electric charge.

- Calculate the electric field due to the dipole at the location of the moving charge.
- Calculate the electric force on the charge.
- Use the force to find the change in momentum of the charge over a short time interval.
- Use this momentum to find the change in position of the charge.
- Repeat for as long as you like or until you get bored (or your computer dies).

Before getting right into the program, there is another important part of a numerical calculation — -the numbers. You have to have numerical values for all of the calculations since really the numbers are all that you have to work with. That’s what makes this different than an analytical calculation with just algebraic expressions for stuff.

**Numerical Values**

This can be tricky. You need to start with some values for charge, mass, and time so that everything works. I’ll skip the part where I just made some rough guesses for the values. Here is what I’m going to start with.

- Dipole charges of 5 nC with a charge separation of 0.08 cm.
- Moving charge with a mass of 1 x 10^-18 kg and a charge of -1.6 x 10^-19 C (I was going to just use an electron, but the mass was too low).
- For the time interval, I am going to use 0.001 seconds.

But wait! I need one more thing. I need the starting position and momentum for the moving charge. I will use the following:

- Position = < 2s, 3s, 0 > meters (that’s a vector).
- Velocity = <2, -2, 0 > m/s (again, a vector). You can multiply this by the mass to get the momentum.

**The Code**

Here’s what I have. You can see the whole program (and even edit it) on trinket.io.

GlowScript 2.9 VPythonk=9e9

s=0.08

R=0.01Q1=sphere(pos=vector(s/2,0,0), radius=R, color=color.red)

Q1.q=5e-9Q2=sphere(pos=vector(-s/2,0,0), radius=R, color=color.cyan)

Q2.q=-5e-9ball=sphere(pos=vector(2*s,3*s,0), radius=R/2, make_trail=True)

ball.q=-1.6e-19qoverm=-1.6e-19/(9.1e-31)

ball.m=1e-18

ball.p=ball.m*vector(2,-2,0)t=0

dt=0.001while t<2:

rate(100)

r1=ball.pos-Q1.pos

r2=ball.pos-Q2.pos

F1=k*Q1.q*ball.q*norm(r1)/mag(r1)**2

F2=k*Q2.q*ball.q*norm(r2)/mag(r2)**2

F=F1+F2

ball.p=ball.p+F*dt

ball.pos=ball.pos+ball.p*dt/ball.m

t=t+dt

Just a few comments on this code.

- Since this is a numerical calculation, all you need is the numbers. Don’t put units with your variables (because then it wouldn’t be a number).
- Oh, units are still important — but it is the responsibility of the human to keep up with this.
- Look at this line:
`ball.p = ball.p + F*dt`

you should realize that this is not an equation. This is a “set equal to”. That’s why the momentum values don’t cancel.

OK, let’s run it. Here’s what I get. This is just a gif, but you can run it yourself.

That looks cool, but is it legit? One quick check is to see what happens when you change the size of the time interval. If I decrease the size of the time step and get something crazy different, then the time step wasn’t small enough.

Another option is to plot the total energy and see if it’s constant. Here the energy will be the sum of the electric potential energy and the kinetic energy of the moving charge.

Let’s do it. Here is the same program with the graph added.

Boom. That works. *“**You know, sometimes I amaze even myself.”*

**Now for the Crazy Part**

Everything so far was just a set up for this. What happens if I put the negative charge on the y-axis (with the dipole centered on the origin) and release it from rest (zero initial velocity)? Check this out.

Isn’t that awesome? There’s so much more to consider, but instead I will just leave you with some homework questions.

**Homework**

- Is this an actual circular path or is it just circular looking?
- Does the period of oscillation depend on the starting distance?
- Does the period of oscillation depend on the value of the mass or charge for the moving object?