Chapter 5

Numerical Methods

Quantitative analyses are essential elements in solving forward and inverse problems. To utilize computers, we should devise numerically implementable algorithms to solve given problems, which include step-by-step procedures to obtain final answers. Formulation of a forward as well as an inverse problem should be done bearing in mind that we will adopt a certain numerical algorithm to solve them. After reviewing the basics of numerical computations, we will introduce various methods to solve a linear system of equations, which are most commonly used to obtain numerical solutions of both forward and inverse problems. Considering that most forward problems are formulated by using partial differential equations, we will study numerical techniques such as the finite difference method and finite element method. The accuracy or consistency of a numerical solution as well as the convergence and stability of an algorithm to obtain the solution need to be investigated.

5.1 Iterative Method for Nonlinear Problem

Recall the abstract form of the inverse problem in section 4.1, where we tried to reconstruct a material property P from knowledge of the input data X and output data Y using the forward problem (4.1). It is equivalent to the following root-finding problem:

images

where X and Y are given data.

We assume that both the material property P and F(P, X) are expressed as vectors in N-dimensional space images. Imagine that P* is a root of G(P) = 0 and P0 is a reasonably good guess in the sense that P0 + ΔP = P* for a small perturbation ΔP. From the tangent line approximation, we can approximate

images

where J(P0) denotes the Jacobian of G(P) at P0. Then, the solution P* = P0 + ΔP can be approximated by

images

The Newton–Raphson algorithm is based on the above idea, and we can start from a good initial guess P0 to perform the following recursive process:

5.1 5.1

The convergence of this approach is related to the condition number of the Jacobian matrix J(P*). If J(P*) is nearly singular, the root-finding problem G(P) = 0 is ill-posed. According to the fixed point theorem, the sequence Pn converges to a fixed point P* provided that Φ(P): = P − [J(P)]−1G(P) is a contraction mapping: for some 0 < α < 1,

5.2 5.2

To be precise, if Φ is a contraction mapping satisfying (5.2), then

images

Hence, {Pn} is a Cauchy sequence, which guarantees the convergence PnP*. Here, P* is a fixed point, Φ(P*) = P*. Owing to the convergence of the recursive process (5.1), we can compute an approximate solution of the root-finding problem G(P) = 0.


Example 5.1.1
Let Φ(x) = cosx. With the initial point x0 = 0.7, let xn+1 = Φ(xn), n = 0, 1, 2, …. Prove that the sequence xn converges to a point x*, where x* is a fixed point, x* = ϕ(x*).

5.2 Numerical Computation of One-Dimensional Heat Equation

We begin with a simple problem of solving the following one-dimensional heat equation with the thermal diffusivity coefficient κ > 0:

5.3 5.3

To compute an approximate numerical solution of u(x, t) in (5.3), we discretize xt-space into a collection of grid points and express u in the following discrete form:

images

where Δx = 1/N and the superscript n and subscript k, respectively, specify the time step and the space step. The quantity ∂tu can be approximated by the first-order time derivative using a finite difference scheme of the two-point Euler difference:

images

where ∂tu|k, n = ∂tu(kΔx, nΔt).

The expressions for the space derivatives can be obtained by Taylor's expansion.

  • Forward difference:

images

images

  • Backward difference:

images

images

  • Central difference:

images

Here, the “big O” notation ϕ(x) = O(η(x)) is used to describe the limiting behavior of the function ϕ such that

images

Using three-point central difference schemes to approximate the second-order space derivative, we get the following recurrence relations.

  • Explicit scheme or forward Euler method: images (the temperature at time n + 1 and position k) depends explicitly on images at the previous time n using the relation

images

  • Implicit scheme or backward Euler method: the Laplacian (∂2u/∂x2)|k, n+1 and images at time n + 1 are evaluated from the implicit relation

images

  • Crank–Nicolson scheme: we use the average of the explicit and implicit schemes

images

With the explicit scheme, the diffusion equation in (5.3) can be expressed as

5.4 5.4

Here, the last term can be viewed as the truncation error (or discretization error), which is the difference between the solution of the explicit scheme equation and the exact analytic solution.


Exercise 5.2.1
Denote the truncation error by

5.5 5.5

Show that the truncation error images can be expressed as

5.6 5.6

where images and images. Show that the principal part of the local truncation error is

images


When using a specific computational scheme, we should check the following fundamental conditions.

  • Convergence. Does the numerical solution images converge to the true solution u?
  • Consistency. Does the discretization error go to zero as Δt, Δx → 0?
  • Stability. Do small errors in the initial and boundary conditions cause small errors in the numerical solution?

5.2.1 Explicit Scheme

In the explicit scheme, it is easy to compute numerical solutions because it is explicit. However, computational experience shows that, depending on the size of κ(Δx)2t, numerical errors (round-off and truncation errors) can be magnified as the iterative computations progress in time. It is well known that this explicit method requires images in order to be numerically stable. Owing to this requirement, it is computationally expensive.

If we substitute the approximations into images and ignore the higher-order terms Ot) and Ox2), we obtain the following system of difference equations for interior grid points:

images

