Finite Difference Methods (FDMs) 1

Similar documents
Finite Difference Methods for Boundary Value Problems

Numerical Solution Techniques in Mechanical and Aerospace Engineering

Finite Difference Methods (FDMs) 2

Numerical Analysis of Differential Equations Numerical Solution of Elliptic Boundary Value

A Hybrid Method for the Wave Equation. beilina

Finite difference method for elliptic problems: I

Sparse Linear Systems. Iterative Methods for Sparse Linear Systems. Motivation for Studying Sparse Linear Systems. Partial Differential Equations

1 Finite difference example: 1D implicit heat equation

MATRICES. a m,1 a m,n A =

Today s class. Linear Algebraic Equations LU Decomposition. Numerical Methods, Fall 2011 Lecture 8. Prof. Jinbo Bi CSE, UConn

SOLVING ELLIPTIC PDES

NUMERICAL METHODS. lor CHEMICAL ENGINEERS. Using Excel', VBA, and MATLAB* VICTOR J. LAW. CRC Press. Taylor & Francis Group

MASSACHUSETTS INSTITUTE OF TECHNOLOGY DEPARTMENT OF MECHANICAL ENGINEERING CAMBRIDGE, MASSACHUSETTS NUMERICAL FLUID MECHANICS FALL 2011

Numerical Solution of Laplace Equation By Gilberto E. Urroz, October 2004

Solving PDEs with CUDA Jonathan Cohen

Numerical Solutions to Partial Differential Equations

Lecture 4.2 Finite Difference Approximation

Computing Spectra of Linear Operators Using Finite Differences

The Finite Difference Method

Iterative Methods for Linear Systems

Basic Aspects of Discretization

Lecture 9 Approximations of Laplace s Equation, Finite Element Method. Mathématiques appliquées (MATH0504-1) B. Dewals, C.

Linear Algebra (Review) Volker Tresp 2017

5. FVM discretization and Solution Procedure

1 Number Systems and Errors 1

Boundary value problems on triangular domains and MKSOR methods

5. Direct Methods for Solving Systems of Linear Equations. They are all over the place...

Linear Systems of Equations. ChEn 2450

Introduction to PDEs and Numerical Methods Tutorial 5. Finite difference methods equilibrium equation and iterative solvers

Chapter 5 HIGH ACCURACY CUBIC SPLINE APPROXIMATION FOR TWO DIMENSIONAL QUASI-LINEAR ELLIPTIC BOUNDARY VALUE PROBLEMS

Kasetsart University Workshop. Multigrid methods: An introduction

Chapter 4. Two-Dimensional Finite Element Analysis

Computational Fluid Dynamics Prof. Sreenivas Jayanti Department of Computer Science and Engineering Indian Institute of Technology, Madras

EE364a Review Session 7

Code: 101MAT4 101MT4B. Today s topics Finite-difference method in 2D. Poisson equation Wave equation

Final year project. Methods for solving differential equations

Introduction to numerical schemes

AMS 529: Finite Element Methods: Fundamentals, Applications, and New Trends

Matrix decompositions

1.Chapter Objectives

Motivation: Sparse matrices and numerical PDE's

1.5 Gaussian Elimination With Partial Pivoting.

MATH 333: Partial Differential Equations

Numerical Methods I: Numerical linear algebra

Boundary Value Problems and Iterative Methods for Linear Systems

Solving the Generalized Poisson Equation Using the Finite-Difference Method (FDM)

Finite Difference Method for PDE. Y V S S Sanyasiraju Professor, Department of Mathematics IIT Madras, Chennai 36

The Solution of Linear Systems AX = B

A simple FEM solver and its data parallelism

Diffusion / Parabolic Equations. PHY 688: Numerical Methods for (Astro)Physics

Numerical Solutions to Partial Differential Equations

Applied Mathematics 205. Unit III: Numerical Calculus. Lecturer: Dr. David Knezevic

2 Two-Point Boundary Value Problems

We wish to solve a system of N simultaneous linear algebraic equations for the N unknowns x 1, x 2,...,x N, that are expressed in the general form

