February 2, 26 Notes for Lecture Introduction to grid-based methods for solving Poisson and Laplace Equations Finite difference methods The basis for most grid-based finite difference methods is the Taylor s expansion: Φ(r + u) Φ(r) + u Φ(r) + 2! (u )2 Φ(r) + 3! (u )3 Φ(r) +! (u ) Φ(r) +. () We will work out some explicit formulae for a 2-dimensional regular grid with h denoting the step length. For the 2-dimensional Poisson equation we have 2 ρ(x, y) Φ(x, y). (2) ε We note that a sum of surrounding edge values gives: S A Φ(x + h, y) + Φ(x h, y) + Φ(x, y + h) + Φ(x, y h) (3) Φ(x, y) + h 2 2 Φ(x, y) + h 2 x + Φ(x, y) + (h 6...). y Similarly, a sum of surrounding corner values gives: S B Φ(x + h, y + h) + Φ(x h, y + h) + Φ(x + h, y h) + Φ(x h, y h) () ( Φ(x, y) + 2h 2 2 Φ(x, y) + h 6 x + y + 6 2 2 ) Φ(x, y) + (h 6...). x We note that we can combine these two results into the relation S A + S B 5Φ(x, y) + 3h2 2 2 Φ(x, y) + h 8 2 2 Φ(x, y) + (h 6...). (5) This result can be written in the form; Φ(x, y) 5 S A 2 S B 3h2 ρ(x, y) + h 2 ρ(x, y). (6) ε ε
Φ(x,a)V 2 3 Φ(,y) 5 6 Φ(a,y) 7 8 9 Φ(x,) Figure : 3 3 grid for solution of the Poisson equation within a 2-dimensional square. In general, the right hand side of this equation is known, and most of the left hand side of the equation, except for the boundary values are unknown. It can be used to develop a set of linear equations for the values of Φ(x, y) on the grid points. For example, consider a solution to the Laplace equation in the square region x a, y a which Φ(x, ) Φ(, y) Φ(a, y) and Φ(x, a) V. We will first analyze this system with a mesh of 9 points. In this case, φ 5 Φ( a 2, a 2 ) is unknown, while φ φ 2 φ 3 and φ φ 6 φ 7 φ 8 φ 9. For this example, Eq. 6 states φ 5 5 (φ 2 + φ + φ 6 + φ 8 ) + 2 (φ + φ 3 + φ 7 + φ 9 ) 3 V. (7) This results is within 2% of the exact answer of Φ( a 2, a 2 ).25V. If analyze this same system with the next more accurate grid, using the symmetry of the system Φ(x, y) Φ(a x, y), we have now 6 unknown values {φ 5, φ 6, φ 8, φ 9, φ, φ 2 } and boundary values φ φ 2 φ 3 and φ φ 7 φ φ 3 φ φ 5. This results in the following relations between the grid points: φ 5 5 (φ 2 + φ + φ 6 + φ 8 ) 2 (φ + φ 3 + φ 7 + φ 9 ), (8) φ 6 5 (φ 3 + φ 5 + φ 5 + φ 9 ) 2 (φ 2 + φ 2 + φ 8 + φ 8 ), (9) φ 8 5 (φ 5 + φ 7 φ 9 + φ ) 2 (φ + φ 6 + φ + φ 2 ), () φ 9 5 (φ 6 + φ 8 + φ 8 + φ 2 ) 2 (φ 5 + φ 5 + φ + φ ), ()
Φ(x,a)V 2 3 2 Φ(,y) 7 5 8 6 5 9 8 7 2 Φ(a,y) 3 5 3 Φ(x,) Figure 2: 5 5 grid for solution of the Poisson equation within a 2-dimensional square. φ 5 (φ 8 + φ + φ 2 + φ ) 2 (φ 7 + φ 9 + φ 3 + φ 5 ), (2) φ 2 5 (φ 9 + φ + φ + φ 5 ) 2 (φ 8 + φ 8 + φ + φ ). (3) These equations can be cast into the form of a matrix problem which can be easily solved using Maple: /5 /5 /2 φ 5 3/ 2/5 / /5 φ 6 3/ /5 /2 /5 /5 /2 φ 8 V / /5 2/5 / /5 φ 9. () /5 /2 /5 φ / /5 2/5 φ 2 The solution to these equations and the exact results are found to be: φ 5 φ 6 φ 8 φ 9 φ φ 2.62835839.55666769.92222635 V.26595573 ; (exact).759236.2532.3228338.5529283.8228338.25.67976687.95792 V. (5)
We see that the accuracy has improved considerably with the new mesh. Introduction to Finite element method The finite element approach is based on an expansion of the unknown electrostatic potential in terms of known grid-based functions of fixed shape. In two dimensions, using the indices {i, j} to reference the grid, we can denote the shape functions as {φ ij (x, y)}. The finite element expansion of the potential in two dimensions can take the form: πε Φ(x, y) ij ψ ij φ ij (x, y), (6) where ψ ij represents the amplitude associated with the shape function φ ij (x, y). The amplitude values can be determined for a given solution of the Poisson equation: by solving a linear algebra problem of the form 2 (πε Φ(x, y)) πρ(x, y), (7) M kl,ij ψ ij G kl, (8) ij where M kl,ij φ kl (x, y) φ ij (x, y) and G kl φ kl (x, y) πρ(x, y). (9) In obtaining this result, we have assumed that the boundary values vanish. In order for this result to be useful, we need to be able evaluate the integrals for M kl,ij and for G kl. In the latter case, we need to know the form of the charge density. The form of M kl,ij only depends upon the form of the shape functions. If we take these functions to be: where X i (x) φ ij (x, y) X i (x)y j (y), (2) { x x i h for xi h x x i + h otherwise and Y j (y) has a similar expression in the variable y. Then M kl,ij [ dxk (x) dx i (x) Y l(y)y j (y) + X k (x)x i (x) dy l(y) There are four types of non-trivial contributions to these values: xi +h xi +h, (2) ] dy j (y). (22) (X i (x)) 2 h ( u ) 2 du 2h 3, (23) (X i (x)x i+ (x)) h ( u)udu h 6, (2)
and xi +h xi +h ( dxi (x) ( dxi (x) ) 2 h du 2 h, (25) ) dx i+ (x) du h h. (26) These basic ingredients lead to the following distinct values for the matrix: 8 for k i and l j 3 M kl,ij for k i ± and/or l j ± 3 otherwise. (27) For problems in which the boundary values are, Eq. 8 then can be used to find all of the interior amplitudes ψ ij. In order to use this technique to solve the boundary value problem discussed above, we have to make one modification. The boundary value of Φ(x, a) V is not consistent with the derivation of Eq. (9), however, since we are only interested in the region y a, we can extend our numerical analysis to the region y a + h and require Φ(x, a + h) in addition to Φ(x, a) V. Using the same indexing as in Fig. 2, this means that ψ ψ 2 ψ 3 V. The finite element approach for this problem thus can be put into the matrix form for analysis by Maple: 8/3 /3 /3 /3 ψ 5 2/3 8/3 2/3 /3 ψ 6 /3 /3 8/3 /3 /3 /3 ψ 8 V 2/3 /3 2/3 8/3 2/3 /3 ψ 9. (28) /3 /3 8/3 /3 ψ 2/3 /3 2/3 8/3 ψ 2 The solution to these equations and the exact results are found to be: ψ 5 ψ 6 ψ 8 ψ 9 ψ ψ 2.5727698.587926267.9285729 V.27857286 ; (exact).7537788.92659.3228338.5529283.8228338.25.67976687.95792 V. (29) We see that the results are similar to those obtained using the finite difference approach.