This formation is called the explicit forward Euler method because the time derivative is represented with a forward Euler approximation. The solution at time t = nΔt can be solved explicitly as

5.7 5.7

or

5.8 5.8

where images. Since u in (5.3) has homogeneous boundary conditions,

5.9 5.9

From the above formula, we can directly compute un, an approximate solution u(x, Δt), from the discrete version of the initial condition u0 (a discrete form of u(x, 0) = f(x)). This step-by-step time advancing process (5.8) is called time marching since the unknown values un+1 at the next time n + 1 are directly computed from the computed values un at the previous time n. According to (5.4), the computed solution by the time marching scheme (5.8) can be Ot) accurate in time and Ox2) accurate in space.

We should note that the exact solution images of the discretized problem (5.7) may not be an accurate approximate solution of the original continuous heat equation even if Δx and Δt are sufficiently small. The stability of a numerical scheme is closely associated with numerical errors. Hence, we need to check the error images between the numerical solution images of the finite difference equation (5.7) and the true solution images, with u being the solution of the continuous equation (5.3). From (5.7) and (5.5), the error images can be expressed as

images

If images, the error images is estimated by

images

Since the above estimate holds for all k and n, we obtain

5.10 5.10

We should note that, as Δt → 0, images. The estimate (5.10) shows that images converges to the true solution u as Δt → 0 provided r < 0.5. The numerical errors are proportional to the time step and to the square of the space step. For details, please refer to Haberman (1987).


Theorem 5.2.2
The explicit scheme (5.7) is stable provided that the value of the gain parameter r defined in (5.7) satisfies

images


 


Exercise 5.2.3
The Von Neumann stability criterion is a method to check the stability condition by inserting the Fourier mode images into the finite difference scheme (5.7):

images

A necessary condition for stability can be obtained by restricting Δx and Δt such that |λ| ≤ 1, that is, λn will not grow without bound.
1. Derive an expression for λ for stability:

images

2. Show that images implies |λ| ≤ 1.

 


Exercise 5.2.4
We can obtain a stability condition using the discrete Fourier transform (DFT). Recall that the DFT of a vector images is a vector images with images being

images

We can apply the same DFT to

images

1. Show that

images

2. Denote ξm = 2mπ/N and show that

images

3. Show that application of DFT to (5.7) leads to

images

where r = κN2Δt = κΔtx2.
4. For stability, we need

images

Hence, a sufficient condition for stability is images.

Unfortunately, the numerical solution is unstable when images no matter how small Δx and Δt are. If images, the error images may grow with the time step n. This is the major shortcoming of the explicit method. Now, we present the Lax equivalence theorem (Lax and Richtmyer 1956), which plays an important role in determining the convergence of a solution of the finite difference method to a solution of the partial differential equation (PDE).


Theorem 5.2.5 Lax equivalence theorem
For a consistent difference scheme of a well-posed linear initial value problem, the method is convergent if and only if it is stable.

5.2.2 Implicit Scheme

The major shortcoming of the explicit method is the time step constraint Δt < [1/(2κ)]Δx2 to guarantee the stability so that the computed solution images is a good approximation to the true solution u(xk, tn). Using the explicit scheme or forward Euler method, the numerical solution images may blow up if the time step does not satisfy the constraint Δt < [1/(2κ)]Δx2.

We can remove the time step constraint Δt < [1/(2κ)]Δx2 of the forward Euler method by the use of the implicit scheme or backward Euler method:

5.11 5.11

where we evaluate the approximation for uxx at tn+1 = (n + 1)Δt rather than at tn. This implicit backward Euler method leads one to solve the following implicit linear system:

5.12 5.12

where

images


Exercise 5.2.6
Prove that the backward Euler method (5.11) is unconditionally stable. Inserting the Fourier mode images into the implicit scheme, find the following expression for λ:

images


Since the matrix A in (5.12) is diagonally dominant, the implicit scheme is always numerically stable and convergent regardless of the choice of the time step. This is the major advantage of the implicit backward Euler method over the explicit forward Euler method (5.7). On the other hand, the implicit method requires a computation of the inverse matrix A at each time step and, therefore, it is computationally more intensive.

5.2.3 Crank–Nicolson Method

The Crank–Nicolson method combines the forward and backward Euler methods as

images

When images, the scheme is called the Crank–Nicolson scheme.


Exercise 5.2.7
Show that the Crank–Nicolson scheme is unconditionally stable.

We can summarize the following features.

  • For β = 0, the scheme is explicit. It is stable under the condition Δt ≤ [1/(2κ)]Δx2. Owing to this constraint, the time step has to be chosen small enough.
  • For β ≠ 0, the scheme is implicit. The scheme for β = 1 is unconditionally stable.
  • When images, the scheme is the Crank–Nicolson scheme, which is unconditionally stable.

5.3 Numerical Solution of Linear System of Equations

Finding a numerical solution of a forward problem and also an inverse problem often requires solving a system of linear algebraic equations,

images

for u. We can view a solution u of the system as a minimizer of the following functional:

images

Assuming that A is invertible, we consider a quantitative bound for the error in the computed solution of the linear system. We define the norm of the matrix A as

images

