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:

Image for post

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.

Image for post

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:

Image for post

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:

#python #physics #programming

Calculating and Visualizing the Magnetic Field Due
5.70 GEEK