I told my students I would solve this problem for them. It’s a real life problem too.

Is it possible to use a Neodymium magnet and a coil of wire to get an LED to light up?

That’s the real version. But because I was afraid students would be overwhelmed, I added the following:

The magnet has a maximum magnetic field of 0.2 Tesla.

The LED requires 1.5 Volts and 10 mA to light.

I like this problem because I don’t know the answer. Also, the answer is useful. If you want to do a physics demo showing the voltage induced by a changing magnetic field—what better way than with a hand-held magnet and a small light?

But will it even work? Let’s get started. Here is a diagram.

By changing the magnetic flux through the coil, this will create a curly electric field and an electromotive force (a change in electric potential). The magnetic flux is defined as:

Where N is the number of turns in the loop, A is the area of the loop and is the angle between the magnetic field and a vector perpendicular to the area. In the diagram above, since the magnetic field is perpendicular to the coil.

A change in flux produces a voltage according to Faraday’s Law:

Note: yes, I’m different. I think that the number of loops (N) is part of the magnetic flux and that the minus sign in Faraday’s Law doesn’t really mean anything.

Putting the flux into Faraday’s Law, I get (assuming ):

Now for some estimates. I could just estimate everything and then calculate the voltage—but instead I’m going to estimate everything except the number of turns. I can then solve for N and see if it’s reasonable.

Here’s what I have.

B = 0.2 T

A: radius = 0.01 m

Time interval = 1 second

Voltage = 1.5 V

Solving for N:

This is the perfect case to use python for your calculator. You can put your estimates as variables so that you can easily change things up. Here is my code. I get the following output.

Umm….yeah. That’s 23 thousand turns. I’m not going to do that. Even if decreased the time to 0.1 seconds, I would still need 2000 turns. Arg.

Oh, what if I just make a HUGE loop? Nope. That wouldn’t work. In my estimation for the change in flux, I assumed a constant magnetic field—this is obviously not true, but good enough for a small loop. With a big loop, you would have some of the magnetic field creating a negative flux. It would just make things worse.

What if I put the magnet on a spinning stick (run by a motor)?

It seems that most of the second semester algebra-based physics is magic. Since you need calculus to derive many of the expressions, the students just get them magically instead.

NOT TODAY. Well, I hope not. Today I am going to use python and the Biot-Savart Law to find the magnetic field due to a wire. Here is the expression I want to show:

Where I is the current in a wire and r is the distance from the wire. I guess I should start with the magnetic field due to a moving point charge.

Yes, that’s sort of a crazy equation. The weird part is the cross product. Here are some notes:

The “times” symbol is the cross product.

The cross product is an operation between two vectors that returns a vector as the resultant (unlike the dot-product that returns a scalar).

The resultant of this vector is perpendicular to both of the products—that makes this only work in 3D.

The magnitude of the resultant depends on the magnitude of the products and the sine of the angle between them.

OK, that’s enough of that. Fortunately, we don’t really need to compute cross products since it’s built into VPython (Glowscript). Let me do one more thing before calculating stuff. Suppose I have a charge q moving with a velocity v over some short length of wire, L. I can write qv as:

So, instead of dealing with qv, I can use IL. Note that L is a vector in the direction of motion for the current. Now my magnetic field looks like this:

I changed from L to dL since it has to be a short wire. So, dL is just a way to emphasize that the wire is super short.

Let’s do this. Here is my first calculation. Let’s say I have a super short wire (0.01 m) with a current of 0.1 Amps. What is the magnetic field a distance of 0.02 meters from the wire? I left off something important—but I will show you that in a second. Here is the code to calculate this magnetic field.

It looks like this (this is just an image—you need to go to the trinket site to actually run this code).

If you run this, you get an output of <-2.5e-7,0,0> T. I think that’s correct. But let’s make this better. Let’s make a visual representation of the magnetic field. Really, that is the power of VPython anyway. Here is the new code and this is what it looks like when you run it.

I rotated the camera angle a little bit so you could see the wire and the magnetic field. OK, now for MORE VECTORS. Here is the sloppy code.

Oh. I like that. It’s pretty. But you can see that the magnetic field makes a circular pattern around the wire. But what about a long wire? Here comes the part where we NEED python. I want to be able to represent a long wire as a series of a bunch of small wires. Then I can calculate the magnetic field due to each of the small wires and then add them up to get the total magnetic field.

In order to simulate a “long wire” I need to have the “observation” location in the center of the series of short wires. Maybe this diagram will help. Here is a side view of 8 small wires together along with the observation location.

Each of these parts of a wire will have a magnetic field at the “obs” location. So, here is how this will work.

Pick some distance from the wire (r) and create the observation location as a vector.

Take the wire and break it into pieces. The more pieces, the better the answer.

For each piece in the wire, calculate the vector r to the observation location.

Calculate the magnetic field due to this piece and add it to the total.

Let’s do this. Here is the code. Oh, I am going to use the same wire as before but I will make it 1 meter long. Also note—I’m not going to display an image of the magnetic field (or even the wire). I’m going to try to make this as simple as possible.

Using 8 pieces, I get the following output.

Where the theoretical B is the value calculated from the scalar equation up top (magnetic field due to a long wire). So, this is the scalar value (ignore the negative sign). Also, it looks quite a bit off—but there are a couple of points.

This calculation only uses 8 points.

There is a slight error. I put the first I*dL at the position x = -L/N. That assumes a super tiny dL—and that’s not true when N = 8.

The magnetic field due to a long wire equation (above) is for an infinite length wire.

Still, it’s pretty good. What happens as I increase the number of pieces? For that, I’m going to make this whole calculation a function. That way I can run it a bunch of times. Here is a refresher course on functions in python.

So, with 50 pieces you get a pretty good agreement with the theory. I like that.

But wait! The theoretical value says the magnitude of the magnetic field decreases as 1/r. Does that work for this model too? Let’s test it. Here is the code.

Surprising that the two calculations don’t quite agree at very close distances. I suspect that is because I have an even number of wire pieces (50) which puts the observation location between two wires segments. Or something like that. But otherwise, this works.

It’s too bad I can’t embed trinket.io right into this blog. I guess I will have to upgrade my wordpress at some point.