With u being the solution of Au = b and u + Δu being the solution of A[u + Δu] = b + Δb, we have

images

where cond(A) is called the condition number of the matrix A, indicating an amplification factor that bounds the maximum relative change in the solution due to a given relative change in the vector on the right-hand side.

5.3.1 Direct Method using LU Factorization

The most common direct method of solving Au = b is LU-factorization with forward and backward substitutions. By applying the Gaussian elimination process, we can express the matrix A as

images

where L is a unit lower triangular matrix and U is an upper triangular matrix. We summarize the process to find L and U as follows:

i. A[1] = [aij].
ii. images.
iii. Given images of the form

images

A[k+1] is determined from

images

where

images

Then,

images

Given such an LU-factorization, we can solve the system Au = b via the forward and backward substitutions. Such direct methods are usually applied to the cases where the size of the matrix A is relatively small.

5.3.2 Iterative Method using Matrix Splitting

When the problem Au = b is too large, one may use an iterative method by generating a sequence unu with a low computational cost. The most commonly used iterative methods for solving Au = b are based on the decomposition of the matrix A into two parts A = B + (AB) so that the linear system Au = b can be rewritten as

images

Then, we set the iteration scheme as follows:

5.13 5.13

An iterative method expressed in the form of (5.13) is called the stationary iterative method. For the choice of B in the stationary iterative method, we use the decomposition

images

where D is the diagonal part of A and L and U are the lower and upper triangular matrices with zeros on their diagonals, respectively. The most common stationary iterative schemes are as follows.

  • Jacobi method: with B = D and G = D−1(L + U), the iterative scheme is

images

  • Damped Jacobi method: use G = (I − ωD−1A) with the damping factor ω to get the iterative scheme

images

  • Gauss–Seidel method: use G = − (L + D)−1U to get

images

  • Successive over-relaxation (SOR) method: use images to get

images

with the relation factor ω > 1.

Definition 5.3.1
The set σ(G) of all eigenvalues of the matrix G is said to be the spectrum of G. The value ρ(G) = maxλ∈σ(G)|λ| is called the spectral radius of G.

Throughout this section, we assume that the stationary iterative scheme (5.13) is consistent with Au = b, that is,

5.14 5.14

From (5.13) and (5.14), we have

5.15 5.15

The above identity leads directly to the following theorem.


Theorem 5.3.2
For any initial guess u0,

images


To be precise, assume that G has N linearly independent eigenvectors v1, …, vN with associated eigenvalues λ1, …, λN and that |λN| = ρ(G). Then, from (5.15), we have

images

and, therefore,

images

Hence, the spectral radius ρ(G) measures the speed of convergence when ρ(G) < 1.


Exercise 5.3.3
Show that the Jacobi method un+1 = (ID−1A)un + D−1b converges whenever A is strictly diagonally dominant, that is, unu if

images


 


Exercise 5.3.4
Let un+1/2 = (ID−1A)un + D−1b denote the result of the Jacobi method. Show that the damped Jacobi method is

images

where ω is a damping factor.

 


Exercise 5.3.5
Derive the Gauss–Seidel method using

images


The successive relaxation (SR) method is

images

The condition 0 < ω < 1 is called under-relaxation, whereas the condition ω > 1 is called over-relaxation. The choice of ω for faster convergence depends on the structure of A.

5.3.3 Iterative Method using Steepest Descent Minimization

Throughout this section, we assume that A is a real symmetric N × N matrix. We can iteratively solve Au = b by searching for a solution of the following equivalent minimization problem:

images

Then, Au = b if and only if

images

From the above equivalence relation, we have the following: if A is positive definite, then Au = b if and only if u minimizes the energy functional Φ(v). The minimum value of Φ is Φ(A-1b) = images.


Exercise 5.3.6
Consider

images

Show that the minimizer of Φ in images is the solution of the linear system

images


The steepest descent method to find u = A−1b is to search for a minimum point of Φ by traveling in the steepest descent direction of Φ. It is important to note that the residual vector r = bAv associated with any vector v points in the steepest descent direction of Φ. Taking an iterative step in the steepest descent direction leads us to approach the minimum point u = A−1b. The following updating steps describe the general procedure:

1. Start with an initial guess u0.
2. Compute the steepest direction r0 = − ∇Φ(u0) = bAu0.
3. Search for the lowest point u1 = u0 + κ0r0 along the line defined by u0 + κr0, with κ variable. To be precise,

images

4. Compute a new search direction r1 = − ∇Φ(u1).
5. Repeat the previous steps to get a minimizing sequence {um} in such a way that

5.16 5.16

For the convergence analysis of the steepest descent method, note that

images

Hence, (5.16) can be expressed as

5.17 5.17

Denoting em: = umu, (5.16) can be written as

5.18 5.18

For an intuitive understanding of the rate of convergence of the steepest descent method, we should note that the error em = umu measures the difference in the domain space, whereas the residual rm = A(uum) = − ∇Φ(um), indicating the steepest descent direction, measures the difference in the range space.

We can get a convergence analysis using eigenvectors v1, …, vN of A (assumed to be an orthonormal basis in images) with associated eigenvalues λ1, …, λN, ordered so that |λ1| ≤ ··· ≤ |λN|. Assume that

