AM 205: lecture 14. Last time: Boundary value problems Today: Numerical solution of PDEs

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

An Introduction to Numerical Methods for Differential Equations. Janet Peterson

INTRODUCTION TO PDEs

Scientific Computing: An Introductory Survey

Introduction to Partial Differential Equations

Tutorial 2. Introduction to numerical schemes

Finite Difference Methods for Boundary Value Problems

CLASSIFICATION AND PRINCIPLE OF SUPERPOSITION FOR SECOND ORDER LINEAR PDE

First order Partial Differential equations

Chapter 3 Second Order Linear Equations

Chapter 3. Second Order Linear PDEs

Numerical Methods for PDEs

LECTURE # 0 BASIC NOTATIONS AND CONCEPTS IN THE THEORY OF PARTIAL DIFFERENTIAL EQUATIONS (PDES)

M.Sc. in Meteorology. Numerical Weather Prediction

PDE Solvers for Fluid Flow

Solving First Order PDEs

Video 15: PDE Classification: Elliptic, Parabolic and Hyperbolic March Equations 11, / 20

Analysis III (BAUG) Assignment 3 Prof. Dr. Alessandro Sisto Due 13th October 2017

Partial Differential Equations

2.29 Numerical Fluid Mechanics Spring 2015 Lecture 9

Linear Algebra. Chapter 8: Eigenvalues: Further Applications and Computations Section 8.2. Applications to Geometry Proofs of Theorems.

Lecture 1. Finite difference and finite element methods. Partial differential equations (PDEs) Solving the heat equation numerically

Solving First Order PDEs

General Technical Remarks on PDE s and Boundary Conditions Kurt Bryan MA 436

Mathematical Methods - Lecture 9

BOUNDARY-VALUE PROBLEMS IN RECTANGULAR COORDINATES

Additive Manufacturing Module 8

Partial Differential Equations

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

Introduction to Boundary Value Problems

Discretization of PDEs and Tools for the Parallel Solution of the Resulting Systems

Chapter 2 Boundary and Initial Data

ENGI 9420 Lecture Notes 8 - PDEs Page 8.01

Applied Math Qualifying Exam 11 October Instructions: Work 2 out of 3 problems in each of the 3 parts for a total of 6 problems.

Lecture 6: Introduction to Partial Differential Equations

AMS 147 Computational Methods and Applications Lecture 17 Copyright by Hongyun Wang, UCSC

Partial differential equations

Partial Differential Equations

Conservation Laws and Finite Volume Methods

x = x y and y = x + y.

Last time: Diffusion - Numerical scheme (FD) Heat equation is dissipative, so why not try Forward Euler:

13 PDEs on spatially bounded domains: initial boundary value problems (IBVPs)

HOMEWORK 4: Numerical solution of PDEs for Mathmatical Models, Analysis and Simulation, Fall 2011 Report due Mon Nov 12, Maximum score 6.0 pts.

ENGI 4430 PDEs - d Alembert Solutions Page 11.01

Lecture Introduction

Numerical Solutions to PDE s

Numerical Methods for PDEs

8.6 Translate and Classify Conic Sections

Numerical Solutions to Partial Differential Equations

From Completing the Squares and Orthogonal Projection to Finite Element Methods

Before we look at numerical methods, it is important to understand the types of equations we will be dealing with.

Final: Solutions Math 118A, Fall 2013

Math 2a Prac Lectures on Differential Equations

MATH 333: Partial Differential Equations

Transforming Nonhomogeneous BCs Into Homogeneous Ones

Numerical Analysis and Methods for PDE I

Problem set 3: Solutions Math 207B, Winter Suppose that u(x) is a non-zero solution of the eigenvalue problem. (u ) 2 dx, u 2 dx.

Numerical Solutions to Partial Differential Equations

Introduction of Partial Differential Equations and Boundary Value Problems

7 Hyperbolic Differential Equations

Part 1. The diffusion equation

Lecture Notes on Partial Dierential Equations (PDE)/ MaSc 221+MaSc 225

ENGI 9420 Lecture Notes 8 - PDEs Page 8.01

3.4 Conic sections. Such type of curves are called conics, because they arise from different slices through a cone

Conservation Laws and Finite Volume Methods

A Note on Integral Transforms and Partial Differential Equations

Lecture 38 Insulated Boundary Conditions

Lecture 10. (2) Functions of two variables. Partial derivatives. Dan Nichols February 27, 2018

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

MATH 425, FINAL EXAM SOLUTIONS

Lecture Notes on PDEs

MATH-UA 263 Partial Differential Equations Recitation Summary

Table of Contents. II. PDE classification II.1. Motivation and Examples. II.2. Classification. II.3. Well-posedness according to Hadamard

4.5 Integration of Rational Functions by Partial Fractions

