You are on page 1of 9

TWO NUMERICAL METHODS

DANIEL MARSHALL PHYSICS 400H PROJECT PROF. OHARA 02 FEBRUARY 20

Marshall 2 Introduction Central to the study of electromagnetism is the problem of solving continuum or field problems. There are three main approaches to solving these problems: experimental, analytical, or numerical. Experimental methods are of course usually the most time consuming and inconvenient. Analytical methods, though exact, have a narrow range of application and require much experience to apply efficiently. Common analytical methods include separation of variables, series expansion, conformal mapping, integral solutions, and perturbation methods. [1] Here are a few conditions that analytic techniques cannot handle: The partial differential equation in question is nonlinear The solution region is complex The boundary conditions are time-dependent The medium is inhomogeneous or anisotropic

When these and other complicating conditions are present, we have to use numerical methods. Numerical methods have an extremely wide range of applicability and can provide approximate solutions with sufficient accuracy for real life applications. The finite difference method and the finite element method are two widely used numerical techniques. I will summarize the approach of these two techniques and solve an example problem using the latter method. [2] Finite Difference Method The finite difference method (FDM) is the most widely used numerical method and arguably the easiest to apply and understand. The method was first developed in the 1920s by Thom to solve nonlinear hydrodynamic equations. The idea is to approximate the solution to a partial differential equation (PDE) by replacing the PDE with a finite difference approximation. A nite-difference equation relates the value of a dependent variable to the value of that same variable at neighboring points (so if you have the value of the dependent variable on a boundary, you could use the finite-difference equation to work out the values across the whole bounded region) There are a few definitions that are useful when constructing the finite difference approximation to a PDE. Referring to figure 1: Forward-difference formula estimates the derivative of the function at P by using the slope of arc PC. Backward-difference formula estimates the derivative of the function at P by using the slope of arc AP. Central-difference formula estimates the derivative of the function at P by using the slope of

Figure 1 arc AC.

Marshall 3 The second derivative at P can be found by applying the central-difference formula twice. These formulas are known as finite-difference approximations of a derivative. This same logic can be applied when approximating partial derivatives of a function of two or three variables you just define a grid across the region of interest and apply the same formulas and use two neighboring points (that would correspond to points A and C in Figure 1). Once we have these approximations to the partial derivatives of interest, we simply plug them into the PDE to obtain the finite difference approximation. As mentioned earlier, the finite difference approximation will relate the dependent variable to its value at neighboring points. The mathematics of the finite difference approximation to the PDE can be visually described by a computational molecule. For the two dimensional case, consider Figure 2. The goal is to determine the value of the solution to the PDE at each point on the grid. The six points contained in the gray box is an example of a possible computational molecule. Each iteration of the finite difference equation will relate three knowns (corresponding to the blue squares) to three unknowns (corresponding to the red squares). The Figure 2 known values will come from the boundary conditions. So the procedure in figure 2 would be to move the computational molecule across the bottom row, producing nine equations with nine unknowns. These would be solved and the process would repeat for the y = 1 row, then the y = 2 row, and so on. The shape of the computational molecule and the number of knowns and unknowns varies depending on whether a forward, backward, central or other variation of the difference formula was used when constructing the finite difference approximation to the PDE. There are various algebraic complications that can arise depending on the PDE in question and the density of the points where the solution function will be evaluated. As a result, though the method is relatively intuitive, the FDM is not always perfectly straight forward. [3] Finite Element Method Although the FDM is probably the easiest and most widely used numerical technique, the finite element method (FEM) is a more general and widely applicable technique. Unfortunately, the FEM is math heavy and requires a lot of notation (which makes it kind of annoying to learn). The approach of the FDM is to discretize the solution region, derive and assemble the governing equations of the elements, and then solve the resulting system of equations. As an example, let us consider the solution to Laplaces equation (2V = 0) in the summary that follows. There are many different shape unit cells you can choose from to discretize the solution region. For example, a common geometry is to assemble a grid of three-node triangles across the solution

