• No results found

Numerical Methods for Solving PDE’s

In document Multi-fluid Plasma Modelling (Page 41-45)

Not every partial differential equation (PDE) can be solved exactly. Usually, approximate solutions to these PDE’s can be obtained in some limit. With the advent of computers, it has become feasible to calculate the solutions to arbitrary PDE’s to a resolution lim- ited only by the computational power and memory available. However, as both of these resources are finite, the domain over which the PDE is to be solved must be discretised. One common method for doing this is the finite-difference approximation.

In the finite-difference approximation, the domain is represented by a grid of points and the solution to the PDE is calculated (to a finite resolution) at each of these points. For example, for a PDE for a functionu(x, y), an (N+1)×(M+1) grid can be constructed by restricting the variablesx and y to:

xi=x0+i∆x i∈ {0,1,2, . . . N} (4.1)

yj =y0+j∆y j ∈ {0,1,2, . . . M}. (4.2)

4.1.1 Finite-difference Approximation

Once a discretisation is performed, a method is needed for approximating the derivative terms in the PDE. In the finite-difference approximation, partial derivatives are approx- imated by calculating the gradient between the values of the function at nearby points.

For example, first order derivatives can be approximated using a forward difference, ∂ f(x, y) ∂x ≈ f(x+ ∆x, y)−f(x, y) ∆x +O(∆x), (4.3) a backward difference, ∂ f(x, y) ∂x ≈ f(x, y)−f(x−∆x, y) ∆x +O(∆x), (4.4) or a centred difference, ∂ f(x, y) ∂x ≈ f(x+ ∆x, y)−f(x−∆x, y) 2∆x +O(∆x) 2. (4.5)

The centred difference is used whenever possible as it has the greatest accuracy, but when

f(x+ ∆x, y) orf(x−∆x, y) are unknown (for example, at the boundary of the domain), reverse or forward differences are used respectively.

Second order derivatives can be approximated similarly by a second-order centred difference, ∂2f(x, y) ∂x2 ≈ f(x+ ∆x, y)−2f(x, y) +f(x−∆x, y) (∆x)2 +O(∆x) 2. (4.6)

To give a concrete example, Laplace’s equation (∇2u = 0) in two dimensions can be

discretised under the finite-difference approximation as

∇2u≈ ui+1,j−2ui,j+ui−1,j

(∆x)2 +

ui,j+1−2ui,j+ui,j−1

(∆y)2 = 0. (4.7)

If the grid is chosen such that ∆x= ∆y, then Eq. (4.7) can be rewritten to give

ui,j =

1

4(ui+1,j+ui,j+1+ui−1,j+ui,j−1). (4.8) This equation represents a system of (N −1)×(M −1) algebraic equations where the value of the solution at any given point depends directly upon its nearest-neighbours, and through them, upon the rest of the grid. This system of equations can be solved when a boundary condition is specified. For the Laplace equation, this system of equations is linear. For more general PDE’s the system of equations will be non-linear.

Solving the system of equations represented by Eq. (4.8) (or its equivalent for another PDE) presents two challenges. The first is that for a large or non-linear system, Eq. (4.8) will need to be solved through an iterative process. One method for doing this is called the Gauss-Seidel (or Newton-Gauss-Seidel) method [48, p. 864] (discussed in §4.1.2), which can be optimised through the use of the Red-Black ordering [49] as discussed in §4.1.3. The second, more significant problem is that because each point is only directly coupled to its nearest-neighbours, it will take many iterations for changes to propagate across the entire grid. This problem can also be stated in terms of a Fourier decomposition: the short-wavelength components of the solution will converge much more rapidly than the long-wavelength components. One mechanism for dealing with this problem is known as the multigrid method, and is discussed in§4.1.4.

§4.1 Numerical Methods for Solving PDE’s 33

4.1.2 Newton-Gauss-Seidel Method

The Newton-Gauss-Seidel method is a method for iteratively solving a discretised form of a differential equation. This method can be demonstrated by examining the following general form for a discretised single-variable two-dimensional PDE:

αui,j +β = 0, (4.9)

whereα and β may depend on the nearest-neighbour values, and possiblyui,j itself if the

PDE is non-linear. During Newton-Gauss-Seidel iteration, each new solution is calculated using the residue of the above equation,

∆ =αui,j+β (4.10) 0 =α ui,j− ∆ α +β (4.11) =⇒ u0i,j =ui,j− ∆ α, (4.12)

where u0i,j is the new solution. The term ∆/αcan be thought of as the correction to the previous solution.

The convergence rate of this process (i.e. the rate at which ∆ → 0) is not always optimal, and can be improved through the use of an over-relaxation parameter. When using an over-relaxation parameter, a multiple of the correction to the solution (∆/α) other than 1 is used, i.e.

u0i,j =ui,j−ω

α, (4.13)

whereωis the over-relaxation parameter. For certain values of the over-relaxation param- eter, the rate of convergence for the above iterative scheme can be enhanced compared to whenω = 1. The over-relaxation parameter typically takes values in the range 0≤ω≤2, although ‘good’ values are problem-dependent and must be determined through numerical experimentation.

4.1.3 Red-Black Ordering

The Newton-Gauss-Seidel method can be made to converge faster if the new solutionu0i,j

is used instead of the old one to calculateαandβ in Eq. (4.9), whereu0i,j has already been calculated. One method of doing this is known as Red-Black ordering. In this method, each point is given a colour, either red or black (see Figure 4.1) such that if a given point is red, all its nearest-neighbours will be black, and vice versa. In an iterative scheme such as the one given in Eq. (4.8) on the facing page, the value of the new solution at each point can only depend upon the value at its nearest-neighbours, and possibly also its old solution. Thus in Figure 4.1, in each iteration, the value at each red point at the next iteration will depend only on the value at neighbouring black points and itself, and vice versa. The solution is then calculated through the following iterative method: the solution is calculated at all of the red points using the values at the black points, and then the solution is calculated at all of the black points using the values at the red points. This process is repeated until convergence is achieved.

One of the advantages of the Red-Black ordering over other orderings that could be used is that the value of the solution at the next iteration at each black point is completely independent of all other black points, and similarly for the red points. This enables

Figure 4.1: Red-Black iteration. The values at the black dots are calculated using the values at the red dots, and vice versa.

each half of the calculation to be completed in parallel, making the best use of available computational resources. In addition to the slower rate of convergence, the Newton-Gauss- Seidel method has another disadvantage — it requires both the old and new solutions to be kept in memory. The Red-Black and other orderings only require a single solution to be kept in memory, reducing the memory requirements of solving the problem by half.

4.1.4 Multigrid Method

Another mechanism to increase the convergence rate for iterative schemes is to use the multigrid method. The multigrid method is designed to solve the problem where the long- wavelength components of a solution converge much slower than the short-wavelength components. To resolve this problem, the PDE is solved numerically over a number of different grids of varying resolution, typically working from a coarse grid to a finer one (see Figure 4.2). Once the solution is found on one grid, the solution is then refined to be used as the initial guess for the next grid. In this way, the long-wavelength components of the solution can be made to converge quickly on the coarser grids, so that when the finer grids are reached it is only the short-wavelength components of the solution that need to converge.

Figure 4.2: Example of the multigrid method. Beginning initially on a coarse 3×3 grid, the problem is solved on the red dots before the grid is refined by the addition of the blue dots to create a 5×5 grid. Once the problem is then solved on this intermediate grid, the grid is refined by the addition of the yellow dots to create a 9×9 grid upon which the problem is solved again.

In document Multi-fluid Plasma Modelling (Page 41-45)

Related documents