Numerical Analysis of Differential Equations Numerical Solution of Elliptic Boundary Value

UNIVERSITY of LIMERICK OLLSCOIL LUIMNIGH

Updated: January 16, 2016 Calculus II 7.4. Math 230. Calculus II. Brian Veitch Fall 2015 Northern Illinois University

Marching on the BL equations

Numerical Methods for Conservation Laws WPI, January 2006 C. Ringhofer C2 b 2

2.29 Numerical Fluid Mechanics Spring 2015 Lecture 13

An Introduction to Partial Differential Equations

First order wave equations. Transport equation is conservation law with J = cu, u t + cu x = 0, < x <.

Introduction to PDEs and Numerical Methods Lecture 1: Introduction

PDEs, part 3: Hyperbolic PDEs

1. Projective geometry

Method of Lines. Received April 20, 2009; accepted July 9, 2009

Chapter Two: Numerical Methods for Elliptic PDEs. 1 Finite Difference Methods for Elliptic PDEs

Modeling using conservation laws. Let u(x, t) = density (heat, momentum, probability,...) so that. u dx = amount in region R Ω. R

Chapter 10 Exercises

z x = f x (x, y, a, b), z y = f y (x, y, a, b). F(x, y, z, z x, z y ) = 0. This is a PDE for the unknown function of two independent variables.

Lecture 16: Relaxation methods

Finite Difference and Finite Element Methods

4F3 - Predictive Control

Numerical Solutions to Partial Differential Equations

Math 660-Lecture 23: Gudonov s method and some theories for FVM schemes

