GS534: Solving the 1D Poisson equation using finite differences ...
GS534: Solving the 1D Poisson equation using finite differences ...
GS534: Solving the 1D Poisson equation using finite differences ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
The boundary conditions require special care. For x = 0 we hav e a Dirichlet boundary condition<br />
which allows us to fix <strong>the</strong> value u 1 = 0. For x = 1 we hav e a Neumann boundary condition<br />
du/dx = 0. This is a symmetry boundary condition, so that in this case we can imagine a ’ghost’<br />
point u N+1 which is always equal to u N−1 . This leads to <strong>the</strong> expression for point x N :<br />
u N = u N−1 + 1 2 (∆x)2<br />
(10)<br />
3. Iterative methods<br />
3.1. Jacobi and Gauss-Seidel<br />
A simple approach to solve <strong>the</strong> differential <strong>equation</strong> is to start with a ’guess’ and to use <strong>the</strong> stencil<br />
(9) on <strong>the</strong> internal points and taking care of <strong>the</strong> boundary conditions to iteratively improve on <strong>the</strong><br />
estimated solution. The algorithm is as follows:<br />
initialize a vector u<br />
until converged<br />
copy u to backup vector u old<br />
update u by applying (9) to <strong>the</strong> internal points <strong>using</strong> u old in right hand side<br />
update boundary condition values<br />
We can modify this ’strict’ Jacobi by not <strong>using</strong> a duplicate vector u old but ra<strong>the</strong>r working on u.<br />
This can save memory and has <strong>the</strong> advantage that that you use updated values whenever possible.<br />
Note that it may still be necessary to keep a duplicate vector around for checking on <strong>the</strong> convergence.<br />
A second modification is reached by recognizing that <strong>the</strong> stencil only uses nearest neighbors.<br />
In order to optimally update <strong>the</strong> values in <strong>the</strong> center points it would make sense to first do<br />
all even points, followed by all odd points. During this last step you would use <strong>the</strong> updated values.<br />
This is called Red-Black Gauss-Seidel, where <strong>the</strong> ’Red-Black’ term comes from imagining<br />
that each odd point is red and each even point is black. This concept is easily extended to 2D and<br />
3D. The algorithm is <strong>the</strong>n modified to:<br />
initialize a vector u<br />
until converged<br />
update u by applying (9) to <strong>the</strong> odd internal points<br />
update u by applying (9) to <strong>the</strong> even internal points<br />
update boundary condition values<br />
where you need to make sure that <strong>the</strong> boundary conditions are treated at <strong>the</strong> appropriate step in<br />
<strong>the</strong> algorithm.<br />
3.2. Iterative methods: successive overrelaxation<br />
The methods above are stable and easy to implement but converge very slowly except for very<br />
small problems (N small). In order to speed up <strong>the</strong> convergence we can use overrelaxation in<br />
which you make an overcorrection at each step in <strong>the</strong> Gauss-Seidel iteration. In our case this<br />
reads:<br />
u i ′= 1 2 [u i−1 + u i+1 − (∆x) 2 ]<br />
(11a)<br />
2