Category Archives: Brian

Conclusion

While I have made a lot of progress since the start of this project, I am disappointed that I don’t have more time to work on it because I made so much progress right at the end, finally figuring out techniques that worked well in Mathematica.  If I had more time I would try to make some contours of multiple dipoles, and see how things cancel out.  Admittedly this would be a lot harder to picture the perpendicular field lines, and the 3D structure would probably become more necessary.  Its also possible that the contour technique I used here might not work well at all for multiple dipoles, but it would have been good to check it out a bit at least.

That being said, I did make some pretty cool 3D graphs of magnetic equipotential surfaces that scale as expected with current intensity.  The 2D case helped greatly to show how these contour surfaces represent the magnetic field in a general way, partly because of the greater number of contours that could be shown at once in a plot.  This 2D case is actually more helpful in my mind because the field of a single dipole is so symmetric in a lot of ways that 3D images actually just confuse the issue and get in the way of each other.  If I got the chance to model multiple dipoles, I likely would have tried to keep their dipole moments (vectors normal to the center of the current loops) in the same plane (xz most likely, for consistency).  This way, at least in some regions, the field would still be independent of $\phi$, and thus the analysis of such fields would be simpler.

The 3D graphical limitations of Mathematica could be seen on some of my contour plots, especially those with the current loop shown as well, where the surface disappeared around the xy plane.  I expect this is due to the near horizontal nature of the contour at this point, and the rendering issues that come into play when plotting such an extreme surface.  The limitations (or just my inability to utilize Mathematica to its full extent) of VectorPlot3D and similar functions are pretty obvious in my case as they didn’t work well at all for the vector functions that I was trying to plot.

Despite these limitations and my Mathematica difficulties, I think that I managed to convey a good amount of information about the fields (and the less generally useful equipotential surfaces) of a single magnetic dipole.  Hopefully I also laid the groundwork for students in this class in the future to work on modeling magnetic dipoles, specifically multiple dipoles in complex configurations.  I also learned a lot about the benefits, frustrations, and limitations that Mathematica brings to the table as a computational scientific tool.

Share

Final Data

The next phase of my project involved actually creating some models of the magnetic field of a magnetic dipole.  This proved to require more steps and creativity than previously thought, but in the end I did get some useful plots.  The three finalized Mathematica files that I refer to throughout this post can be found via the link at the bottom of this post.

The first breakthrough I had was using a different technique to convert the expression for the magnetic field from spherical to cartesian coordinates so that Mathematica can plot some version of its information.  This technique worked way better than using Mathematica’s built in TransformedField function, which produced some weird results (see Preliminary Data post).  Instead, I decided, with the help of Shelly Johnson, to write out the explicit cartesian forms of $r$, $\theta$, and $\phi$ as well as the explicit spherical forms of $\hat{r}$ $\hat{\theta}$, and $\hat{\phi}$, and then let Mathematica substitute these expressions in the larger expression for the magnetic field.  This worked pretty well to give the three components of the magnetic field, $\vec{B_x}$, $\vec{B_y}$, and $\vec{B_z}$, as can be seen at the top of my Mathematica file titled “3D_vector_graphs.nb”.

When these expressions are plotted using VectorPlot3D, however, the results are pretty uninformative.

3D vector plot of the magnetic field of a magnetic dipole

3D vector plot of the magnetic field of a magnetic dipole

Even zoomed in and seen from a more right angle, this field is not helpful.

Same plot as above, but seen zoomed in and in the xz plane

Same plot as above, but seen zoomed in and in the xz plane

Since this approach didn’t work well, for reasons discussed more in my next Conclusion post, and my previous attempts at plotting the vector field at representative points was getting complicated as well, I decided to try to use this new transformation by substitution method to try Contour plots instead.

I began by forming one expression for the magnetic field value at points in space, with no vector information.  This expression ends up being pretty manageable, and the contours of this can be made effectively using ContourPlot3D.  Some different results are shown below, taken from my Mathematica file “3D_contour_graphs”.

3Dcontour1simple

3D contour of my expression for the magnitude of the magnetic field of a magnetic dipole. This contour is for when the magnetic field equals 1

The same plot as above, but this time zoomed in and shown "cut in half" to see what happens on the inside of the symmetric circular outer portion

The same plot as above, but this time zoomed in and shown “cut in half” to see what happens on the inside of the symmetric circular outer portion

These results are pretty promising, so I then added in a few more contours, to see how the different values looked relative to one another.

Similar plot to the above, but this time with three contours.  From the inner to outer contours, these surfaces represent the places where the magnitude of the magnetic field equals 0.75, 0.5, and 0.28 respectively.

Similar plot to the above, but this time with three contours. From the inner to outer contours, these surfaces represent the places where the magnitude of the magnetic field equals 0.75, 0.5, and 0.28 respectively.

