PHYCS 6730 Lab Exercise: Gauss Seidel with Relaxation
These exercises experiment with the solution to Poisson's equation
(actually the Laplace equation) using finite differences to represent
the Laplacian and Gauss-Seidel with relaxation to iterate to
convergence. The files you need are in
~p6730/exercises/gauss_seidel.
Exercise 1. Understanding the code
The code that solves the problem is in poisor.cc (stands for
Poisson with successive overrelaxation). Read through the code and
answer these questions:
- In how many dimensions is the problem solved?
- What is the grid size for the problem? How is it defined?
- What is the meaning of the "boundary", how is it defined, and how
does the code keep track of grid points that are on the boundary?
- What are the key statements that update the potential at a grid point?
- What value of omega corresponds to straight Gauss-Seidel with no relaxation?
- What is the convergence criterion?
Exercise 2. Running the code
The file data defines a 15 x 15 square grid and a pair of
capacitor plates extending part way into the grid at x = 9 and
x = 6. With such a setup the solution to the Laplace equation
gives the fringe fields around the edges of a parallel plate
capacitor.
Run the code, using the file data to specify the grid. Set the
tolerance to .001. Monitor the progress of the solution with omega
= 1 at the point (3,7), for example, or any other point you
choose. To monitor the progress, capture stdout and plot it.
Exercise 3. Optimizing the relaxation parameter
Find the range of relaxation parameters that allow convergence. Then
vary the parameter over the range 1 to 2 to find the parameter that
gives convergence in the fewest iterations.