images

From (5.18), we have

images

where

images

Now, consider the following two special cases.

  • In the special case of e0 = vj,

images

From (5.18), we have

images

Therefore, u1 is the exact solution.
  • If λ1 = ··· = λN, then images and hence u1 is the exact solution.

The following exercise explains the rate of convergence of the steepest descent method.


Exercise 5.3.7
Prove the identity

images

where

images

Using the above identity, show that

images


The above exercise explains that the steepest descent method can converge very quickly when α ≈ 0. Note that α ≈ 0 if either λN1 ≈ 1 or e0 is close to an eigenvector.

However, the rate of convergence would be very slow when |λN|/|λ1| is large. In the case where |λN|/|λ1| ≈ ∞, it is possible that the steepest descent direction rm from a given point um is very different from the direction pointing to the true solution u. The worst case is when e0 ≈ λNv1 + λ1vn, and this causes a sluggish performance of the steepest descent method in which the iterative scheme takes many short and inefficient switchbacks down to the valley floor. It may include steps with the same directions as those in earlier steps.


Remark 5.3.8
We revisit the steepest descent method by considering an iterative method to solve the minimization problem:

images

where Φ is a convex function. Given an initial approximation images of the exact solution u, we find successive approximations images of the form

5.19 5.19

where images is a search direction and αk > 0 is a step length. By Taylor's theorem,

images

where u lies on the line segment between uk and uk+1. This implies that

images

If we choose dk = − ∇Φ(uk) ≠ 0, then for a sufficiently small αk we have

images

To choose the step length αk, we may determine αk so that

images

in which case αk must satisfy

5.20 5.20


5.3.4 Conjugate Gradient (CG) Method

To deal with inefficient switchbacks in finding u = A−1b using the steepest descent method, the conjugate gradient (CG) method was proposed by choosing new search directions taking account of the progress in previous ones. Throughout this section, we assume that A is symmetric and positive definite. Two vectors v and w are conjugate with respect to A if they are A-orthogonal:

images

To understand the key idea of the CG method, we pick orthogonal search directions d0, d1, …, dN−1 and choose

images

Then, eN = 0 and uN must be the exact solution of Au = b. This procedure requires at most N steps to compute u provided that κm is computable. Unfortunately, we cannot compute uN since the computation of κm requires the unknown quantity u.

To deal with this problem, we use the fact that Aem is computable though em is not, and make the search direction A-orthogonal instead of orthogonal. Suppose that a1, …, aN−1 are A-orthogonal:

images

Our new requirement is that

images

It is crucial to observe that κm is computable as

images

Now, we need to determine the A-orthogonal basis set {a0, …, aN−1}. It is not desirable to use the Gram–Schmidt method since the process is roughly equivalent to performing Gaussian elimination. In the CG method, the search directions are constructed by conjugation of the residuals. We choose the search direction of the vector form

images

and hence

images

This choice makes sense for many reasons.

1. Residual rm = − ∇Φ(um) and pm = rm + ··· contains the steepest descent direction at um.
2. We have rm · pm−1 = 0 because of the choice of κm−1 = 0, that is,

images

3. We require that the minimization along the line um + κpm does not undo the progress in searching the direction pm−1. Hence, we choose the parameter βm so that pm+1 is A-conjugate to pm:

images

4. Assume u0 = 0. Then,

images

where images is called a Krylov subspace.

Now, we are ready to explain the basic CG algorithm. Let images be symmetric and positive definite. The following algorithm solves Au = b starting with the initial guess u0:

1. r0: = bAu0;
2. p0: = r0;
3. for m = 1, 2, …, n,
a. images,
b. um: = um−1 + κm−1pm−1,
c. rm: = rm−1 + κm−1Apm−1,
d. images.

For detailed explanation for this method, see Allen et al. (1988). We may view the CG method as a method between the steepest descent and Newton's methods. Since each search direction pm is A-conjugate to all previous search directions, the CG algorithm requires at most N iterations to converge so that uN must be the exact solution from the theoretical point of view. However, in practice, when N is large, we need to take account of numerical round-off errors, and it is possible that the exact solution is never obtained.

Since the error em = uum satisfies

images

the basic CG method may show poor performance for a large condition number images. These observations motivated the use of a preconditioner. The idea is to replace

images

where B−T is the transpose of B−1. To be precise, define G(x): = Φ(Bv) with x = Bv. Then, it is easy to see that

images

and

images

which is equivalent to

images


Example 5.3.9 (Preconditioned conjugate gradient algorithm)
Let images be a symmetric and positive definite matrix. Let τ > 0 be a convergence tolerance on ||rm|| = ||bAum||. The preconditioned CG algorithm is as follows:
1. r0 = bAu0;
2. p0: = r0;
3. for m = 1, 2, …,
a. images,
b. um: = um−1 + κm−1pm−1,
c. rm: = rm−1 + κm−1Apm−1,
d. if ||rm|| > τ, then
i. solve BTBym = rm for ym,
ii. images,
iii. m: = m + 1,
iv. go to 3(a).

