Platzhalter für Bild, Bild auf Titelfolie hinter das Logo einsetzen Introduction to PDEs and Numerical Methods Tutorial 5. Finite difference methods equilibrium equation and iterative solvers Dr. Noemi Friedman, 13.12.2013.
Instationary heat equation what to solve? Stability checking from eigenvalue analysis: Method of lines Euler forward method find the eigenvalues (λ j ) and eigenvectors (v j ) of matrix A u n+1 = I + ΔtA u n u n+1 = Bu n B Euler backward method u n = I ΔtA u n+1 B 1 Theta method I θδta u n+1 = I + 1 θ ΔtA B 1θ B 2θ u n B 1 u n+1 = u n B 1θ u n+1 = B 2θ u n Solve system of equations Gx = b solve for x 13. 12. 2013. Dr. Noemi Friedman PDE tutorial Seite 2
Instationary heat equation what to solve? u n = I ΔtA u n+1 I θδta u n+1 = I + 1 θ ΔtA B 1 B 1θ B 2θ u n B 1 u n+1 = u n B 1θ u n+1 = B 2θ u n What do we know about the matrices B 1 and B 1θ? Recall 1D instationary heat equation with three point stencil: d dt u 1 (t) u j 1 (t) u j (t) u j+1 (t) u N 1 (t) = β2 h 2 u j (t) t = β2 h 2 u j+1 2u j + u j 1 + O(h 2 ) u 1 (t) u j 1 (t) u j (t) u j+1 (t) u N 1 (t) 1 13. 12. 2013. Dr. Noemi Friedman PDE tutorial Seite 3
Instationary heat equation what to solve? A: triangular matrix B 1 = I ΔtA B 1θ = I θδta tridiagonal matrices Recall 2D instationary heat equation : (See Tutorial 3.) If dx=dy: After time discr. with theta method: n + 1 13. 12. 2013. Dr. Noemi Friedman PDE tutorial Seite 4 n
Instationary heat equation what to solve? f 0 Δt β2 h 2 : = r u n+1 j,l rθ 4u n+1 j,l + u n+1 j 1,l + u n+1 j+1,l + u n+1 j,l 1 + u n+1 j,l+1 = = u n j,l + r 1 θ 4u n j,l + u n j 1,l + u n j+1,l + u n j,l 1 + u n j,l+1 θ = 1 Euler backward method u n+1 j,l r 4u n+1 j,l + u n+1 j 1,l + u n+1 j+1,l + u n+1 j,l 1 + u n+1 j,l+1 = u n j,l 13. 12. 2013. Dr. Noemi Friedman PDE tutorial Seite 5
Instationary heat equation what to solve? (0, N) (M, N) n = u n 1,1 u n 2,1 u n 3,1 u n M 1,1 u n 1,2 u n 2,2 u n M 1,2 u n 1,N 1 u n M 1,N 1 u n = u n 1,1 u n 2,1 u n 3,1 u n 4,1 u n 1,2 u n 2,2 u n 3,2 u n 4,2 u n 1,3 u n 2,3 u n 3,3 u n 4,3 l = 1.. N y = lδy (0,1) (1,1) (2,1) (3,1) (M, 1) (0,0) (1,0) (2,0) (3,0) x = jδx (2,3) (1,2) (2,2) (3,2) j = 1.. M (M, 1) with homogenous Dirichlet BC. u n+1 j,l r 4u n+1 j,l + u n+1 j 1,l + u n+1 j+1,l + u n+1 j,l 1 + u n+1 j,l+1 = u n j,l 13. 12. 2013. Dr. Noemi Friedman PDE tutorial Seite 6
Instationary heat equation what to solve? u n+1 j,l r 4u n+1 j,l + u n+1 j 1,l + u n+1 j+1,l + u n+1 j,l 1 + u n+1 j,l+1 = u n j,l with homogenous Dirichlet BC. 4 1 1 1 4 1 1 1 4 1 1 1 4 1 1 4 1 1 +r 0 1 0 0 1 4 1 0 0 1 0 0 1 1 4 1 1 1 1 4 1 1 4 1 1 1 4 1 1 1 4 1 1 1 4 u n+1 1,1 u n+1 2,1 u n+1 3,1 u n+1 4,1 u n+1 1,2 u n+1 2,2 u n+1 3,2 u n+1 4,2 u n+1 1,3 u n+1 2,3 u n+1 3,3 u n+1 4,3 Sparse matrix with bandwidth: 2M-1 (here 9) BUT the band itself is sparse, only five diagonals are nonzero 13. 12. 2013. Dr. Noemi Friedman PDE tutorial Seite 7
Instationary heat equation what to solve? u n+1 j,l r 4u n+1 j,l + u n+1 j 1,l + u n+1 j+1,l + u n+1 j,l 1 + u n+1 j,l+1 = u n j,l B 1 u n+1 = u n where B 1 = B C C B C C B B = 1 + 4r r r 1 + 4r r r 1 + 4r C = r r r 13. 12. 2013. Dr. Noemi Friedman PDE tutorial Seite 8
Stationary heat equation what to solve? Instationary heat equation with constant BC, and source term approaches a stationary state: (parabolic) Equilibrium equation (stationary heat equation): Discretised form: (elliptic) 13. 12. 2013. Dr. Noemi Friedman PDE tutorial Seite 9
Stationary heat equation what to solve? Conclusion instationary heat equation with implicit FD System of linear equations: methods (Euler backward, Theta method) stationary heat equation Gx = b solve for x Where the G matrix is in general sparse, banded can get very large with refined spatial and temporal discretisation for 1D heat equation with three-point-stencils: tridiagonal for 1D heat equation with five-point-stencils: pentadiagonal for 2D heat equation: banded with sparse band 13. 12. 2013. Dr. Noemi Friedman PDE tutorial Seite 10
Stationary and instationary heat equation how to solve? 1.) Solve system of equation directly Gx = b Calculate inverse from Cramer-rule: x i = det (A i) det (A) 2 n + 1! operations Gauß-Jordan elimination Gauß elimination, LU decomposition (Cholesky decomp. If G is symmetric and pos.def., Thomas algorithm, if matrix is tridiagonal) G = L U 2n 2 operations Gx = L Ux y Ly = b Ux = y = b forward substitution back substitution 13. 12. 2013. Dr. Noemi Friedman PDE tutorial Seite 11
Stationary and instationary heat equation how to solve? Direct solve G = LL LL factorisation with Gauß method g 11 g 12 g 21 g 22 = l 11 0 l 21 l 22 u 11 u 12 0 u 22 g 11 = l 11 u 11 g 12 = l 11 u 12 g 21 = l 21 u 11 g 22 = l 21 u 12 + l 22 u 22 4 equations 6 unknowns 1 0 l 21 1 u 11 u 12 0 u 22 g 11 = 1u 11 g 12 = 1u 12 1 0 l 21 1 g 11 g 12 0 u 22 g 21 = l 21 g 11 g 22 = l 21 g 12 + 1u 22 1 0 g 21 g 11 1 g 11 g 12 0 g 22 l 21 g 12 13. 12. 2013. Dr. Noemi Friedman PDE tutorial Seite 12
Stationary and instationary heat equation how to solve? Direct solve Gauß factorization G = LL in general n 2 equations n 2 l + n unknowns ii = 1 General algorithm fff i = k + 1 n l ii = g ii (k) g kk (k) fff j = k + 1.. n g ii (k+1) = g ij (k) l ii g kj (k) ~ 2n3 3 operations But even if the matrix is nonsingular the elements g kk (k) (pivot elements) can be zero Pivoting (flip rows or columns) can be also important for reducing roundoff errors g kk (k) won t be zero if the matrix is positivive definit or if it is diagonally dominant 13. 12. 2013. Dr. Noemi Friedman PDE tutorial Seite 13
Stationary and instationary heat equation how to solve? Direct solve If G is positive definit+symmetric G = LL = HH T Tridiagonal system: G = a 1 c 1 e 2 a 2 c 2 e n a n L = LL factorisation with Cholesky decomposition Thomas algorithm 1 β 2 1 β n 1 U = ~ n3 3 operations (half of the Gauß method) α 1 c 1 α 2 c 2 α n α 1 = a 1 β i = e i α 1 1 α i = a i β i c i 1 i = 2 n What happens with the roundoff errors in G = LL = G + δδ G Gx = b G + δδ x = b + δb x x x λ mmm λ mmm δδ b O(n) operations λ mmm λ mmm = K(A) 13. 12. 2013. Dr. Noemi Friedman PDE tutorial Seite 14
Stationary and instationary heat equation how to solve? Iterative methods If G is too large, and/or banded but the band is sparse iterative solvers Gx = b x (k+1) = BB (k) + g (1) B depends on G (iteration matrix) g depends on G and b such that it must satisfy the relation: x = BB + g How do I know that my iterative solver converges to x? x = G 1 b g = G 1 b BG 1 b = I B G 1 b (2) x = BB + g (1)-(2): e (k+1) = BB (k) eith the error: e (k) = x x (k) If B is symmetric and pos.def. e (k+1) = BB (k) ρ(b) e (k) ρ B = λ mmm (spectral radius) e (k) ρ(b) k e (0) if ρ B < 1 convergence 13. 12. 2013. Dr. Noemi Friedman PDE tutorial Seite 15