This is pretty good, but where are these surfaces in relation to the small current loop that is supposed to be creating these magnetic field contours?  My next few contours include a small yellow ring at the origin, which indicates the placement of the loop, and also plots both positive and negative contours, which gives the whole picture both above and below the ring (which, looking at the original equation, should be symmetric).

The same three contours as above, along with their negative counterparts, and a small yellow ring representing the current loop that creates the magnetic field modeled.

The same three contours as above, along with their negative counterparts, and a small yellow ring representing the current loop that creates the magnetic field modeled.

A different view of the above graph, which allows one to look into the part of the contour that has been "cut open".

A different view of the above graph, which allows one to look into the part of the contour that has been “cut open”.

Now that there is a current loop in our models, what happens when the current in this loop is increased?  The above models were made with a magnetic dipole moment, $m=1$, but the below image increased the current so that $m=2$.

Similar plot to above, but with a stronger magnetic field (m=2).

Similar plot to above, but with a stronger magnetic field (m=2).

Putting images with $m=1$, $m=2$, and $m=3$ side by side shows that the same contours move farther away (and change curvature a bit) for models with larger values, which is expected because larger m values indicate larger magnetic fields.

 

A different view of the above graph, which allows one to look into the part of the contour that has been "cut open".Similar plot to above, but with a stronger magnetic field (m=2). 3dcontourmultiplebiggerB2                                              

From left to right, Contours with m = 1, m = 2, and m = 3.

This is all pretty good, but what are these contour surfaces actually telling us about the magnetic field?  These contour surfaces represent places where the magnitude of the magnetic field is at a constant value, so these shapes represent equipotential surfaces.  While equipotential surfaces are not often talked about when talking about magnetic fields, the general principle that field vectors are perpendicular to equipotential surfaces is true of magnetic fields as well as electric.  Therefore, these contours actually tell us something about the magnetic field of a dipole, albeit in an indirect manner.

To try and get a better picture of what the field lines look like around this current loop, I plotted these contour surfaces in 2D by removing any y dependence, so that the 2D contours plotted are shown in the xz plane.  This doesn’t lose much information again because of the $\phi$ independence of the magnetic field of a dipole.  The result is shown below, which is taken from my Mathematica file “2D_contour_graphs”.

2D contour, showing 20 different contour lines, both positive and negative.

2D contour, showing 20 different contour lines, both positive and negative.

This gives us a representation where the vector field lines may be easier to picture, and easier to compare to the lines shown in Griffiths’ “Introduction to Electrodynamics” 5.4.3 – pg. 255, which are shown in 2D.  It took some squinting, but I can see that lines perpendicular to these (and more) contour lines forms loops expected of a magnetic dipole.  I overlaid a few representative loops over my 2D contour image in paint to illustrate this idea.

Same image as above, but with (approximate) magnetic field lines overlaid in thick black.

Same image as above, but with (approximate) magnetic field lines overlaid in thick black.

Link to final Mathematica files: 3 Final Mathematica Files

Share

Preliminary Data

As I began working on this modeling project in Mathematica, it quickly became apparent that even just the magnetic field of a single magnetic dipole is pretty complicated to model.  Transforming between Spherical and Cartesian coordinates via Mathematica’s built in TransformedField function is more complicated than expected, and may even not work at all.

The expressions for $\vec{B_x}$, $\vec{B_y}$, and $\vec{B_z}$, get pretty complicated, as I found out when I began transforming them by hand to check against Mathematica’s TransformedField results.  The Mathematica files containing some of my current work can be viewed here.  The file named “transforming coordinates.nb” shows my attempts to use the TransformedField function to get the three Cartesian components of the general magnetic field equation, originally expressed in Spherical coordinates.  The fact that a 3D vector plot of the resulting expressions shows nothing leads me to believe something more involved is necessary to convert these expressions between Spherical and Cartesian coordinates.  I may try calculating the separate expressions for $\vec{B_x}$, $\vec{B_y}$, and $\vec{B_z}$ by hand, typing them all into Mathematica, and using these expressions to try to generate a 3D vector plot, but there may be easier and more informative ways of presenting the magnetic field information.

Professor Magnes suggested that I try looking at only a sample of representative points near the magnetic dipole, and evaluating the magnetic field expression,

$\vec{B} = \frac{\mu_0 m}{4 \pi r^3} (2 cos \theta \hat{r} + sin \theta \hat{\theta})$

