Assignment NP 3.03: Relaxation Method for a Square 2-D Box


Statement of the Problem

Determine the electrostatic potential phi inside a long box of square cross section, with the sides and bottom grounded and the top held at fixed potential Vo. Compare the Relaxation Method solution to the analytic solution.

The Relaxation Method

The Relaxation Method is one method that can be used to solve the equation the laplacian of phi = 0. For this square box problem, the 2-D box is divided up into 10x10=100 boxes. This is accomplished by using a 11x11 array where each cell in the array corresponds to the point where the points of four boxes meet (or a value on the edge of the suface of the 2-D box). At each point where the boxes meet, the relaxation method will calculate the potential. Addition of the potential from each of the closest corners to where the four boxes meet and dividing the number by four (the number of boxes) produces the desired potential. This calculated number is then stored in the first element of the array. This process is repeated until the potential has been calculated at each place where four boxes meet. This is one iteration. It is a very rough approximation of the solution. Repeating this entire process in the same order until the calculated potentials no longer changes out to a specified significant figure will produce a more accurate solution.

Using a revised version of Professor Bland's program called relax1.pro, I tried various number of interations. It was determined that around 73, 75 iterations, the contour graph does not appear to change anymore. Looking at the values of phi reveals that don't change much within two significant figures (sig figs) at 75 interations. Assuming that this is not good enough, let's try for three sig figs. Well, I'm out to 200 iterations and it's still not completely stable at 3 sig figs. The rate of change in phi in the 3rd sig fig is extremely slow. Therefore, I conclude that for two sifg figs, 75 iterations is pretty much where the potential no longer changes.

The Analytical Solution

The analytical solution is determined from the method of separation of variables. By using this method in rectangular coodinates, the solution was found to be:

    phi(x,y) = (sun over odd n) An sin(n*pi*x/a) sinh (n*pi*y/a)
    where An = 4*Vo/(n*pi*sinh(n*pi))

Substitution of phi into the equation laplacian of phi = 0 reveals that this solution for phi does indeed satisfy the equation. What about the boundaries? For x=0, the sine function is zero so that phi is zero. Check. For y=0, the hyperbolic sine function is zero so that phi is again zero. Check. For x=a, the sine function becomes sin(n*pi). For any n, this is zero. Check. For y=a, the hyperbolic sine function becomes sinh(n*pi). This poses no problem either. Check.

Using a revised version of Professor Bland's program called series1.pro, I tried various n values. It was determined that after n=27, the program incured an arithmetic error. The graph does continue to change at n values larger than 27 but not significantly enough to worry much about. I also check to see what the graph looks like when y is set to a. At first I was skeptical, but later I came to the conclusion that the graph seems to be converging to the correct solution as the value of n increases.

Comparison of the Relaxation Solution and the Analytical Solution

Both methods seem to have their weaknesses. For the relaxation method, depending upon how precise one wants to be determines how many iterations one needs to complete. This is can be quite a few if one wants precision to more than one or two sig fig and there is slow "convergence" as seen in this example. This can be time consuming. For the separation of variables method, one needs of calculate an infinite number of n values and to sum over them. This also is time comsuming if not humanly impossible at the moment.

Both methods have their strengths. For the relation method, one need not continue to iterate for eternity. If one only requires a couple of sig fig accuracy, this method yields very quite, and precise results. For the separation of variables method, usually one needs only to calculate a handful of terms to yield quite an accurate approximation.

Which method should one use? It depends upon what you want to know, where you want to know it, how accurate you want your answer to be, and what tools you have on had.