5.4 Finite Difference Method (FDM)

5.4.1 Poisson Equation

We examine numerical techniques to find a solution for the Poisson equation in a two-dimensional rectangular domain Ω = {(x, y):0 < x < a, 0 < y < b}:

5.21 5.21

The simplest way to solve (5.21) is to convert it to an equivalent system of difference equations using a finite difference approximation. Let Δx = a/m and Δy = b/n denote the step size in the x and y directions, respectively. Let

images

Let uk, j denote the computed value of u(xk, yj). To convert the Poisson equation uxx + uyy = f into a difference equation, we use finite difference approximations for the second derivatives. The three-point central difference approximations for the second derivatives are

images

Ignoring the higher-order terms, we get the following system of difference equations for the interior grid points:

5.22 5.22

where fk, j = f(xk, yj) and gk, j = g(xk, yj).

We often take the square grid as Δx = Δy = h. Then, we may conveniently write the structure of the five-point approximation in terms of the following stencil as

images

The problem of the system of difference equations can be written as the following linear system.

  • Let u = [u1, 1, …, u1, n−1, u2, 1, …, um−1, n−1].
  • Let A be the (m − 1)(n − 1) × (m − 1)(n − 1) square matrix:

images

where I is the (n − 1) × (n − 1) identity matrix and B is the (n − 1) × (n − 1) matrix

images

  • The finite difference system (5.22) can be written as

5.23 5.23

where f = [f1, 1, …, f1, n−1, f2, 1, …, fm−1, n−1] and BC is the corresponding boundary condition.

5.4.2 Elliptic Equation

Assume that Ω is a square region in images. We will explain a discretized version of the elliptic equation:

images

We divide Ω uniformly into N × N subsquares Ωi, j with the center point (xi, yj), where i, j = 0, …, N − 1. We assume that the conductivity σ is constant on each subsquare Ωi, j, say σi, j:

images

The solution u can be approximated by a vector images such that each interior voltage uk where k = i + jN is determined by the weighted average (depending on the conductivity σ) of the four neighboring potentials. To be precise, the conductivity equation ∇ · (σ∇u(r)) = 0 can be written in the following discretized form:

5.24 5.24

with

5.25 5.25

where images denote north, south, east and west neighboring points of the kth point. The discretized conductivity equation (5.24) with the Neumann boundary condition g can be written as a linear system Au = g, where g is the injection current vector associated with g.

5.5 Finite Element Method (FEM)

The finite element method (FEM) is a useful tool to compute an approximate numerical solution of a PDE (Johnson 2009). This section summarizes the FEM to find an approximate solution of a PDE.

5.5.1 One-Dimensional Model

We explain Galerkin's method for solving the following elliptic equation as an example:

5.26 5.26

The weak form of (5.26) is

5.27 5.27

where ϕ satisfies ϕ(0) = 0. Galerkin's method discretizes the weak form (5.27). Let h = 1/N and define Vh as follows:

images

As shown in Figure 5.1, we choose ϕ1, …, ϕNVh such that

images

Then, the finite element space is images.

Figure 5.1 Basis functions

5.1

We look for an approximate solution

5.28 5.28

Substituting images into (5.27) yields

5.29 5.29

The identity (5.29) can be written as the following matrix form:

5.30 5.30

where A is an N × N matrix given by

images

images

The matrix A is sparse:

  • If |ij| > 1, then images, and hence

images

where * denotes a non-zero value.
  • If ji = 1, then images.
  • If i = jN, then images.
  • If i = j = N, then images.

5.5.2 Two-Dimensional Model

Let Ω be a domain in the two-dimensional space images with smooth boundary ∂Ω and let σ be a positive bounded function in Ω. For a given images, we consider the Neumann boundary value problem:

5.31 5.31

We try to find an approximate solution of (5.31) within the set images. The FEM uses the weak formulation for the solution u:

5.32 5.32

We perform triangulation of the domain Ω by subdividing Ω into triangular subdomains K1, K2, …, KM as in Figure 5.2. They are pairwise disjoint and no vertex of one triangle lies on the edge of another triangle within a typical triangular element. The corresponding approximate domain, denoted by Ωh, is the domain whose closure is the closure of K1 ∪ ··· ∪ KM.

Figure 5.2 (a) Node points, (b) finite element triangulation and (c) basis function ϕj

5.2

Next, we can construct the finite element space images:

images

Let {zj:j = 1, …, N} be the set of nodes of the triangular elements. For each k, we define the function φkV by

images

Then, it is easy to see that

images

According to the Lax–Milgram theorem, there exists a unique uV that solves

5.33 5.33

Substituting images (with ui being unknown constants) into (5.33) leads to the linear system

5.34 5.34

where

images

The Lax–Milgram theorem provides that the system has a unique solution u = (u1, …, uN)T satisfying

images


Exercise 5.5.1
Consider the following.
1. Show that, if u is the solution of

5.35 5.35

then u + c is also a solution of (5.35) for any constant c. Hence, A(u + c) = b for any constant vector c.
2. Show that A is not invertible and that the rank of A is N − 1.

Since the rank of A is N − 1, we drop the first row and column of A and consider