Introduction to Applied Linear Algebra with MATLAB

LAB 5. INTRODUCTION Finite Difference Method

Preface to the Second Edition. Preface to the First Edition

Linear Algebra V = T = ( 4 3 ).

x n -2.5 Definition A list is a list of objects, where multiplicity is allowed, and order matters. For example, as lists

Finite Differences for Differential Equations 28 PART II. Finite Difference Methods for Differential Equations

Index. higher order methods, 52 nonlinear, 36 with variable coefficients, 34 Burgers equation, 234 BVP, see boundary value problems

Additive Manufacturing Module 8

Matrix decompositions

Hani Mehrpouyan, California State University, Bakersfield. Signals and Systems

Alternative Boundary Condition Implementations for Crank Nicolson Solution to the Heat Equation

where is the Laplace operator and is a scalar function.

Linear Algebraic Equations

Numerical solution of the 2-D Poisson equation on an irregular domain with Robin boundary conditions

Lab 2 Worksheet. Problems. Problem 1: Geometry and Linear Equations

Lecture 9: Numerical Linear Algebra Primer (February 11st)

Tutorial 2. Introduction to numerical schemes

LU Factorization. Marco Chiarandini. DM559 Linear and Integer Programming. Department of Mathematics & Computer Science University of Southern Denmark

AMS526: Numerical Analysis I (Numerical Linear Algebra for Computational and Data Sciences)

Linear Algebra (Review) Volker Tresp 2018

Lecture 18 Classical Iterative Methods

Solution Methods. Steady State Diffusion Equation. Lecture 04

Poisson Solvers. William McLean. April 21, Return to Math3301/Math5315 Common Material.

Partial Differential Equations

Domain Decomposition Preconditioners for Spectral Nédélec Elements in Two and Three Dimensions

Lab 1: Iterative Methods for Solving Linear Systems

Consider the following example of a linear system:

Finite Difference Methods for

A High-Order Galerkin Solver for the Poisson Problem on the Surface of the Cubed Sphere

Introduction to Boundary Value Problems

LU Factorization a 11 a 1 a 1n A = a 1 a a n (b) a n1 a n a nn L = l l 1 l ln1 ln 1 75 U = u 11 u 1 u 1n 0 u u n 0 u n...

Linear Algebra Linear Algebra : Matrix decompositions Monday, February 11th Math 365 Week #4

Thomas Algorithm for Tridiagonal Matrix

Relationships Between Planes

Monte Carlo Method for Finding the Solution of Dirichlet Partial Differential Equations

Chapter 4 No. 4.0 Answer True or False to the following. Give reasons for your answers.

Linear Algebra Section 2.6 : LU Decomposition Section 2.7 : Permutations and transposes Wednesday, February 13th Math 301 Week #4

Lecture 3: Gaussian Elimination, continued. Lecture 3: Gaussian Elimination, continued

5.7 Cramer's Rule 1. Using Determinants to Solve Systems Assumes the system of two equations in two unknowns

Introduction - Motivation. Many phenomena (physical, chemical, biological, etc.) are model by differential equations. f f(x + h) f(x) (x) = lim

Partial Differential Equations

Quiz ) Locate your 1 st order neighbors. 1) Simplify. Name Hometown. Name Hometown. Name Hometown.

Numerical Methods I Solving Square Linear Systems: GEM and LU factorization

Bindel, Spring 2016 Numerical Analysis (CS 4220) Notes for

Numerical Methods Process Systems Engineering ITERATIVE METHODS. Numerical methods in chemical engineering Edwin Zondervan

Review for Exam 2 Ben Wang and Mark Styczynski

Transcription:

Finite Difference Methods (FDMs) 1

1 st - order Approxima9on Recall Taylor series expansion: Forward difference: Backward difference: Central difference:

2 nd - order Approxima9on Forward difference: Backward difference: Central difference:

2D Ellip9c PDEs The general elliptic problem that is faced in 2D is to solve (14.1) where is gradient of u in x direction is gradient of u in y direction is the Laplacian Equation (14.1) is to be solved on some bounded domain D in 2-dimensional Euclidean space with boundary that has conditions (14.2)

