PHYS 306:  Computational Physics Lab

Winter 2009

Homework #4
(Due:  March 3, 2009)



  1. Do in-class exercise 7.1. Turn in your programs, as well as all requested output and graphs.

  2. Repeat part (b) of the previous problem, but instead use successive overrelaxation (SOR) at each iteration, that is, update according to the rule

    \begin{displaymath}
\phi^{(n+1)}_{ij} = {\textstyle\frac14}\omega
(\phi^{(n)}_...
...j+1}
+ \phi^{(n)}_{i,j-1})
+ (1-\omega) \phi^{(n)}_{i,j}\,,
\end{displaymath}

    where $\omega$ is the overrelaxation parameter. Obviously, $\omega=1$ corresponds to Gauss-Seidel relaxation. It can be shown that the optimal choice of $\omega$ for a square grid is

    \begin{displaymath}
\omega_{opt} = \frac{2}{1+\pi/N}\,.
\end{displaymath}

    For each $N$, iterate to convergence with $\omega$ = 1.5, 1.75, $\omega_{opt}$, and 2. In each case, how does $n_{iter}$ scale with $N$?

  3. (a) Following the development in class for Laplace's equation $\nabla^2\phi=0$, derive the equivalent differencing procedure for solving Poisson's equation:

    \begin{displaymath}
\nabla^2\phi = -\rho\,,
\end{displaymath}

    (where we have chosen units such that $\epsilon_0=1$). Show that the Jacobi algorithm becomes

    \begin{displaymath}
\phi_{ij}^{(n+1)} = {\textstyle\frac14}
(\phi^{(n)}_{i+1,j...
...i^{(n)}_{i,j-1})
+ {\textstyle\frac14}
\Delta^2\rho_{ij}\,,
\end{displaymath}

    where $\Delta$ is the grid spacing (assumed uniform in both $x$ and $y$), and $\rho_{ij} = \rho(x_i,y_j)$.

    (b) Solve this rescaled version of Poisson's equation in the square $-1<x<1$, $-1<y<1$, with $\rho=100$ for $(x-\frac14)^2 +
(y-\frac12)^2 < 0.01$, and $\rho=0$ otherwise. Apply boundary conditions $\phi=1$ for $\vert x\vert=1$, $\phi=-1$ for $\vert y\vert=1$. Use a $101\times101$ grid ($100\times100$ zones) to represent the solution, and iterate until $\max_{ij}\ \vert\phi_{ij}^{(n+1)} -
\phi_{ij}^{(n)}\vert < 10^{-4}$. As indicators of the solution,

    1. plot $\phi(0,y)$ for $-1<y<1$ and $\phi(x,0)$ for $-1<x<1$,
    2. plot the equipotential curves corresponding to $\phi=-0.8, -0.4, 0, 0.4$, and $0.8$, and
    3. construct a 2-D image representing $\phi(x,y)$ at the end of the calculation. [Use linear interpolation from the $\phi_{ij}$ grid to reconstruct the continuous function $\phi(x,y)$.]









Steve McMillan 2010-04-22