PHYS 306:  Computational Physics Lab

Winter 2009

Homework #1
(Due:  January 23, 2009)




Write a program to calculate and plot the field lines and equipotential curves due a collection of  nq = 6 charges q[i], with


     q[0] = q[2] = q[4] = 1.e-6;

     q[1] = q[3] = q[5] = -1.e-6;


Charges 0 through 4 lie on the vertices of a pentagon, with coordinates xq and yq given by


     xq[i] = cos(2*i*M_PI/5);

     yq[i] = sin(2*i*M_PI/5);


Charge 5 lies at the origin.


Start by plotting the charges as points and drawing the field lines (take $~n_\theta = 16~$ starting points per positive charge), with steps $\delta s = \min(0.02, 10^3 V/\vert{\bf E}\vert)$, as discussed in class. Use box limits of $-4 < (x,y) < 4$, and stop computing field lines that extend more than 4 units from the origin.

An equipotential line may be defined by


\begin{displaymath}
\frac{dX}{ds} = \mp\frac{E_y}{\vert{\bf E}\vert}
\end{displaymath}


\begin{displaymath}
\frac{dY}{ds} = \pm\frac{E_x}{\vert{\bf E}\vert}\,.
\end{displaymath}

It will be sufficient to use the same step $\delta s$ as in the field line computation. However, again as discussed in class, since the equipotential lines are closed loops, you will have to take special care to ensure that the calculation terminates.

Draw the equipotentials (in both directions from the starting point if the line gets too far from the origin and doesn't return) through the points $\{(x,\pm1), x = -4, -3,
-2, \ldots, 4\}$.

Turn in your program (or programs if you choose to perform the two calculations separately), as well as plots of the field lines and equipotentials, with the locations of the charges clearly marked. If possible, draw both sets of curves on a single graph.









Steve McMillan 2010-04-22