MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Plotting magnetic field lines

  • To: mathgroup at smc.vnet.net
  • Subject: [mg4855] Re: Plotting magnetic field lines
  • From: Tom Wickham-Jones <twj>
  • Date: Thu, 26 Sep 1996 22:42:15 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

> >
> > Has anyone used Mathematica to plot
> > field lines?  Thanks.
> >
> 
> Couldn't that be formulated as a ContourPlot[]?

Field lines of a vector function can be plotted with a
combination of NDSolve and ParametricPlot.  In two-dimensions
the vector function gives {ex[x,y], ey[x,y]} pairs.
When a vector arrow plot is made,  such as with PlotVectorField
discrete arrows with x and y components of ex and ey are plotted.
The field lines are solutions of the differential equation...

	D[x,t] == ex[x,y]    D[y,t] == ey[x,y]

they can be seen as the trajectory of massless particles under
the influence of the field. ( Another name for field lines is
stream lines, also in wind tunnel experiments they are calculated
and observed by releasing smoke.)

This differential equation can be solved by NDSolve.  The
solution will be a pair of interpolation function objects.
One for the x[t] solution and the other for the y[t] solution.
These can then be plotted by ParametricPlot[{x[t], y[t]},{t,t0,t1}]
and the field line displayed.  Generally one would want to plot
a sequence of field lines to see how the vector function behaves
over some domain.

I wrote a package which is available on MathSource that will
calculate a field line given suitable input.  This is an
example of how to use it.


In[1]:= <<ExtendGraphics`FieldLines`

In[2]:= potential[{x1_, y1_}]  = 
    1/Sqrt[(x1-x)^2 + (y1-y)^2]        

                      1
Out[2]= -----------------------------
                      2            2
        Sqrt[(-x + x1)  + (-y + y1) ]

In[3]:= {ex, ey} = 
    -{D[potential[{1,1}], x], D[potential[{1,1}], y]}        

                    1 - x                        1 - y
Out[3]= {-(------------------------), -(------------------------)}
                   2          2 3/2             2          2 3/2
           ((1 - x)  + (1 - y) )        ((1 - x)  + (1 - y) )

In[4]:= lines = 
           Table[
              FieldLine[
                  {x, ex, 1 + 0.2 Sin[i]}, 
                  {y, ey, 1 + 0.2 Cos[i]},{t, 50}],
                    {i,0,2Pi-Pi/16,Pi/16}];
                                                

In[5]:= Show[
          Graphics[lines,
                    AspectRatio -> Automatic,
                    Frame -> True]]                            

Out[6]= -Graphics-

The package is available on MathSource as item 0205-041.
One way to contact MathSource is through the WWW with
http://www.wri.com/mathsource.


In my book, Mathematica Graphics: Techniques and Applications, 
I devoted a chapter to the visualization of vectors including
this topic of Field Lines.


Tom Wickham-Jones
WRI

==== [MESSAGE SEPARATOR] ====


  • Prev by Date: help for legend on 2-D graph.
  • Next by Date: Re: Peter Coffee article
  • Previous by thread: Re: Plotting magnetic field lines
  • Next by thread: Display a List of Graphics