Marshall 4 region (or a four-node tetrahedron in the 3-dimentional case). Discretization of the solution region is typically done by hand (though automatic discretization programs do indeed exist). Figure 3 shows a simple example of such a discretization. As indicated by the arrow, the local node numbering must proceed counterclockwise around the element (this is a matter of keeping the signs consistent in the algebra of the equations that follow). Some notation: Ve(x,y) corresponds to the potential specific to element e (where e = 1,2,3,). Vei corresponds to the potential at node i of element e. I will now summarize the derivation of the element governing equations. Our goal is to solve 2V = 0 for V the FEM will Figure 3 accomplish this by taking advantage of the fact that Laplaces equation is satisfied when the total energy in the solution region is minimized. For

triangular discretizations, it is most common to approximate the potential across each element as (1) This approximation is the same as assuming the electric field is constant across each element (Ee = -Ve). This brings to light an advantage of the FEM: the potential is approximated across the
entire solution region not just at a finite set of nodes as in the FDM. The constants a, b, and c will be determined by

(2)
After a massive amount of algebra, we can substitute the result of (2) into (1) to obtain

(3) where i(x, y), known as the element shape functions, are functions that contain x1, x2, x3, y1, y2, y3, and the area of the element1. Next, we consider the energy per unit length associated with the element:

I thought I would mention that there is nothing fancy about obtaining the element shape functions, you just work out the algebra of plugging in the constants a, b, and c (determined by equation 2) into equation 1. I chose not to explicitly define them since I am just summarizing.

Marshall 5

(4)
Where = r 0 and the integral is taken over the area of the element. We take the gradient of (3) and substitute into (4). With the introduction of some new notation, the result of this substitution can be compactly expressed as: (5) where [Ve] is a column vector whose entries are the potentials at each node of the element, and [C(e)] is the element coefficient matrix (since I am just summarizing, I will not explicitly write out [C(e)] its entries depend on the area of the elements and the coordinates of the nodes ). The entries of [C(e)] can be considered to couple together the individual nodes of each triangular element. Equation (5) is the element governing equation that we set out to find. The next step is to sum together the result of equation (5) applied to each element. We obtain a very similar looking equation: (6) where [V] contains the potential approximations of each element (the values we set out to find) and [C] is the global coefficient matrix. The global coefficient matrix is assembled through a process that uses the entries of all the individual element coefficient matrices in such a way that the potential distribution is continuous across interelement boundaries. As mentioned at the start, the final step of the process uses the fact that Laplaces equation is satisfied when the total energy in the solution region is minimized. As a result, it is required that (7) This results in a set of simultaneous equations (where the unknowns are the potentials across each element) which can be solved to obtain the approximate solution of Laplaces equation. The iteration method and the band matrix method are two common algorithms for solving the resulting system of equations. [4] Example Problem2 Solve Laplaces equation using the FEM for the two dimensional problem shown in Figure 4. The red numbers correspond to the element numbers and the gray numbers correspond to the node numbers. In the solution (where I have used MATLAB), there are three main steps. Step one consists of inputing all the data that defines the geometry of the descretized solution space. Step two geneates the
2

This example is based on example 6.2 of -- Sadiku, Matthew N. O.. Numerical Techniques in Electromagnetics with MATLAB. Boca Raton, FL: CRC, 2009. Print. p 393-398.

Marshall 6 global coefficient matrix. Step three uses the iteration method to solve the resulting system of equations. If this program were used to solve Laplaces equation for a completely different geometry, the coding of steps two and three would remain mostly unchanged. Figure 4

Figure 4

Marshall 7

Marshall 8 The resulting approximation at each node is displayed:

Marshall 9 References [1] Sadiku, Matthew N. O.. Numerical Techniques in Electromagnetics with MATLAB. Boca Raton, FL: CRC, 2009. Print. p 1. [2] Sadiku, Matthew N. O.. Numerical Techniques in Electromagnetics with MATLAB. Boca Raton, FL: CRC, 2009. Print. p 119. [3] Sadiku, Matthew N. O.. Numerical Techniques in Electromagnetics with MATLAB. Boca Raton, FL: CRC, 2009. Print. pp 119-126. [4] Sadiku, Matthew N. O.. Numerical Techniques in Electromagnetics with MATLAB. Boca Raton, FL: CRC, 2009. Print. pp 379-389.

You might also like