5.36 5.36

Now, AN−1 is invertible and hence we can compute images. Using the knowledge of images, we can obtain the solution u = ∑ujφj of (5.33) by

images

where c is a constant chosen so that images.

5.5.2.1 Computation of Element Matrix

Let images be the set of the triangular elements. The ijth element of the matrix A can be decomposed into

images

Fixing the triangle K, we let the nodes of K be z1, z2 and z3. Let φ1(x) be a linear function on K with the value 1 at the node z1 and 0 at the other nodes. We will derive formulas for φ1 and ∇φ1 in terms of z1, z2 and z3. The function φ1 in K can be written in the form

images

where α1, α2, α3 satisfy

images

Therefore, the coefficients α1, α2, α3 can be found from

images

Since we can express φ1 as

images

images

where

images

and images is the area of the triangle. Note that φ1(x) is linear and φ1(z2) = 0 = φ1(z3).

Similarly, we have

images

images

Simple computation yields

images

where z = (z2, − z1). If σ = σK is a constant in K, then

images

Hence, the element matrix for the triangular element K is

images

5.5.2.2 Assembly of Two Element Matrices

We can combine two element matrices from two connected triangles sharing two nodes together. Globally numbering all four nodes, we may express each element matrix as

images

Assembly of these two element matrices is straightforward as

images

5.5.2.3 Assembly of Master Matrix

We first globally number all nodes. Assembly of all element matrices into a master matrix is more complicated because we must take care of connected or disjoint elements. Since the ijth element of the matrix A is

images

assembly of all element matrices is required to form the global master matrix A. An efficient way of assembling the global master matrix proceeds recursively, building up the finite element representation of one element at a time, as follows.

1. Set the N × N matrix

images

Here, N is the number of nodes in the finite element model or mesh.
2. For m = 1, …, M (M is the number of elements),

images

where i = max(gr, gs) and j = min(gr, gs). Here r and s are local node numbers of the element Km, and gr and gs are global node numbers corresponding to r and s, respectively. We can find values of images from

images

This procedure generates a lower triangular matrix

images

Since our master matrix A is symmetric and images when ij,

images

5.5.2.4 Boundary Condition

Since A is a singular matrix, it is not invertible and we cannot solve the linear system of equations Au = b. Since the rank of A is N − 1, we set a reference node and modify the master matrix so that the modified matrix is not singular, as follows.

1. For a chosen reference node, set u1 = 0.
2. Modify the matrix and vector as

images

3. Modify the linear system of equations as

images

where vectors images and images are regarded as the modified potential and current, respectively.

5.5.2.5 Solution of Linear System of Equations

The matrix AN−1 is symmetric, positive definite and sparse. Hence, we can solve images using various techniques introduced in the previous sections.

5.5.3 Numerical Examples

5.5.3.1 Elliptic PDE

Let Ω be a unit disk with the conductivity distribution σ given in Figure 5.3. We attach three electrodes images as shown in Figure 5.3. If we apply voltage V0 between a pair of the electrodes images and images, then the induced potential is dictated approximately by the following mixed boundary value problem:

5.37 5.37

where σ is the conductivity distribution. Figure 5.4 shows the images of the current flux and equipotential lines for the solution of (5.37). The following suggests an example code for solving (5.37).

clc; clear; close all
h = 1/32; Node = [0 0];
for cir = 1:1/h
Node = [Node;cir*h*cos((0:round(2*pi*cir)-1)*2*pi/round(2*pi*cir))’
...cir*h*sin((0:round(2*pi*cir)-1)*2*pi/round(2*pi*cir))’]; end
Element = delaunayn(Node); Sol_u = zeros(length(Node),1);
Sen = zeros(length(Node)); in =length(Node)-ceil(1*round(2*pi*cir/16)):
...length(Node)-ceil(0*round(2*pi*cir/16)); Sol_u(in) = 1;
out = length(Node)-floor(9*round(2*pi*cir/16)):length(Node)-
...floor(8*round(2*pi*cir/16)); Sol_u(out) = -1;
B = [in out]; I = [];
for ele = 1:length(Element)
    Cof=[Node(Element(ele,:),:) ones(3,1)]eye(3);sigma = 1;
    if norm(mean(Node(Element(ele,:),:))-[0.5 0.5])<0.2+10^(-2)
        sigma = 2;     end
Sen(Element(ele,:),Element(ele,:)) = Sen(Element(ele,:),Element(ele,:))+sigma*
...abs(1/2*det([Node(Element(ele,:),:) ones(3,1)]))*(Cof(1:2,:)’*Cof(1:2,:));
end
Sen(B,:) = []; RHS =-Sen*Sol_u; Sen(:,B) = [];
Sol_u(setdiff(1:length(Node), find(Sol_u =0))) = SenRHS;
figure; plot(Node(:,1),Node(:,2),‘k.’); axis equal; axis off;
 hold on; plot(Node(in,1),Node(in,2),‘b*’);
