The University of Queensland Homepage
UQ VisLab UQ VisLab

 2D Visualization of Electric Fields and Electric Potential of Point Charges
Tyrone Curtis

2DPointCharges.nb - Mathematica notebook (for Mathematica 5.1)
LabelContour.m - Mathematica package required to label contour plots.

Summary of notebook contents

This is a Mathematica notebook for plotting equipotentials and electric field lines for a series of point charges in the 2D plane.  Equipotentials are plotted using the standard Mathematica ContourPlot command, however extra commands found in the LabelContour package are used to label contours.  Field lines are plotted by numerically solving the differential equations of the electric field.  Please note that this notebook has been created using Mathematica Version 5.1.  As such there may be incompatibilities with earlier versions of Mathematica.

Currently the notebook creates a random charge distribution, however it is possible to specify your own charge distribution.  Instructions on how this is done are included in the notebook.

You are able to plot contour lines of the electric potential using two methods:

  1. The first method places contour labels on the contour lines, with no contour shading.    An example of this is shown in figure 1.

Contour plot with label

Figure 1 - Contour plot with labels on contour lines

  1. The second method produces the contour plot with shading, along with a legend alongside the plot to indicate the levels of each contour.  This is shown in figure 2.

Contour plot with legend
Figure 2 - Contour plot with legend



Both of these methods require commands found in the LabelContour package. 


This notebook also plots the electric field lines for the system - these are able to be plotted with or without a contour plot.  Examples of these are shown in figure 3.

Field lines without contour plot    or    Field lines with contour plot

Figure 3 - Field lines with and without contour plot.

Arrows are placed on the field lines indicating the direction of force on a positive charge.  It is possible to specify the number of field lines starting around each charge.  Positive charges are plotted in blue, negative charges in red and neutral charges in green.


The contour plots and field lines for a random charge distribution are shown in figure 4.

Field lines for random charge distribution

Figure 4 - Field lines and contour plot for random charge distribution