Quadrapole Equipotentials in 3D

You do not have to evaluate any of the
commands in this notebook!

They have already been evaluated for you!

This file contains a number of commands that have already been executed to produce  the graphics below.  You should not have to re-evaluate any Mathematica commands to view this notebook.   The commands have been left in the text so that you can see how the figures were generated.  You may wish to refer to them yourself at some  time as an example.
    
       Here we first start up the Mathematic kernel. (Again, you do not need to execute this or any command in the notebook.)

2 + 2

We also need to load the file that defines the commands for 3D contour plotting  commands:

Needs["Graphics`ContourPlot3D`"]

First we define a function which gives us the potential of an electric quadrapole. The quadrapole consists of a charge of +2 flanked by two -1 charges.  We define this  function below:   The positive charge is placed at the origin, and the negative charges  are placed at (x=0,y=+/- 1,z=0).

Vq = 
      -((1/(Sqrt[(x^2) + (((y - 1))^2) + (z^2)])) + 
              (1/(Sqrt[(x^2) + (((y + 1))^2) + (z^2)]))) + 
        (2/(Sqrt[(x^2) + (y^2) + (z^2)]))

One way to proceed would be to use the command ContourPlot3D that will plotcontrour surfaces in 3D.  However, each time we execute the command, the computer would have to evaluate the potential at every point in the volume the plot portrays.If we want to draw several contours we want to first generate a table of values of  V(x,y,z), and then use that for all our plots.  The semicolon at the end of the  expression is important; it suppresses the output of the results to the screen.  If we did not include it, we would have over a thousand points printed to the screen.   We also force the results to be evaluated as numbers, not as symbolic square roots.

qpot = 
      Table[Vq, {x, -3.1, 3, .25}, {y, -3.1, 3, .25}, {z, -3.1, 
          3, .25}];

First let's plot the contour where the potential is zero.  ListContourPlot will take    our table of values and find the contour at any value of the potential we specify. We do   have to tell the command the range of x, y and z values for which the table of values    were calculated.  (The table ``qpot'' only conatins a list of values of Vq(x,y,z), it does not contain the actual values of x, y, and z at which they were calculated.)  The option PlotPoints sets the ``mesh'' for the surface.  A finer mesh gives more detail but takes a lot more time.   This one took about two minutes.

zero = 
      ListContourPlot3D[qpot, 
        MeshRange -> {{-3.1, 3}, {-3.1, 3}, {-3.1, 3}}, 
        PlotPoints -> {5, 7}, Contours -> {0.}]

Click on the figure with your mouse.  You should see a box appear about the figure.   Click and hold the mouse on the lower left corner of this box, on the black dot there.  Now drag your mouse so that you enlarge the size of the box.  When you release the  mouse button, Mathematica will redraw the figure scaling it to the box you have  specified.  This trick allows you to see the surface as it is being constructed by Mathematica.  It will allow you to see some features hidden by other surfaces.  Do this now.
           
                Below we draw the contour Vq(x,y,z)=1/2.  since it is a positive contour, it will be close to the positive charge at the center of the volume.  It will enclose this charge in  a little pill-shaped volume.  Note that the figure below is not drawn at the same  scale as the figure above.  We will fix that later.

plus = 
      ListContourPlot3D[qpot, 
        MeshRange -> {{-3.1, 3}, {-3.1, 3}, {-3.1, 3}}, 
        PlotPoints -> {5, 7}, Contours -> {0.5}]

Below we draw the surfaces defined by Vq(x,y,z)=-1/2.  Note that there are two of  them, each enclosing one of the negative point charges on the y-axis.

minus = 
      ListContourPlot3D[qpot, 
        MeshRange -> {{-3.1, 3}, {-3.1, 3}, {-3.1, 3}}, 
        PlotPoints -> {5, 7}, Contours -> {-0.5}]

Finally, below we show a plot with all of the surfaces shown together.  This is done  by combining our previous plots, using the Show command.  We cleverly named our plots before.  Now we can use these names to tell Mathematica to plot all of the surfaces together.  We can see one of the Vq=-1/2   contours, but the other one and the Vq=1/2 contour are hidden.  But if you click on the  figure, and resize it, you will see each surface as it is drawn: first the far negative   contour, then the far zero contour, then the positive, pill-shaped contour, the near   zero potential countour, and finally the near negative potential contour.  Give it a try!

total = Show[{zero, plus, minus}]

That's it!  have fun with the electrostatic hockey part of the assignment.