The 2D Poisson equation is given by (14.3) with boundary conditions (14.4) There is no initial condition, because the equation does not depend on time, hence it becomes boundary value problem. Suppose that the domain is and equation (14.3) is to be solved in D subject to Dirichlet boundary conditions. The domain is covered by a square grid of size

Step 1: Generate a grid. For example, a uniform Cartesian grid can be generated as

Generating grids in MATLAB: % Define domain a = 0; b = 1; c = 0; d = 1; % Define grid sizes M = 50; % number of points N = 50; % number of points hx = (b-a)/m; % length of sub-intervals in x-axis hy = (d-c)/n; % length of sub-intervals in y-axis % Generate 2D arrays of grids [X,Y] = meshgrid(a:hx:b,c:hy:d);

We denote by U a grid function whose value at a typical point in domain D is intended to approximate the exact solution at that point. The solution at the boundary nodes (blue dots) is known from the boundary conditions (BCs) and the solution at the internal grid points (black dots) are to be approximated. Step 2: At a typical internal grid point we approximate the partial derivatives of u by second order central difference,, which is second order accurate since the remainder term is

Then the Poisson equation is approximated as (14.5) where

The local truncation error satisfies where. The finite difference discretization is consistent if We ignore the error term and replace the exact solution values at the grid points with the approximate solution values, that is

(14.6) The finite difference equation at the grid point involves five grid points in a five-point stencil:,,,, and. The center is called the master grid point, where the finite difference equation is used to approximate the PDE.

Suppose that rearranged into, then equation (14.6) can be (14.7) The difference replacement (14.7) is depicted as in the fivepoint stencil:

Step 3: Solve the linear system of algebraic equations (14.7) to get the approximate values for the solution at all grid points. Step 4: Error analysis, implementation, visualization, etc. The linear system of equations (14.7) will transform into a matrix-vector form: (14.8) where, from 2D Poisson equations, the unknowns 2D array which we will order into a 1D array. are a

While it is conventional to represent systems of linear algebraic equations in matrix-vector form, it is not always necessary to do so. The matrix-vector format is useful for explanatory purposes and (usually) essential if a direct linear equation solver is to be used, such as Gaussian elimination or LU factorization. For particularly large systems, iterative solution methods are more efficient and these are usually designed so as not to require the construction of a coefficient matrix but work directly with approximation (14.7). Since and suppose that Hence, there are 9 equations and 9 unknowns. The first decision to be taken is how to organize the unknowns into a vector.

The equations are ordered in the same way as the unknowns so that each row of the matrix of coefficients representing the left of (14.7) will contain at most 5 non-zero entries with the coefficient 4 appearing on the diagonal. When (14.7) is applied at points adjacent to the boundary, one or more of the neighboring values will be known from the BCs and the corresponding term will be moved to the right side of the equations. For example, when : The values of are known from the BCs, hence they are on the right side of the equations. Then the first row of the matrix will contain only three non-zero entries.

Inner grid points are to be approximated Arranging into a vector:

Outer grid points are known from the boundary conditions.

Working on the first column of the inner grid points gives us Arranging in matrix-vector form yields

The second column of the inner grid points gives Arranging in matrix-vector form yields:

The third column gives Arranging in matrix-vector form yields

Top BC Le# BC Bo/om BC Right BC

For general case, we focus on the equations on the i-th column of the grid. Since the unknowns in this column are linked only to unknowns on the two neighboring columns, these can be expressed as where B is the tridiagonal matrix,

Methods to generate tridiagonal matrix in MATLAB % (1) Use for loop D = zeros(m-1,m-1); D(1,1) = beta; D(1,2) = -alpha; for i=2:m-2 D(i,i) = beta; D(i,i-1) = -alpha; D(i,i+1) = -alpha; end D(M-1,M-2) = -alpha; D(M-1,M-1) = beta; % (2) Use built-in function diag r2 = beta*ones(m-1,1); r = -alpha*ones(m-1,1); A = diag(r2,0) + diag(r(1:m-2),1) + diag(r(1:m-2),-1); % or s2 = beta*ones(m-1,1); s = -alpha*ones(m-2,1); B = diag(s2,0) + diag(s,1) + diag(s,-1);

