For a school project, I'm trying to graph a magnetic field. I found this page on the NASA website with spherical coordinate equations for a dipole field, but I'm having trouble interpreting the page.

The equations are

$$B_r = 2M \frac{cos θ}{r^3} \tag{1}$$ $$B_θ = M \frac{sin θ}{r^3} \tag{2}$$ $$B_φ = 0 \tag{3}$$

I know that $\theta$ is the zenith angle, but I'm having trouble figuring out what $M$ is.

NASA says that $M$ is the dipole moment and has a value of $-8 \times 10^{15} \ T \ m^3$ or $-31,000 \ n \ T R_e^3$, but I can't find what those variables exactly mean. I think $T$ might be for torque, but even still, I don't really know how to graph that. If anyone could help clarify the spherical coordinates to me, it would be much appreciated. Thanks!

Here's the original NASA file.

  • $\begingroup$ Those are units - $T m^3$ is Tesla $\cdot$ meters cubed. $M$ is just a number - if you want a picture of what the field looks like, you can just as easily set $M=1$ and everything will look the same. $\endgroup$ – J. Murray Mar 25 '18 at 2:46
  • $\begingroup$ @J.Murray That should be an answer $\endgroup$ – David Z Mar 25 '18 at 2:52

$M$ is a measure of the strength of the dipole field. In SI units, $M= -8\times 10^{15} \ T m^3$, where $T$ stands for "teslas" and $m^3$ means "meters cubed".

If you only want to know what the field looks like, then you could just set $M=-1$, so you have that

$$ B_r = -2\frac{\cos(\theta)}{r^3}$$ $$ B_\theta = -\frac{\sin(\theta)}{r^3}$$ $$ B_\phi = 0$$

As far as actually plotting this goes, you need to be careful. The easiest thing to do would be to convert everything to Cartesian coordinates and then use some kind of vector plotting software, such as the one available through WolframAlpha.

The NASA document gives the cartesian form of the equations on the next page. Keeping our convention that $M=-1$, we have that

$$B_x = -3\frac{xz}{r^5}$$ $$B_y = -3\frac{yz}{r^5}$$ $$B_z = \frac{r^2-3z^2}{r^5}$$

where $r=(x^2+y^2+z^2)^{\frac{1}{2}}$. This is a 3D vector field, which is typically difficult to plot - instead, we can look at a "slice" by simply setting $y=0$. We then take the $z$ axis to be vertical and the $x$ axis to be horizontal.

The components of the vector field are then

$$ B_x = \frac{-3xz}{(x^2+z^2)^{\frac{5}{2}}}$$ $$ B_z = \frac{x^2-2z^2}{(x^2+z^2)^\frac{5}{2}}$$

Plotting this is not as easy at is appears, though, because the quantity $x^2+z^2$ goes to zero at the coordinate origin, which will cause most plotting programs to behave badly.

Additionally, even if you tell the program not to plot any vectors at the origin, the dipole field increases dramatically for smaller $r$. Your plotting program will probably scale the vectors according to the longest ones in the plot, which means you'll end up with a plot that looks like this:

enter image description here

This is not terribly illuminating. What you'll want to do is restrict your attention to $r$ greater than some lower limit. Playing around with it a bit, I think it looks nice if you make the restriction $x^2+z^2>1$ and plot it from $-2$ to $2$ in $x$ and $z$, but you can make that decision yourself.

A quick example of Mathematica syntax:


So a basic plot looks like this:

enter image description here

If I wanted to restrict my vector plot to the region outside the unit circle, I would replace xComponent with


which is equal to "xComponent" if $x^2+y^2>1$, and is equal to $0$ otherwise. That syntax would look like this:

enter image description here

  • $\begingroup$ Thanks! Do you know how I would go about graphing this in Matlab or a modeling software? I'm trying to make a visual model of magnetic fields and I'm having trouble doing that in Wolfram Alpha. $\endgroup$ – JL292 Mar 26 '18 at 2:48
  • $\begingroup$ @JL292 Mathematica is the big kid version of Wolfram Alpha, and you can access most of its functionality through the Wolfram Sandbox. If you'd prefer Matlab, you can use the quiver plot, though to me, Mathematica is substantially easier. $\endgroup$ – J. Murray Mar 26 '18 at 2:53
  • $\begingroup$ @JL292 See my update at the bottom of the post. $\endgroup$ – J. Murray Mar 26 '18 at 3:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.