LECTURE 15 + C+F. = A 11 x 1x1 +2A 12 x 1x2 + A 22 x 2x2 + B 1 x 1 + B 2 x 2. xi y 2 = ~y 2 (x 1 ;x 2 ) x 2 = ~x 2 (y 1 ;y 2 1

Splitting methods with boundary corrections

A First Course of Partial Differential Equations in Physical Sciences and Engineering

Chapter 3. Finite Difference Methods for Hyperbolic Equations Introduction Linear convection 1-D wave equation

Propagation of discontinuities in solutions of First Order Partial Differential Equations

Transcription:

AM 205: lecture 14 Last time: Boundary value problems Today: Numerical solution of PDEs

ODE BVPs A more general approach is to formulate a coupled system of equations for the BVP based on a finite difference approximation Suppose we have a grid x i = a + ih, i = 0, 1,..., n 1, where h = (b a)/(n 1) Then our approximation to u C 2 [a, b] is represented by a vector U R n, where U i u(x i )

ODE BVPs Recall the ODE: αu (x) + βu (x) + γu(x) = f (x), x [a, b] Let s develop an approximation for each term in the ODE For the reaction term γu, we have the pointwise approximation γu i γu(x i )

ODE BVPs Similarly, for the derivative terms: Let D 2 R n n denote diff. matrix for the second derivative Let D 1 R n n denote diff. matrix for the first derivative Then α(d 2 U) i αu (x i ) and β(d 1 U) i βu (x i ) Hence, we obtain (AU) i αu (x i ) + βu (x i ) + γu(x i ), where A R n n is: A αd 2 + βd 1 + γi Similarly, we represent the right hand side by sampling f at the grid points, hence we introduce F R n, where F i = f (x i )

ODE BVPs Therefore, we obtain the linear 1 system for U R n : AU = F Hence, we have converted a linear differential equation into a linear algebraic equation (Similarly we can convert a nonlinear differential equation into a nonlinear algebraic system) However, we are not finished yet, need to account for the boundary conditions! 1 It is linear here since the ODE BVP is linear

ODE BVPs Dirichlet boundary conditions: we need to impose U 0 = c 1, U n 1 = c 2 Since we fix U 0 and U n 1, they are no longer variables: we should eliminate them from our linear system However, instead of removing rows and columns from A, it is slightly simpler from the implementational point of view to: zero out first row of A, then set A(0, 0) = 1 and F 0 = c 1 zero out last row of A, then set A(n 1, n 1) = 1 and F n 1 = c 2

ODE BVPs We can implement the above strategy for AU = F in Python Useful trick 2 for checking your code: 1. choose a solution u that satisfies the BCs 2. substitute into the ODE to get a right-hand side f 3. compute the ODE approximation with f from step 2 4. verify that you get the expected convergence rate for the approximation to u e.g. consider x [0, 1] and set u(x) = e x sin(2πx): f (x) αu (x) + βu (x) + γu(x) = αe x [ 4π cos(2πx) + (1 4π 2 ) sin(2πx) ] + βe x [sin(2πx) + 2π cos(2πx)] + γe x sin(2πx) 2 Sometimes called the method of manufactured solutions

ODE BVPs Python example: ODE BVP via finite differences Convergence results: h 2.0e-2 1.0e-2 5.0e-3 2.5e-3 error 5.07e-3 1.26e-3 3.17e-4 7.92e-5 O(h 2 ), as expected due to second order differentiation matrices

ODE BVPs: BCs involving derivatives Question: How would we impose the Robin boundary condition u (b) + c 2 u(b) = c 3, and preserve the O(h 2 ) convergence rate? Option 1: Introduce a ghost node at x n = b + h, this node is involved in both the B.C. and the (n 1) th matrix row Employ central difference approx. to u (b) to get approx. B.C.: or equivalently U n U n 2 2h + c 2 U n 1 = c 3, U n = U n 2 2hc 2 U n 1 + 2hc 3

ODE BVPs: BCs involving derivatives The (n 1) th equation is α U n 2 2U n 1 + U n h 2 + β U n U n 2 2h + γu n 1 = F n 1 We can substitute our expression for U n into the above equation, and hence eliminate U n : ( 2αc ) 3 + βc 3 2α ( ) 2α h h 2 U n 2+ h 2 (1 + hc 2) βc 2 + γ U n 1 = F n 1 Set F n 1 F n 1 ( 2αc 3 h + βc 3 ), we get n n system AU = F Option 2: Use a one-sided difference formula for u (b) in the Robin BC, as in III.2

Partial Differential Equations

3 Notation: u x u x, uxy y ( u ) x PDEs As discussed in III.1, it is a natural extension to consider Partial Differential Equations (PDEs) There are three main classes of PDEs: 3 equation type prototypical example equation hyperbolic wave equation u tt u xx = 0 parabolic heat equation u t u xx = f elliptic Poisson equation u xx + u yy = f Question: Where do these names come from?

PDEs Answer: The names are related to conic sections General second-order PDEs have the form au xx + bu xy + cu yy + du x + eu y + fu + g = 0 This looks like the quadratic function q(x) = ax 2 + bxy + cy 2 + dx + ey

PDEs: Hyperbolic Wave equation: u tt u xx = 0 Corresponding quadratic function is q(x, t) = t 2 x 2 q(x, t) = c gives a hyperbola, e.g. for c = 0 : 2 : 6, we have 6 4 2 0 2 4 6 5 4 3 2 1 0 1 2 3 4 5

PDEs: Parabolic Heat equation: u t u xx = 0 Corresponding quadratic function is q(x, t) = t x 2 q(x, t) = c gives a parabola, e.g. for c = 0 : 2 : 6, we have 35 30 25 20 15 10 5 0 5 4 3 2 1 0 1 2 3 4 5

PDEs: Elliptic Poisson equation: u xx + u yy = f Corresponding quadratic function is q(x, y) = x 2 + y 2 q(x, y) = c gives an ellipse, e.g. for c = 0 : 2 : 6, we have 2 1.5 1 0.5 0 0.5 1 1.5 2 3 2 1 0 1 2 3

PDEs In general, it is not so easy to classify PDEs using conic section naming Many problems don t strictly fit into the classification scheme (e.g. nonlinear, or higher order, or variable coefficient equations) Nevertheless, the names hyperbolic, parabolic, elliptic are the standard ways of describing PDEs, based on the criteria: Hyperbolic: time-dependent, conservative physical process, no steady state Parabolic: time-dependent, dissipative physical process, evolves towards steady state Elliptic: describes systems at equilibrium/steady-state

Hyperbolic PDEs

Hyperbolic PDEs We introduced the wave equation u tt u xx = 0 above Note that the system of first order PDEs u t + v x = 0 v t + u x = 0 is equivalent to the wave equation, since u tt = (u t ) t = ( v x ) t = (v t ) x = ( u x ) x = u xx (This assumes that u, v are smooth enough for us to switch the order of the partial derivatives)

Hyperbolic PDEs Hence we shall focus on the so-called linear advection equation u t + cu x = 0 with initial condition u(x, 0) = u 0 (x), and c R This equation is representative of hyperbolic PDEs in general It s a first order PDE, hence doesn t fit our conic section description, but it is: time-dependent conservative not evolving toward steady state = hyperbolic!

Hyperbolic PDEs We can see that u(x, t) = u 0 (x ct) satisfies the PDE Let z(x, t) x ct, then from the chain rule we have t u 0(x ct) + c x u 0(x ct) = t u 0(z(x, t)) + c x u 0(z(x, t)) = u 0(z) z t + cu 0(z) z x = cu 0(z) + cu 0(z) = 0

Hyperbolic PDEs This tells us that the solution transports (or advects) the initial condition with speed c e.g. with c = 1 and an initial condition u 0 (x) = e (1 x)2 we have: 1.5 t=0 t=5 1 0.5 0 0 2 4 6 8 10

Hyperbolic PDEs We can understand the behavior of hyperbolic PDEs in more detail by considering characteristics Characteristics are paths in the xt-plane denoted by (X (t), t) on which the solution is constant For u t + cu x = 0 we have X (t) = X 0 + ct, 4 since d dt u(x (t), t) = u dx (t) t(x (t), t) + u x (X (t), t) dt = u t (X (t), t) + cu x (X (t), t) = 0 4 Each different choice of X 0 gives a distinct characteristic curve

Hyperbolic PDEs Hence u(x (t), t) = u(x (0), 0) = u 0 (X 0 ), i.e. the initial condition is transported along characteristics Characteristics have important implications for the direction of flow of information, and for boundary conditions Must impose BC at x = a, cannot impose BC at x = b

Hyperbolic PDEs Hence u(x (t), t) = u(0, X (0)) = u 0 (X 0 ), i.e. the initial condition is transported along characteristics Characteristics have important implications for the direction of flow of information, and for boundary conditions Must impose BC at x = b, cannot impose BC at x = a

Hyperbolic PDEs: More Complicated Characteristics More generally, if we have a non-zero right-hand side in the PDE, then the situation is a bit more complicated on each characteristic Consider u t + cu x = f (t, x, u(t, x)), and X (t) = X 0 + ct d dt u(x (t), t) = u dx (t) t(x (t), t) + u x (X (t), t) dt = u t (X (t), t) + cu x (X (t), t) = f (t, X (t), u(x (t), t)) In this case, the solution is no longer constant on (X (t), t), but we have reduced a PDE to a set of ODEs, so that: u(x (t), t) = u 0 (X 0 ) + t 0 f (t, X (t), u(x (t), t)dt

Hyperbolic PDEs: More Complicated Characteristics We can also find characteristics for variable coefficient advection Exercise: Verify that the characteristic curve for u t + c(t, x)u x = 0 is given by dx (t) = c(x (t), t) dt In this case, we have to solve an ODE to obtain the curve (X (t), t) in the xt-plane

Hyperbolic PDEs: More Complicated Characteristics e.g. for c(t, x) = x 1/2, we get X (t) = 1/2 + (X 0 1/2)e t In this case, the characteristics bend away from x = 1/2 1 0.9 0.8 0.7 0.6 t 0.5 0.4 0.3 0.2 0.1 0 2 1.5 1 0.5 0 0.5 1 1.5 2 2.5 3 x Characteristics also apply to nonlinear hyperbolic PDEs (e.g. Burger s equation), but this is outside the scope of AM205

Hyperbolic PDEs: Numerical Approximation We now consider how to solve u t + cu x = 0 equation using a finite difference method Question: Why finite differences? Why not just use characteristics? Answer: Characteristics actually are a viable option for computational methods, and are used in practice However, characteristic methods can become very complicated in 2D or 3D, or for nonlinear problems Finite differences are a much more practical choice in most circumstances

Hyperbolic PDEs: Numerical Approximation We now consider how to solve u t + cu x = 0 equation using a finite difference method Question: Why finite differences? Why not just use characteristics? Answer: Characteristics actually are a viable option for computational methods, and are used in practice However, characteristic methods can become very complicated in 2D or 3D, or for nonlinear problems Finite differences are a much more practical choice in most circumstances

Hyperbolic PDEs: Numerical Approximation Advection equation is an Initial Boundary Value Problem (IBVP) We impose an initial condition, and a boundary condition (only one BC since first order PDE) A finite difference approximation leads to a grid in the xt-plane 6 5 4 t 3 2 1 0 0 1 2 3 4 5 6 7 x

Hyperbolic PDEs: Numerical Approximation The first step in developing a finite difference approximation for the advection equation is to consider the CFL condition 5 The CFL condition is a necessary condition for the convergence of a finite difference approximation of a hyperbolic problem Suppose we discretize u t + cu x = 0 in space and time using the explicit (in time) scheme Here U n j U n+1 j Uj n t + c Un j U n j 1 x = 0 u(t n, x j ), where t n = n t, x j = j x 5 Courant Friedrichs Lewy condition, published in 1928

Hyperbolic PDEs: Numerical Approximation This can be rewritten as where U n+1 j = Uj n c t x (Un j Uj 1) n = (1 ν)uj n + νuj 1 n ν c t x We can see that U n+1 j depends only on U n j and U n j 1

Hyperbolic PDEs: Numerical Approximation Definition: Domain of dependence of U n+1 j depends on U n+1 j is the set of values that 4 3 U n+1 j 2 1 0 0 1 2 3 4 5 6 7

Hyperbolic PDEs: Numerical Approximation The domain of dependence of the exact solution u(t n+1, x j ) is determined by the characteristic curve passing through (t n+1, x j ) CFL Condition: For a convergent scheme, the domain of dependence of the PDE must lie within the domain of dependence of the numerical method