The vector arises from the top and bottom boundaries. Also, when i = 1 or M 1, boundary conditions from the vertical edges are applied, so that

The difference equation can now be expressed as a system of the form where A is an matrix and the unknowns and the right hand side vector. A has the tridiagonal matrix structure:

where I is the right hand side vector F: identity matrix, and the It is essential to store matrices A, B, and I as sparse matrices, only the non-zero entries are stored.

Generating matrices B and A in MATLAB % Build matrix B r2 = 2*ones(M-1,1); r = -ones(m-2,1); B = diag(r2,0) + diag(r,1) + diag(r,-1); % Sparse matrix B B = sparse(b); % Build sparse identity matrix I = speye(m-1); % Build tridiagonal block matrix A A = kron(b,i) + kron(i,b);

Solve the BVP defined by: Example on a unit square with boundary conditions: using second order approximation (central finite difference).

Example

2D Poisson Equa9on The right hand side function in MATLAB function f = poisson_rhs(x,y) f = 20*cos(3*pi*X).*sin(2*pi*Y); Dirichlet BCs in MATLAB function G = poisson_bcs(x,y,m) G(:,1) = Y(:,1).^2; % left G(:,M+1) = ones(m+1,1); % right G(1,:) = X(1,:).^3; % bottom G(M+1,:) = ones(1,m+1); % top

Neumann Problem Poisson equation (14.3) is to be solved on the square domain subject to Neumann boundary condition where denotes differentiation in the direction of the outward normal to The normal is not well defined at corners of the domain and need not be continuous there. To generate a finite difference approximation of this problem we use the same grid as before and Poisson equation (14.3) is approximated at internal grid points by the five-point stencil.

Neumann Problem At vertical boundaries, where Taylor expansions, subtracting the gives us Rearrange to get (14.9)

Neumann Problem Along the boundary where (note the negative sign appropriate for the outward normal on this boundary), when this is applied at the grid point and we neglect the remainder term, we obtain or (14.10) This approximation involves the value of U at the fictitious grid point which lies outside the domain D. We write the approximation (14.7) at the boundary points (14.11)

Neumann Problem We may eliminate between (14.10) and (14.11) to obtain a difference formula with a four point stencil by rearranging the formula in (14.10) into and substitute this into (14.11) to get (14.12) or (14.13)

Neumann Problem Along the boundary or at where now the outward normal is positive or, we obtain (14.14) where we have substitution for the fictitious grid point that lies outside the domain D: (14.15) Similar to the left boundary, the approximation (14.7) at the right boundary becomes (14.16)

Neumann Problem = fic44ous point

Neumann Problem Equation (14.13) also holds with where we also have which is approximated by at the corner (note the positive sign) (14.17) Combining (14.17) with (14.13) at we find Hence, for the corner point on the left boundary (14.18)

Neumann Problem For the bottom point at where the outward normal becomes, the approximation is represented by to get the fictitious point (14.19) Hence at the corner bottom point on the left boundary, substituting (14.12) and (14.19) into (14.7) we get (14.20)

Neumann Problem In summary, for Neumann BC we need approximation for for the corner points, which, from the approximation at point

Neumann Problem The points outside the boundary on the left are approximated using (14.12). The points outside the boundary on the right are approximated using (14.15). The points outside the boundary on the bottom are approximated using (14.19). The points outside the boundary on the top are approximated using (14.17).

Neumann Problem Proceeding in this manner for each of the boundary segments and each corner, we arrive at linear equations for the values of U in the domain and on boundaries. We then should assemble the equations into a matrix form (14.16) where we use the same column-wise ordering as before.

where Neumann Problem

Neumann Problem The right hand side for F actually is approximated in matrix form where

Solve the BVP defined by: Example on a unit square with zero-flux on all boundaries: using second order approximation (central finite difference).

Example