Numerical Solutions to Partial Differential Equations Zhiping Li LMAM and School of Mathematical Sciences Peking University
A Model Problem and Its Difference Approximations 1-D Initial Boundary Value Problem of Heat Equation 1-D Initial Boundary Value Problem of Heat Equation The standard model problem: Homogeneous heat equation with homogeneous Dirichlet boundary condition u t = u xx, 0 < x < 1, t > 0, (1) u(x, 0) = u 0 (x), 0 x 1, (2) u(0, t) = u(1, t) = 0, t > 0. (3) 1 A sequence of independent nontrivial special solutions: u k (x, t) = e k2 π 2t sin kπx, k = 1, 2,. 2 / 37
A Model Problem and Its Difference Approximations Analytical Solutions of the Homogeneous Heat Equation Analytical Solutions of the Homogeneous Heat Equation 2 If the initial data u 0 has a Fourier sine expansion where a k = 2 1 0 u 0 (x) = a k sin kπx, k=1 u 0 (x) sin kπx dx, k = 1, 2,, 3 then, the solution to the model problem (1)-(3) can be written as u(x, t) = a k e k2 π 2t sin kπx. k=1 3 / 37
A Model Problem and Its Difference Approximations Finite Difference Discretization of the Heat Equation Grid and Grid Function 1 Spatial grid: h = h N = x = 1/N, and x = h, = 0, 1,, N; 2 Temporal grid: τ = t, and t m = m τ, m = 0, 1, ; 3 Grid function: U = U (h,τ) = {U m : = 0, 1,, N; m = 0, 1, }; Next, we are going to discuss finite difference schemes of heat equations and their analytical properties. 4 / 37
The Explicit Scheme for the Heat Equation An Explicit Scheme of the Heat Equation Substituting / t by +t / t; Substituting 2 / x 2 by δ 2 x/( x) 2 ; leads to the explicit difference scheme U m U m+1 τ = Um +1 2Um + U 1 m h 2, 1 N 1; m 0; (4) U 0 = u 0, 0 N; (5) U m 0 = U m N = 0, m 1. (6) The explicit scheme (4) can be equivalently written as [ +t τ ] δ2 x h 2 U m = 0. 5 / 37
The Explicit Scheme for the Heat Equation The Stencil of the Explicit Scheme of the Heat Equation The scheme (4) is called an explicit scheme, since U m+1 = (1 2µ)U m + µ ( U m 1 + U m +1),, where µ = τ/h 2 is called the grid ratio of the heat equation, thus, can be explicitly calculated from U m node by node. U m+1 t m+1 m 1 +1 x 6 / 37
Truncation Error of the Explicit Scheme By comparing[ the explicit ] scheme and [ the heat] equation +t δ2 x τ h 2 U m = 0, t 2 x 2 u = 0, we introduce the truncation operator [ ] [ ] +t T = T (h,τ) := δ2 x τ h 2 t 2 x 2. For sufficiently smooth u, by Taylor series expansion, +t u(x, t) = u t (x, t) t+ 1 2 u tt(x, t)( t) 2 + 1 6 u ttt(x, t)( t) 3 +, δ 2 xu(x, t) = u xx (x, t)( x) 2 + 1 12 u xxxx(x, t)( x) 4 +. Hence the truncation error can be written as Tu(x, t) = 1 2 u tt(x, t)τ 1 12 u xxxx(x, t)h 2 + O(τ 2 + h 4 ).
Truncation Error, Consistency and Order of Accuracy Truncation Error of the Explicit Scheme We can also use another form of the Taylor expansion of u at (x, t) +t u(x, t) = u t (x, t) t + 1 2 u tt(x, η)( t) 2, δ 2 xu(x, t) = u xx (x, t)( x) 2 + 1 12 u xxxx(ξ, t)( x) 4, where η (t, t + τ), ξ (x h, x + h), to express the truncation error in the form Tu(x, t) = 1 2 u tt(x, η)τ 1 12 u xxxx(ξ, t)h 2. 8 / 37
Truncation Error, Consistency and Order of Accuracy Consistency and Order of Accuracy of the Explicit Scheme Since, for smooth u, the truncation error satisfy Tu(x, t) = 1 2 u tt(x, η)τ 1 12 u xxxx(ξ, t)h 2, 1 [τ 1 +t h 2 δ 2 x] is consistent with [ t 2 x ], since Tu(x, t) 0, as h 0, τ 0, (x, t) (0, 1) R +. 2 The explicit scheme is of first and second order accurate with respect to time and space, since Tu(x, t) = O(τ) + O(h 2 ). 3 Tu(x, t) 1 2 M tt τ + 1 12 M xxxx h 2, (x, t) Ω tmax, where Ω tmax (0, 1) (0, t max ), M tt = sup (x,t) Ωtmax u tt (x, t) and M xxxx = sup (x,t) Ωtmax u xxxx (x, t). 9 / 37
L Stability and Convergence of the Explicit Scheme 1 Error: e m = U m u m, = 0, 1,, N, m = 0, 1,. 2 The error equation (compare τ 1 +t U m = h 2 δxu 2 m + f m ): e m+1 e m = em +1 2em + e 1 m τ h 2 T m, 1 N 1; m 0; (7) e 0 = 0, 0 N; (8) e m 0 = e m N = 0, m 1, (9) 3 Stability (uniformly well-posedness of (7)-(9), to be proved): ( ) e,ωtmax C 1 max 0 N e0 + max ( e0 m + en m )) +C 2 T,Ωtmax 0<mτ t max 4 A priori error estimate e,ωtmax C(M tt τ + M xxxx h 2 ). What remains to show is the stability.
Stability and Convergence of the Explicit Scheme L Stability of the Explicit Scheme 1 Define Ω = Ω ( tmax, Ω D = {(x, t) Ω tmax : t = 0, or x = 0, 1}, δ L (h,τ) U m+1 2 = x ( x) 2 ) +t U m, then the conditions (1), (2) t of the maximum principle are satisfied, if 0 < µ 1/2 (Exercises 2.4). 2 Proper comparison function can also be found (Exercises 2.5). 3 The explicit scheme and its error equation: L (h,τ) U m+1 = f m, L (h,τ) e m+1 = T m ; 4 The stability then follows from the maximum principle. 11 / 37
Stability and Convergence of the Explicit Scheme L Stability of the Explicit Scheme For parabolic problems, we have an alternative approach. The explicit scheme and its error equation (µ = τ/h 2 ): U m+1 = (1 2µ)U m + µ ( U 1 m + U+1 m ) + τ f m, e m+1 = (1 2µ)e m + µ ( e 1 m + e+1 m ) τ T m. If µ 1 2, em+1 max 0 N em + τ T m, = 1, 2,, N 1; where T m = max T m. Therefore, for all m 0, we have 1 N 1 { ( ) max max max 0 N e0, max max e0, l en }+τ l 1 l m 1 N 1 em+1 m T l. l=0 12 / 37
Stability and Convergence of the Explicit Scheme L Stability Condition of the Explicit Scheme If the grid ratio satisfies µ t/( x) 2 1/2, then, the explicit scheme has the following properties (C-1) stability: for all m 0, { max max max 0 N U0, max max ( U0, l UN l ) } +t max f,ωtmax, 1 l m 1 N 1 Um+1 e,ωtmax max 0 N e0 + max max ( e0 m, en m )) + t max T,Ωtmax ; 0<mτ t max 13 / 37
Stability and Convergence of the Explicit Scheme L Stability Condition of the Explicit Scheme (C-2) convergence rate is O(τ) (or O(h 2 )), more precisely ( 1 e,ωtmax τ 2 + 1 ) M xxxx t max. 12µ (Recall Tu(x, t) 1 2 M tt τ + 1 12 M xxxx h 2, µ = τ h 2 and u t = u xx ) 14 / 37
Stability and Convergence of the Explicit Scheme Refinement Path and Condition of L Stability τ = r(h) is said to give a refinement path, if r is a strictly increasing function and r(0) = 0. (C-2) can be rewritten as (C-3) Let {h i } i=1 satisfy lim i 0 h i = 0. Let the refinement path τ = r(h) satisfy µ i = r(h i )/h 2 i 1/2. Suppose the solution u of (1)-(3) satisfies that u xxxx C on (0, 1) (0, t max ). Then the solution sequence U (i) of (4)-(6), with grid sizes (h i, τ i = r(h i )), converge uniformly on [0, 1] [0, t max ] to u, and the convergence rate is O(h 2 i ). 15 / 37
Stability and Convergence of the Explicit Scheme Refinement Path and Condition of L Stability The convergence rate is optimal. However, for any fixed grid spacing, as t max, we lost control on the error. Recall that, if f = 0, the( exact solution ) u(x, t) 0, as 1 t, e,ωtmax τ + 1 M 2 12µ xxxx t max is certainly not a satisfactory error estimate for large t max. Better results on error estimates can be obtained by applying the maximum principle and choosing proper comparison functions (Exercises 2.5 and 2.6). 16 / 37
Stability and Convergence of the Explicit Scheme Fourier Analysis and L 2 Stability of the Explicit Scheme Similar as the model problem (1)-(3), the difference problem U m+1 τ U m = Um +1 2Um + U m 1 h 2, 1 N 1; m 0, U 0 = u 0, 0 N, U m 0 = U m N = 0, m 1, can also be solved by the method of separation of variables. 17 / 37
Stability and Convergence of the Explicit Scheme Fourier Analysis and L 2 Stability of the Explicit Scheme In fact, any given general constant-coefficient linear homogeneous difference equation defined on a uniform grid on [ 1, 1] [0, ) admits a complete set of Fourier modes solutions: U (k)m = λ m k eikπ x, N + 1 N, N + 1 k N, x = 1/N: λ k = λ k e i arg λ k : the spatial grid size, the amplification factor, λ k : relative change in the modulus arg λ k : the change in the phase angle of the corresponding Fourier mode in one time step. 18 / 37
Stability and Convergence of the Explicit Scheme Fourier Modes and Characteristic Equations Substituting the Fourier mode U m = λ m k eikπ N into the homogeneous explicit difference scheme U m+1 = U m + µ ( U m 1 2U m + U m +1), yields the characteristic equation of the explicit scheme [ 1 + µ λ m+1 k e ikπ N = λ m k e ikπ N (e ikπ 1 N + e ikπ 1 N 2 )], which has a unique solution λ k = 1 4 µ sin 2 kπ x. 2 19 / 37
A Necessary L 2 Stability Condition: von Neumann condition The stability of the computation requires that all Fourier modes should be uniformly bounded, i.e. there exist a constant C independent of N and k such that λ m k C, mτ t max, N + 1 k N. Assume C > 1, 2τ t max, and set m = [t max /τ], hence m t max /τ 1 t max /2τ. Since C s is a concave function of C if 0 < s < 1, the above condition implies λ k C 1/ m 1 + (C 1)/ m 1 + 2τ(C 1)/t max, which leads to the following necessary condition, usually called the von Neumann condition, for the L 2 stability: there exists a constant K independent of N and k such that λ k 1 + K τ, N + 1 k N.
Stability and Convergence of the Explicit Scheme A Necessary L 2 Stability Condition of the Explicit Scheme Take k = N, since λ N = 1 4µ, it follows from the von Neumann condition for the L 2 stability: λ k 1 + K τ, N + 1 k N, we obtain a necessary condition for the L 2 stability of the explicit scheme: 1 1 4µ 1, or more concisely (since µ > 0) µ 1 2. In fact, if µ > 1/2, it follows from λ N = 1 4µ < 1 that the modulus of λ m N eiπ will grow exponentially fast as m increases. Thus the scheme is unstable for µ > 1/2. 21 / 37
A Sufficient L 2 Stability Condition of the Explicit Scheme On the other hand, if µ 1 kπ 2, then 0 4 µ sin2 2N λ k 1, N + 1 k N. 2, thus (C-4) µ 1 2 the L 2 stability of the explicit scheme. Proof: Let U 0 = 1 2 N k= N+1 (U 0 ) k e ikπ N. Then, U m = 1 2 N k= N+1 λ m k (U 0 ) k e ikπ N. Thus, it follows from λ k 1, k and the Parseval relation that U m 2 2 = (U N m ) 2 2 = λ m k (U 0 2 N ) k (U 0 2 ) k = U 0 2 2. k= N+1 k= N+1
Stability and Convergence of the Explicit Scheme A Sufficient L 2 Stability Condition of the Explicit Scheme Rewrite the explicit scheme as U m+1 = N (U m ), then, we have shown that, for µ 1/2, N (U m ) 2 U m 2 U 0 2. The corresponding error equation is e m+1 = N (e m ) τt m, thus we have e m+1 2 = N (e m ) τt m 2 e m 2 + τ T m 2 m e 0 2 + τ T l 2. This shows that the dependence of the solution of the explicit scheme on the right hand side as well as the initial data is uniformly continuous in the L 2 norm, therefore is L 2 stable. l=0 23 / 37
Stability and Convergence of the Explicit Scheme L 2 Convergence of the Explicit Scheme Since, for µ 1/2, the error of the explicit scheme satisfies m e m+1 2 e 0 2 + τ T l 2, if the corresponding consistency holds, say lim h 0 e 0 2 = 0 and lim τ m T l 2 = 0, m t max /τ, τ 0 l=0 then the difference solution is convergent. Note, if Tu(, t) 2 is a uniformly continuous function of t, then [tmax /τ] lim τ τ 0 l=0 T l 2 = 0 lim τ 0 l=0 tmax 0 Tu(, t) 2 dt = 0. 24 / 37
Stability and Convergence of the Explicit Scheme L 2 Convergence of the Explicit Scheme (C-5) Suppose 1 {h i } i=1 satisfies lim i 0 h i = 0; 2 the refinement path r satisfies µ i = r(h i )/h 2 i 1/2; 3 the solution u satisfies u xxxx C(( 1, 1) R + ) and tmax 0 u xxxx (, t) 2 dt <. Then, max e (i)m 2 = O(hi 2 ). 0<mτ i t max Remark: Here it is assumed that e (i)0 2 = O(hi 2 ), i.e. the initial data is approximated with second order accuracy. 25 / 37
Stability and Convergence of the Explicit Scheme Summary of the 1st Order Forward Explicit Scheme 1 A sufficient and necessary condition for L 2 stability, also a sufficient condition for L stability: µ = τ/h 2 1/2, a rather strict restriction on the time step; 2 Convergence rate O(τ + h 2 ). 3 Easy to solve, and the computational cost is low. Question: is it possible to develop an explicit scheme so that the stability condition is relaxed to say τ = O(h), and the convergence rate is O(τ 2 + h 2 ). 26 / 37
Stability and Convergence of the Explicit Scheme The Richardson scheme The Richardson scheme (with truncation error O(τ 2 + h 2 )): U m+1 U m 1 = Um +1 2Um + U 1 m 2τ h 2. Substitute the Fourier mode U m = λ m k eikπ x into the scheme, we are led to the characteristic equation of the Richardson scheme: λ 2 k + 8λ kµ sin 2 kπ x 1 = 0. 2 The equation has two distinct real roots λ ± k, and for all k 0, λ + k + kπ x λ k = 8µ sin2 < 0, λ + 2 k λ k = 1, λ k < 1. Hence, the Richardson scheme is unconditionally unstable. 27 / 37
The Du Fort-Frankel scheme The Du Fort-Frankel scheme: U m+1 U m 1 2τ = Um +1 (Um+1 + U m 1 ) + U 1 m h 2. The characteristic equation of the Du Fort-Frankel scheme: (1 + 2µ)λ 2 k 4λ kµ cos(kπ x) (1 2µ) = 0, which has roots λ ± k = 2µ cos(kπ x)± 1 4µ 2 sin 2 (kπ x) 1+2µ. If 4µ 2 sin 2 (kπ x) > 1, λ ± k are conugate complex roots, hence λ ± k = λ+ k λ k = (1 2µ)/(1 + 2µ) < 1; If 4µ 2 sin 2 (kπ x) 1, λ ± k (2µ cos(kπ x) +1)/(1 + 2µ) 1. Consequently Du Fort-Frankel scheme is unconditionally L 2 stable. The truncation error is T m = O(( τ h )2 ) + O(τ 2 + h 2 ) + O( τ 4 h 2 ). consistent if τ = o(h); convergence rate O(h 2 ) only if τ = O(h 2 ).
Stability and Convergence of the Explicit Scheme No Explicit Scheme Can Unconditionally Converge Since the solution of the heat equation picks up information globally on the initial and the boundary data, it is impossible to develop an explicit scheme which is unconditionally stable and at the same time unconditionally consistent. In fact, to guarantee an explicit scheme to converge, τ = o(h) must hold on the refinement path. Therefore, it is necessary to develop implicit finite difference schemes for the parabolic partial differential equations. 29 / 37
The 1st Order Backward Implicit Finite Difference Scheme The initial-boundary value problem of the simplest implicit finite difference scheme for the model problem (2.2.1)-(2.2.3): U m+1 τ U m = Um+1 +1 2Um+1 + U m+1 1 h 2, 1 N 1; m 0; U 0 = u 0, 0 N; U m 0 = U m N = 0, m 1. The scheme can be equivalently rewritten as (1 + 2µ)U m+1 = µu m+1 1 + Um + µu m+1 +1. The truncation [ operator ] [ T (h,τ) := t τ δ2 t x h 2 t 2 x ]. 2 L (h,τ) = δ2 x t ( x) 2 t. Maximum principle holds for Ω = Ω tmax, Ω D = {(x, t) Ω tmax : x = 0, 1 or t = 0}. m+1 m 1 +1 x
The Implicit Schemes The 1st Order Backward Implicit Finite Difference Scheme Truncation Error and Order of Accuracy The truncation operator T (h,τ) := [ t τ ] [ δ2 x h 2 t ]. 2 x 2 By the Taylor series expansion, the truncation error of the 1st order backward implicit scheme is Tu(x, t) = 1 2 u tt(x, t)τ 1 12 u xxxx(x, t)h 2 + O(τ 2 + h 4 ), Tu(x, t) = 1 2 u tt(x, η)τ 1 12 u xxxx(ξ, t)h 2. Thus the 1st order backward implicit scheme is consistent with the heat equation, and is of first and second order accurate with respect to time and space respectively, i.e. Tu(x, t) = O(τ + h 2 ). 31 / 37
The Implicit Schemes The 1st Order Backward Implicit Finite Difference Scheme L Stability of the 1st Order Backward Implicit Scheme The 1st order backward implicit scheme and its error equation can be equivalently written as ( ) (1 + 2µ)U m+1 = U m + µ U m+1 1 + Um+1 +1 + τ f m+1, ( ) (1 + 2µ)e m+1 = e m + µ e m+1 1 + em+1 +1 τ T m+1. Thus, for any µ > 0 and for all m 0, { ( ) } max 1 N 1 em+1 max max 0 N e0, max max e0, l en l +τ 1 l m+1 Hence, the 1st order backward implicit scheme is unconditionally L stable and satisfies the maximum principle. Better estimate can be obtained by taking proper comparison functions. m+1 l=1 T l. 32 / 37
The Implicit Schemes The 1st Order Backward Implicit Finite Difference Scheme L 2 Stability of the 1st Order Backward Implicit Scheme Substituting the Fourier mode U m = λ m k eikπ x into the homogeneous 1st order backward implicit scheme, yields the characteristic equations of the scheme [ )] λ m+1 k e ikπ N 1 µ (e ikπ 1 N + e ikπ 1 N 2 = λ m k eikπ N, which has a unique solution λ k = 1 1 + 4 µ sin 2 kπ x 2 Hence, the 1st order backward implicit scheme is unconditionally L 2 stable.. 33 / 37
The Implicit Schemes The 1st Order Backward Implicit Finite Difference Scheme Efficiency of the 1st Order Backward Implicit Scheme 1 Unconditionally L 2 and L stable, can use larger τ; 2 Convergence rate O(τ + h 2 ), τ = O(h 2 ), for efficiency. 3 Need to solve a tridiagonal and diagonally dominant linear system, and the computational cost is about twice that of the 1st order forward explicit scheme if solved by the Thompson method (forward elimination and backward substitution). 4 More efficient only if µ > 1, the computational cost is about 1/µ of that of the 1st order forward explicit scheme. Better, but not good enough. 34 / 37
The Crank-Nicolson scheme The well known Crank-Nicolson scheme: U m+1 [ U m = 1 U m +1 2U m + U 1 m τ 2 h 2 (1 + µ)u m+1 = (1 µ)u m + µ 2 + Um+1 +1 2Um+1 + U m+1 1 h 2 ( U m 1 + U m +1 + U m+1 1 [ 1 T m+ 1 2 = 1 12 u ttt (x, η)τ 2 + u xxxx (ξ, t m+ 1 )h ]; 2 2 [ ] [ ] 2 λ k = 1 2 µ sin 2 kπ x 2 / 1 + 2 µ sin 2 kπ x 2, thus unconditionally L 2 stable. ) + Um+1 +1 3 The computational cost is about twice that of the explicit scheme if solved by the Thompson method. 4 The maximum principle holds for µ 1. 5 Convergence rate is O(τ 2 + h 2 ), efficient if τ = O(h). ] ;
The Implicit Schemes The Crank-Nicolson scheme and θ-scheme The θ-scheme (0 < θ < 1, θ 1/2) U m+1 τ U m = (1 θ) Um +1 2Um + U m 1 h 2 (1+2µθ)U m+1 = (1 2µ(1 θ))u m +µ(1 θ) ( U m 1 + U m +1 + θ Um+1 +1 2Um+1 + U m+1 1 h 2 ; ) +µθ (U m+1 1 + Um+1 +1 ). 1 T m+ 1 2 = O(τ 2 + h 4 ), if θ = 1 2 1 [ [ 12µ ; = O(τ + h2 ), otherwise. ], thus ] / 2 λ k = 1 4(1 θ) µ sin 2 kπ x 2 1 + 4θ µ sin 2 kπ x 2 L 2 stable for 2µ (1 2θ) 1 (unconditional for θ 1/2). 3 The maximum principle holds for 2µ(1 θ) 1. 36 / 37
SK 2µ5, 10, 12; þåš 1 Thank You!