at these points using the Spherical coordinates at first, and converting these points into Cartesian form before plotting a 3D vector plot.  Because of the nature of plotting vector fields in 3D in Mathematica, this may or may not prove to be less complicated.  Another option is presenting the field information in a different way, utilizing contour plots (ListContourPlot3D in Mathematica) instead of vector arrow plots.  A contour plot will show equipotential surfaces within the magnetic field instead of the arrows representing the magnitude and direction of the magnetic field at certain points.  However, the equipotential surfaces and vector arrows are intimately related: vector arrows are always perpendicular to equipotential surfaces.  Therefore, this may be an easier way to compute and show the magnetic field of a magnetic dipole.  Vector arrows can always be added on top of the contour plot to show the magnetic field in another way as well.  There are a lot of factors to play with to see what presentation style will be the most effective.

The other file in the link to my Mathematica work so far contains the start of generating a list of representative points around the origin in Spherical coordinates and the start of converting them into Cartesian coordinates using the CoordinateTransform function in Mathematica.  This file is currently quite preliminary.  I still have a long way to go before I get a graph presenting some information about the magnetic field of a magnetic dipole.

Share

Project Plan – Modeling the Magnetic Field of Magnetic Dipoles using Mathematica

Sources and Resources

My main source will be Griffiths Introduction to Electrodynamics (Fourth Edition), especially pages 253-255, where the magnetic dipole is first introduced and some equations are derived.  Especially important is Eq. 5.88,

$\vec{B} = \frac{\mu_0 m}{4 \pi r^3} (2 cos \theta \hat{r} + sin \theta \hat{\theta})$

which gives the magnetic field of a pure dipole in spherical coordinates.  In this equation, $m$ is the magnetic dipole moment, as defined in Eq. 5.86 in Griffiths

$\vec{m} \equiv I \int d\vec{a}$

 Mathematica 9 will be my main tool for modeling and presenting my results.

Initial Plans

I plan to start with modeling a single magnetic dipole, whose magnetic field (in spherical coordinates) is given by Eq. 5.88.  Mathematica 9 only works in Cartesian coordinates for 3D vector fields, so the Transformedfield function in Mathematica is important for converting from spherical to Cartesian coordinates.  I will also perform this conversion by hand as a check.

One potential problem I notice already is the visibility of a 3D magnetic field model.  Perhaps it is just for ease in printing textbooks, but most magnetic fields shown in Griffiths are only shown in 2D with magnetic flux lines.  As I begin to make some models, I will experiment with the different visibilities when using 3D vs. 2D vector fields, as well as using vector arrows vs. magnetic flux lines.  It may be that a 3D vector field of arrows is too complicated to actually get a sense of what is going on.  Changes in colors, arrow sizes, and arrow density will also help visibility.  I plan to model a small loop at the origin to represent the magnetic dipole itself, but this may just crowd the model even more.

After the single magnetic dipole model is a bit more set, I will move on to superimposing many magnetic dipoles together to create bigger shapes, such as a bar magnet or horseshoe magnet.  I don’t understand much about how this will work in Mathematica, but the result will be the numeric approximation of what the magnetic fields of these bigger shapes look like.  I know that looping structures in Mathematica will be important, but I have to learn more about how these work and how they will work for my benefit.

Collaborators

I am collaborating with Ramy Abbady and Tewa Kpulun, whose projects are very similar to mine in that they are modeling electric and/or magnetic fields of relatively simple geometries (spheres, cylinders, etc.).  We will compare our techniques and presentation styles to see what the best way to present our results is, as well as support each other in learning some more intricate parts of Mathematica 9 coding.

Timeline

Week 1 (4/7-4/13):  I plan to begin modeling the magnetic field of a single dipole and trying out different presentation styles.

Week 2 (4/14-4/20):  I plan to finish my model of a single dipole and decide which presentation style works best.  I also plan on starting to work out Mathematica looping structures and how they can be used to model complex combinations of magnetic dipoles in my project.

Week 3 (4/21-4/27):  I plan on finishing my Mathematica looping education, and beginning to model bar magnets of different sizes and horseshoe configurations.  If at all successful, preliminary results of more complex configurations of magnetic dipoles will be posted to the blog.

Week 4 (4/28-5/4):  I plan on finishing my complex models, and beginning preparation of my finalized results for the blog.

Week 5 (5/5-5/11):  I plan on finishing my final results for the blog and reading and commenting on the results of my peers’ projects.

Share

Project Proposal – Modeling the Magnetic Field of Magnetic Dipoles using Mathematica

For my project, I will work with Tewa Kpulun and Ramy Abbady on modeling vector fields of different geometries using Mathematica software. I plan on modeling the magnetic field $\vec{B}$ of a magnetic dipole with the eventual goal of modeling large scale magnet shapes.  I will begin by modeling a single magnetic dipole with a set magnetic moment $\vec{m}$ before modeling more complicated systems.  Eventually, I plan to superimpose many magnetic dipoles to create more complex magnetic geometries, such as a bar magnet or classic horseshoe magnet, possibly with regions where different internal currents create individual, unique magnetic dipoles.

Share