










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!











Introduction to Partial Differential Equation - III. Numerical methods Discretization: From ODE to PDE For an ODE for u ( x ) defined on the interval, x ∈ [ a , b ], and consider a uniform grid with ∆ x = ( b − a )/N, discretization of x , u , and the derivative(s) of u leads to N equations for ui , i = 0, 1, 2, ..., N, where ui ≡ u ( i ∆ x ) and xi ≡ i ∆ x. (See illustration below.) The idea for PDE is similar. The diagram in next page shows a typical grid for a PDE with two variables ( x and y ). Two indices, i and j , are used for the discretization in x and y. We will adopt the convention, u (^) i, j ≡ u ( i ∆ x , j ∆ y ), xi ≡ i ∆ x , yj ≡ j ∆ y , and consider ∆ x and ∆ y constants (but allow ∆ x to differ from ∆ y ).
For a boundary value problem with a 2nd order ODE, the two b.c. would reduce the degree of freedom from N to N−2; We obtain a system of N−2 linear equations for the interior points that can be solved with typical matrix manipulations. For an initial value problem with a 1st order ODE, the value of u 0 is given. Then, u 1 , u 2 , u 3 , ..., are determined successively using a finite difference scheme for du / dx. We will discuss the extension of these two types of problems to PDE in two dimensions.
Physically, one can think of u as (for example) temperature and the solution of this PDE as the "equilibrium state" of the diffusion process (transport of heat from the area with higher temperature to the area with lower temperature) described by the heat equation (see Part I), ∂ u ∂ t
2 u ∂ x
2 u ∂ y
in which t is time. As t → ∞, u ceases to evolve further so ∂ u /∂ t → 0. The heat equation is then reduced to Laplace equation. In the diagram in the preceding page, one can think of the domain for the PDE as a square slab of metal with its four sides attached to thermal reservoirs to maintain constant temperatures. The right and top sides are slightly warmer at 2°C, while the left and lower sides are cooler at 1°C. With these constraints, we expect the equilibrium state to be non-uniform within the domain; Temperature should decrease approximately from the top right corner to the lower left corner. The solution of the Laplace equation will give us the answer. Let us consider the solution on a grid with ∆ x = ∆ y = 1/3, as illustrated in the figure in next page
In the preceding diagram, the values of the variables in green are already given by the boundary conditions. The only unknowns are the red u (^) i, j at the interior points. We have 4 unknowns, need 4 equations to determine their values. Let us first approximate the second partial derivatives in the PDE by central difference scheme (5th equation for second derivative in Table 6-1 in textbook, also see Sec 6.10),
2 u ∂ x
i , j
ui − 1 , j − 2 ui , j ui 1 , j x
2 u ∂ y
i , j
ui , j − 1 − 2 ui , j ui , j 1 y
Plugging Eqs. (1) and (2) into the original Laplace equation, we obtain ui − 1 , j − 2 ui , j ui 1 , j x
ui , j − 1 − 2 ui , j ui , j 1 y 2 =^0 , at the grid point ( i ,^ j ). For ∆ x = ∆ y , this equation can be rearranged into − 4 ui , j ui −1, j ui 1, j ui , j − 1 ui , j 1 = (^0) , at the grid point ( i , j ). (3) The distribution of the variables in Eq. (3) on the grid is illustrated in the diagrams in the preceding page. The partial derivatives, ∂ 2 u /∂ x 2 +∂ 2 u /∂ y 2 , in the PDE can be evaluated by (3) at the grid point ( i , j ) using the discrete values of u at ( i , j ) itself (with weight of − 4) and those at its 4 neighboring points - at left, right, top, and bottom. The diagram in next page illustrates how this fits into the grid system of our problem. For example, at the grid point, ( i , j ) = (2,2), the terms in Eq. (3) are u 2,2 at center and u 2,3, u 2,1, u 1,2, and u 3,2 at top, bottom, left, and right of the grid point. The relevant grid points form a "cross" pattern.
The solution is illustrated in the following figure. The behavior of the solution is as we expected: Constrained by the boundary conditions, The "temperature", u , decreases from the top right corner to lower left corner of the domain. Note that, unlike the matrix for the boundary value problems for ODE, the matrix in Eq. (6) is not strictly tridiagonal. It is however only slightly more complicated; We can discretize the system on a finer grid with even more grid points and yet there will always be just 3 non-zero elements in each row and each column of the matrix.
Case 2: Evolution equation defined on t ∈ [0, ∞ ) Example 2 : Solve the linear advection equation for u ( x , t ), ∂ u ∂ t = c ∂ u ∂ x
defined on x ∈(−∞, ∞) , t ∈[0, ∞), and with the boundary condition, (I) u ( x , 0) = F ( x ). F ( x ) will be given later as the discussion progresses. Like in Example 1, we should discretize the system on a two-dimensional grid for x and t using the notation, ui,j ≡ u ( i ∆ x , j ∆ t ), xi ≡ i ∆ x , and tj ≡ j ∆ t. Unlike Example 1, here the domain for the PDE is unbounded in x , and semi-infinite in t (analogous to an initial value problem for ODE). There is only one "wall" at t = 0 along which the values of u are given by the boundary condition. See the following diagram.
To perform the integration in t , we discretize the PDE by approximating ∂ u /∂ t with the forward difference scheme, and ∂ u /∂ x with the central difference scheme (this combination is but one of many possible choices),
∂ u
ui , j 1 − ui , j t
∂ u
ui 1 , j − ui − 1 , j 2 x
The partial differentiation in Eq. (7) is performed with x held constant (the index i is the same for all terms in that equation). Likewise, t (or index j ) is held constant in Eq. (8). Combining (7) and (8) we have ui , j 1 − ui , j t = c ui 1 , j − ui − 1 , j 2 x
or ui , j 1 = −
c t
ui −1, j ui , j
c t
ui 1, j. (9) Defining α ≡ (c∆ t )/(2∆ x ), Equation (9) can also be written as ui , j 1 = − ui −1, j ui , j ui 1, j. (10)
The u in the left hand side of Eq. (10) is located at level j +1 (or t = ( j +1)∆ t ), while those in right hand side are all located at level j (or t = j ∆ t ). The situation is illustrated in the following diagram for j = 0. Here, ui ,1 at the level of j =1 ( t = ∆ t ), marked by a triangle, is determined by ui −1,0 , ui ,0 , and ui +1,0 (marked by circles), located one level below it at j = 0 ( t = 0). Since the values of u at the level of j = 0 are given by the boundary condition, ui ,1 is readily obtained from Eq. (10). Once all ui ,1 at the level of j = 1 are calculated, they can be used to determine ui ,2 at the next level (going one step upward in the diagram), and so on.
u 2,2 = −0.25 u 1,1 u 2,1 0.25 u 3,1 = 0.0625 (^) , u 3,2 =−0.25 u 2,1 u 3,1 0.25 u 4,1 = 0.5 (^) , u 4,2 = −0.25 u 3,1 u 4,1 0.25 u 5,1 = 0.875 (^) , u 5,2 = −0.25 u 4,1 u 5,1 0.25 u 6,1 = −0.5 (^) , u 6,2 =−0.25 u 5,1 u 6,1 0.25 u 7,1 = 0. (^). All other ui , 2 with i > 6 or i < 2 are zero. The plot in next page shows the "initial state" and the solutions at t = ∆ t and t = 2∆ t (i.e., ui,j at j = 0, 1, and 2). Lastly, note that the finite difference scheme used in this example is far from the best. It is chosen for its simplicity. In the analytic solution (see Part I), the shape of the initial state should remain the same at t = 0, 0.1, and 0.2. Moreover, u would not become negative at any location. As it turns out, it is not trivial to fix these problems even with more sophisticated numerical schemes. This is beyond the scope of our discussion.
The number on the abscissa is the index " i ". The three panels from top to bottom are j = 0, 1, and 2 (or t = 0, 0.1, and 0.2). A Matlab program that was used to solve the PDE and produce the plot is listed in next page.