Numerical Methods for PDEs Alternating direction implicit (ADI) schemes (Lecture 11, Week 4) Markus Schmuck Department of Mathematics and Maxwell Institute for Mathematical Sciences Heriot-Watt University, Edinburgh Edinburgh, February 4, 2013 M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 11 1/ 7 Outline 1 The ADI method M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 11 2/ 7 A more practical 2D scheme: The ADI method For u smooth enough, the Taylor expansion of u(xj + hx , yl , tn ) admits an Exponential operator notation [ ] ∂u hx2 ∂ 2 u hx3 ∂ 3 u u(xj +hx , yl , tn ) = u + hx + + + ... ∂x 2! ∂x 2 3! ∂x 3 (xj ,yl ,tn ) [ ] 2 2 3 3 h ∂ h ∂ ∂ = 1 + hx + x + x + . . . u |(xj ,yl ,tn ) ∂x 2! ∂x 2 3! ∂x 3 ( ) ∂ = exp hx u |(xj ,yl ,tn ) . ∂x Similarly (missing out the steps in between) we can write ( ) ∂ u(xj , yl + hy , tn ) = exp hy u |(xj ,yl ,tn ) ∂y and ( ) ∂ u(xj , yl , tn + k ) = exp k u |(xj ,yl ,tn ) ∂t M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 11 3/ 7 With the help of this notation, we derive a different implicit scheme for ut = uxx + uyy . Suppose that u(x, y , t) is a smooth solution of the PDE. Taylor expanding u(x, y , tn + k ) about (x, y , tn ) gives ( ) ∂ u(x, y , tn +k ) = exp k u |(x,y ,tn ) . ∂t Use ea = ea/2 · ea/2 to rewrite this as ( ) ( ) k ∂ k ∂ u|t=tn+k = exp exp u|t=tn 2 ∂t 2 ∂t and hence ( ) ( ) k ∂ k ∂ exp − u|t=tn+k = exp u|t=tn . 2 ∂t 2 ∂t | {z } | {z } new time-level old time-level M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 11 [∗] 4/ 7 With the help of this notation, we derive a different implicit scheme for ut = uxx + uyy . Suppose that u(x, y , t) is a smooth solution of the PDE. Taylor expanding u(x, y , tn + k ) about (x, y , tn ) gives ( ) ∂ u(x, y , tn +k ) = exp k u |(x,y ,tn ) . ∂t Use ea = ea/2 · ea/2 to rewrite this as ( ) ( ) k ∂ k ∂ u|t=tn+k = exp exp u|t=tn 2 ∂t 2 ∂t and hence ( ) ( ) k ∂ k ∂ exp − u|t=tn+k = exp u|t=tn . 2 ∂t 2 ∂t | {z } | {z } new time-level old time-level M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 11 [∗] 4/ 7 We now use the fact that u solves the PDE to write ( ) k ∂ exp ± u 2 ∂t = = ( [ ]) k ∂2 ∂2 exp ± u + 2 ∂x 2 ∂y 2 ) ( ) ( k ∂2 k ∂2 exp ± exp ± u 2 ∂x 2 2 ∂y 2 (using ea+b = ea · eb ). Plugging this into [∗] gives ( ) ( ) k ∂2 k ∂2 exp − exp − u|t=tn+k 2 ∂x 2 2 ∂y 2 ) ( ) ( k ∂2 k ∂2 = exp exp u|t=tn . 2 ∂x 2 2 ∂y 2 We now chop the exponentials at first order (e±q ≈ 1 ± q) to get ( )( ) ( )( ) k ∂2 k ∂2 k ∂2 k ∂2 1− 1− u|t=tn+k ≈ 1 + 1+ u|t=tn , 2 ∂x 2 2 ∂y 2 2 ∂x 2 2 ∂y 2 and with second central differences in space leads to ( ry ) n+1 ( ry ) n rx ) ( rx ) ( = 1 + δx2 1 + δy2 wj,l , 1 − δx2 1 − δy2 wj,l 2 2 2 2 where rx , ry defined as before. M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 11 5/ 7 The scheme ( ry ) n+1 ( ry ) n rx )( rx )( = 1 + δx2 1 + δy2 wj,l , 1 − δx2 1 − δy2 wj,l 2 2 2 2 it is much easier and quicker to use than(it looks )as it splits into two r n+1 : stages with an intermediate quantity vj,l := 1 − 2y δy2 wj,l ) ) ( ( r n Stage 1: 1 − r2x δx2 vj,l = 1 + 2y δy2 wj,l ADI scheme ) ) ( ( r Stage 2: 1 − y δ 2 w n+1 = 1 + rx δ 2 v 2 y j,l 2 x j,l y y The name ADI comes from this idea of alternately solving along the x−direction and y −direction. x x PDEs, Lecture 11 right) Stage Numerical 1 (on Methods left), for Stage 2 (on M. Schmuck (Heriot-Watt University) 6/ 7 ) ( The two step splitting solves the full scheme: Applying 1 − r2x δx2 to Stage 2 gives ( ry ) n+1 ( rx ) ( rx ) ( rx ) 1 − δx2 1 − δy2 wj,l = 1 − δx2 1 + δx2 vj,l 2 2 2 2 ( rx 2 ) ( rx 2 ) = 1 + δx 1 − δx vj,l (difference operators commute (Why?)) 2 2 ( ry 2 ) n rx 2 ) ( = 1 + δx 1 + δy wj,l by Stage 1. 2 2 Advantages: Faster than 2D θ-method: Matrices are tridiagonal and involve only J or L unknowns with operations of O(JL) compared to O(J 3 L3 ) (for the θ-scheme). Exercise for the remaining part of today’s lecture: Show that the 2D ADI scheme is unconditionally stable. The generalisation to 3D (with 2 intermediate variables) of the 2D ADI is not unconditionally stable! M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 11 7/ 7 ) ( The two step splitting solves the full scheme: Applying 1 − r2x δx2 to Stage 2 gives ( ry ) n+1 ( rx ) ( rx ) ( rx ) 1 − δx2 1 − δy2 wj,l = 1 − δx2 1 + δx2 vj,l 2 2 2 2 ( rx 2 ) ( rx 2 ) = 1 + δx 1 − δx vj,l (difference operators commute (Why?)) 2 2 ( ry 2 ) n rx 2 ) ( = 1 + δx 1 + δy wj,l by Stage 1. 2 2 Advantages: Faster than 2D θ-method: Matrices are tridiagonal and involve only J or L unknowns with operations of O(JL) compared to O(J 3 L3 ) (for the θ-scheme). Exercise for the remaining part of today’s lecture: Show that the 2D ADI scheme is unconditionally stable. The generalisation to 3D (with 2 intermediate variables) of the 2D ADI is not unconditionally stable! M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 11 7/ 7