hold on; plot(Node(out,1),Node(out,2),‘r*’);
hold on; plot(Node(length(Node)-ceil(9*round(2*pi*cir/16)):length(Node)
...-ceil(8*round(8*pi*cir/16)),1),Node(length(Node)-ceil(9*round(2*pi*cir/16))
...:length(Node)-ceil(8*round(8*pi*cir/16)),2),‘ms’);
figure,triplot(Element, Node(:,1), Node(:,2),‘black’); axis equal;axis off;
figure, trimesh(Element, Node(:,1), Node(:,2), Sol_u);

Figure 5.3 Conductivity distribution and mesh

5.3

Figure 5.4 (a, c) Current flux and (b, d) equipotential lines

5.4

5.5.3.2 Poisson Equation

We consider the Poisson equation

5.38 5.38

Figure 5.5 shows the image of ρ in (5.38) and the solution u. The following also suggests an example code to solve (5.38).

[X Y] = meshgrid(0:0.005:0.5,0:0.005:0.5); Node = [X(:) Y(:)];
Element = delaunayn(Node); U = ones(length (Node),1); App_U = U;
Sen = sparse(length(Node), length(Node));
U(sum((Node-ones(size(U))*[0.12 0.38])'.^{2})<0.1^{2}+0.1^{4}
…|sum((Node-ones(size(U))*[0.380.15])'.^{2})<0.1^{2}+0.1^{4}) = 4;
U((abs(Node(:,1)−0.15)<0.1+0.1^{4}&abs(Node(:,2)−0.05)<0.015+0.1^{4})
…|(abs(Node(:,1)−0.15)<0.1+0.1^{4}&abs(Node(:,2)−0.13)<0.015+0.1^{4})) = 8;
U((abs(Node(:,1)−0.15)<0.1+0.1^{4}&abs(Node(:,2)−0.2)<0.015+0.1^{4})) = 10;
U((abs(Node(:,1)−0.45)<0.015+0.1^{4}&abs(Node(:,2)−0.38)<0.1+0.1^{4})
…|(abs(Node(:,1)−0.37)<0.015+0.1^{4}&abs(Node(:,2)−0.38)<0.1+0.1^{4})) = 12;
U((abs(Node(:,1)−0.3)<0.015+0.1^{4}&abs(Node(:,2)−0.38)<0.1+0.1^{4})) = 6;
On=zeros(length(Node),10);
index=ones(length(Node),1);
for ele=1:length(Element)
    p= Element(ele,:);
    On(p(1),index(p(1)))=ele;index(p(1))=index(p(1))+1;
    On(p(2),index(p(2)))=ele;index(p(2))=index(p(2))+1;
    On(p(3),index(p(3)))=ele;index(p(3))=index(p(3))+1;
end
grad_u=gradp(Node,Element,U);grad=ele2node(On,grad_u);clear grad_u;
…grad_ux=gradp(Node,Element,grad(:,1));gradx=ele2node(On,grad_ux);
grad_uy=gradp(Node,Element, grad(:,2)); grady=ele2node(On,grad_uy);
f=−(gradx(:,1) + grady(:,2));RHS=zeros(size(U)); figure;
surfc(X,Y,reshape(f,size(X,1),size(X,2)),‘FaceColor’,‘interp’,
…‘EdgeColor’,‘none’);view(2);colormap gray; axis equal; axis off;
for ele = 1:length(Element)
Cof = [Node(Element(ele,:),:) ones(3,1)]eye(3);
Sen(Element(ele,:),Element(ele,:)) = Sen(Element(ele,:),Element(ele,:))+abs
…(1/2*det([Node(Element(ele,:),:) ones(3,1)]))*(Cof(1:2,:)'*Cof(1:2,:));
RHS(Element(ele,:)) = RHS(Element(ele,:))+f(Element(ele,:))
…*abs(1/factorial(2)*det([Node(Element(ele,:),:) ones(3,1)]))/3;
end
B = find((Node(:,1)−0.25)>0.246 & (Node(:,2)−0.25)>0.246); clear Node
Sen(B,:) = [];RHS(B) = [];RHS=RHS-Sen*App_U; Sen(:,B) = [];
App_U(setdiff(1:length(X(:)),B)) = SenRHS;
figure;surfc(X,Y,reshape(App_U,size(X,1),size(X,2)),‘FaceColor’,
…‘interp’,‘EdgeColor’,‘none’);view(2); colormap gray; axis equal; axis off;
function grad_u=gradp(Node,ele_con,fwd_potential)
%%%how to get gradient potential~~~
num=length(ele_con);
for ele = 1:num
         vertex=ele_con(ele,:);%%%four vertex of tetrahedron
         Jacobian(1,:) = Node(vertex(1),:)-Node(vertex(3),:);
         Jacobian(2,:) = Node(vertex(2),:)-Node(vertex(3),:);
         %%%%Jacobian is the Jacobian Matrix
         %%%%pd=potential difference
         PD(1)=fwd_potential(vertex(1))-fwd_potential(vertex(3));
         PD(2)=fwd_potential(vertex(2))-fwd_potential(vertex(3));
         grad_u(ele,:) = JacobianPD';
end
function grad=ele2node(On,gradp)
%%  this function is just for 2D,
% transfer the gradient in each element to gradient in each Node
grad=zeros(size(On,1),2);
for i=1:size(On,1)
    if length(find(On(i,:)>0))==1
       grad(i,:)=gradp(On(i,find(On(i,:)>0)),:);
    else
    grad(i,:)=mean(gradp(On(i,find(On(i,:)>0)),:));
    end
end

Figure 5.5 Image of ρ and solution of the Poisson equation in (5.38)

5.5

References

Allen MB, Herrera I and Pinder GF 1988 Numerical Modeling in Science and Engineering. John Wiley & Sons, Inc., New York.

Haberman R 1987 Elementary Applied PDEs, 2nd edn. Prentice-Hall, Englewood Cliffs, NJ.

Johnson C 2009 Numerical Solution of Partial Differential Equations by the Finite Element Method. Reprint of 1987 edition. Dover, Mineola, NY.

Lax PD and Richtmyer RD 1956 Survey of the stability of linear finite difference equations. Commun. Pure Appl. Math. 9, 267–293.

Further Reading

Axelsson O and Barker VA 1984 Finite Element Solution of Boundary Value Problems: Theory and Computation. Academic Press, Orlando, FL.

Bank RE 1998 PLTMG: A Software Package for Solving Elliptic Partial Differential Equations. Users' Guide 8.0. Software, Environments, Tools, vol. 5. SIAM, Philadelphia, PA.

Braess D 2007 Finite Elements: Theory, Fast Solvers, and Applications in Elasticity Theory, 3rd edn. Translated from German by LL Schumaker. Cambridge University Press, Cambridge.

Brenner SC and Scott LR 2008 The Mathematical Theory of Finite Element Methods, 3rd edn. Texts in Applied Mathematics, vol. 15. Springer, New York.

Brezzi F and Fortin M 1991 Mixed and Hybrid Finite Element Methods. Springer Series in Computational Mathematics, vol. 15. Springer, New York.

Brezzi F, Marini LD, Markowich P and Pietra P 1991 On some numerical problems in semiconductor device simulation. In Mathematical Aspects of Fluid and Plasma Dynamics (eds G Toscani, V Boffi and S Rionero). Lecture Notes in Mathematics, vol. 1460, pp. 31–42. Springer, Berlin.

Calhoun D and LeVeque RJ 2005 An accuracy study of mesh refinement on mapped grids. In Adaptive Mesh Refinement—Theory and Applications. Lecture Notes in Computer Science and Engineering, no. 41, pp. 91–101. Springer, Berlin.

Carstensen C and Klose R 2003 A posteriori finite element error control for the p-Laplace problem. SIAM J. Sci. Comput. 25(3), 792–814.

Carstensen C, Liu W and Yan N 2006 A posteriori error estimates for finite element approximation of parabolic p-Laplacian. SIAM J. Numer. Anal. 43(6), 2294–2319.

Ciarlet PG 1980 Metod Konechnykh Elementov dlya Ellipticheskikh Zadach. Translated from English by BI Kvasov. Mir, Moscow.

Fehrenbach J, Gournay F, Pierre C and Plouraboue F 2012 The generalized Graetz problem in finite domains. SIAM J. Appl. Math. 72(1), 99–123.

Gockenbach MS 2006 Understanding and Implementing the Finite Element Method. SIAM, Philadelphia, PA.

Higham DJ and Higham NJ 2005 MATLAB Guide, 2nd edn. SIAM, Philadelphia, PA.

Iserles A 1996 A First Course in the Numerical Analysis of Differential Equations. Cambridge Texts in Applied Mathematics. Cambridge University Press, Cambridge.

LeVeque RJ 2002 Finite Volume Methods for Hyperbolic Problems. Cambridge Texts in Applied Mathematics. Cambridge University Press, Cambridge.

LeVeque RJ 2007 Finite Difference Methods for Ordinary and Partial Differential Equations: Steady-State and Time-Dependent Problems. SIAM, Philadelphia, PA.

Moler CB 2004 Numerical Computing with MATLAB. SIAM, Philadelphia, PA.

Quarteroni A and Valli A 1994 Numerical Approximation of Partial Differential Equations. Springer Series in Computational Mathematics, vol. 23. Springer, Berlin.

Quarteroni A and Saleri F 2003 Scientific Computing with MATLAB. Texts in Computational Science and Engineering, vol. 2. Springer, Berlin.

Richtmyer RD and Morton KW 1967 Difference Methods for Initial-Value Problems, 2nd edn. Interscience Tracts in Pure and Applied Mathematics, no. 4. Interscience, New York.

Strang G and Fix G 2008 An Analysis of the Finite Element Method, 2nd edn. Wellesley-Cambridge, Wellesley, MA.

Strikwerda JC 1989 Finite Difference Schemes and Partial Differential Equations. Wadsworth & Brooks/Cole Mathematics Series. Wadsworth & Brooks/Cole, Pacific Grove, CA.

Thomas JW 1995 Numerical Partial Differential Equations: Finite Difference Methods. Texts in Applied Mathematics, vol. 22. Springer, New York.

Trefethen LN Spectral Methods in MATLAB Software, Environments, Tools, vol. 10. SIAM, Philadelphia, PA.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.148.107.193