Numerical Methods for Partial Differential Equations CAAM 452 Spring 2005 Lecture 9 Instructor: Tim Warburton.

Slides:



Advertisements
Similar presentations
5.1 Real Vector Spaces.
Advertisements

Partial Differential Equations
Chapter 6: Roots: Open Methods
Part 2 Chapter 6 Roots: Open Methods
259 Lecture 17 Working with Data in MATLAB. Overview  In this lecture, we’ll look at some commands that are useful for working with data!  fzero  sum,
Isoparametric Elements Element Stiffness Matrices
1 Spring 2003 Prof. Tim Warburton MA557/MA578/CS557 Lecture 29.
Ordinary Differential Equations
MATH 685/ CSI 700/ OR 682 Lecture Notes
Atms 4320 Lab 2 Anthony R. Lupo. Lab 2 -Methodologies for evaluating the total derviatives in the fundamental equations of hydrodynamics  Recall that.
Matlab Matlab is a powerful mathematical tool and this tutorial is intended to be an introduction to some of the functions that you might find useful.
Numerical Methods for Partial Differential Equations CAAM 452 Spring 2005 Lecture 11 Instructor: Tim Warburton.
Numerical Methods for Partial Differential Equations CAAM 452 Spring 2005 Instructor: Tim Warburton.
Ordinary Differential Equations (ODEs)
Differential Equations and Boundary Value Problems
Numerical Methods for Partial Differential Equations CAAM 452 Spring 2005 Lecture 9 Instructor: Tim Warburton.
Numerical Methods for Partial Differential Equations CAAM 452 Spring 2005 Lecture 2 Instructor: Tim Warburton.
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers Daniel Baur ETH Zurich, Institut.
Fin500J Topic 7Fall 2010 Olin Business School 1 Fin500J Mathematical Foundations in Finance Topic 7: Numerical Methods for Solving Ordinary Differential.
Numerical Methods for Partial Differential Equations CAAM 452 Spring 2005 Lecture 6 Various Finite Difference Discretizations for the Advection Equations.
Pseudospectral Methods
Numerical Methods for Partial Differential Equations
Professor Walter W. Olson Department of Mechanical, Industrial and Manufacturing Engineering University of Toledo Solving ODE.
Gerschgorin Circle Theorem. Eigenvalues In linear algebra Eigenvalues are defined for a square matrix M. An Eigenvalue for the matrix M is a scalar such.
Numerical Methods for Partial Differential Equations CAAM 452 Spring 2005 Lecture 8 Instructor: Tim Warburton.
Ch 8.1 Numerical Methods: The Euler or Tangent Line Method
ME451 Kinematics and Dynamics of Machine Systems Numerical Solution of DAE IVP Newmark Method November 1, 2013 Radu Serban University of Wisconsin-Madison.
Lecture 22 MA471 Fall Advection Equation Recall the 2D advection equation: We will use a Runge-Kutta time integrator and spectral representation.
1 Spring 2003 Prof. Tim Warburton MA557/MA578/CS557 Lecture 5a.
Numerical Methods for Partial Differential Equations CAAM 452 Spring 2005 Lecture 3 AB2,AB3, Stability, Accuracy Instructor: Tim Warburton.
MATLAB Basics. The following screen will appear when you start up Matlab. All of the commands that will be discussed should be typed at the >> prompt.
1 Spring 2003 Prof. Tim Warburton MA557/MA578/CS557 Lecture 31.
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 31.
Integration of 3-body encounter. Figure taken from
Numerical Methods for Partial Differential Equations CAAM 452 Spring 2005 Lecture 5 Summary of convergence checks for LMM and one-step time stepping Instructor:
1 Spring 2003 Prof. Tim Warburton MA557/MA578/CS557 Lecture 8.
6. Introduction to Spectral method. Finite difference method – approximate a function locally using lower order interpolating polynomials. Spectral method.
1 MA/CS471 Lecture 7 Fall 2003 Prof. Tim Warburton
1 Markov Decision Processes Infinite Horizon Problems Alan Fern * * Based in part on slides by Craig Boutilier and Daniel Weld.
Programming assignment #2 Solving a parabolic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 12.
1 Spring 2003 Prof. Tim Warburton MA557/MA578/CS557 Lecture 24.
Numerical Methods for Partial Differential Equations CAAM 452 Spring 2005 Lecture 12 Instructor: Tim Warburton.
Chapter 10 ordinary differential equations (ODEs) Chapter 11 systems of ODEs (6 th edition)
Chapter 7 The Laplace Transform
Advanced Engineering Mathematics, 7 th Edition Peter V. O’Neil © 2012 Cengage Learning Engineering. All Rights Reserved. CHAPTER 4 Series Solutions.
Today’s class Ordinary Differential Equations Runge-Kutta Methods
ACSL, POSTECH1 MATLAB 입문 CHAPTER 8 Numerical Calculus and Differential Equations.
Lecture 39 Numerical Analysis. Chapter 7 Ordinary Differential Equations.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 6 - Chapters 22 and 23.
1 Spring 2003 Prof. Tim Warburton MA557/MA578/CS557 Lecture 25.
1 Spring 2003 Prof. Tim Warburton MA557/MA578/CS557 Lecture 32.
1 Spring 2003 Prof. Tim Warburton MA557/MA578/CS557 Lecture 28.
Solid State Physics Lecture 15 HW 8 Due March 29 Kittel Chapter 7: 3,4,6 The free electron standing wave and the traveling wave are not eigenstates.
Intelligent Robot Lab Pusan National University Intelligent Robot Lab Chapter 6. TRANSIENT RESPONSE -- STABILITY Pusan National University Intelligent.
CHAPTER 3 NUMERICAL METHODS
Numerical Methods for Partial Differential Equations
EEE 431 Computational Methods in Electrodynamics
Part 7 - Chapter 25.
Boundary Element Analysis of Systems Using Interval Methods
Ordinary Differential Equations
Effects of Zeros and Additional Poles
Lecture 19 MA471 Fall 2003.
Class Notes 18: Numerical Methods (1/2)
Homework 3 Q1) Build a finite-difference solver for: with initial condition: Q1a) use Heun’s RK3 time integrator Q1b) use the 4th order central difference.
Part 7 - Chapter 25.
Numerical Analysis Lecture 37.
Numerical Analysis Lecture 38.
Chapter 6. STABILITY Good relationships nurture you. They help you find yourself and who you are. I don’t mean just relationships with boys or men. Relationships.
Pivoting, Perturbation Analysis, Scaling and Equilibration
Presentation transcript:

Numerical Methods for Partial Differential Equations CAAM 452 Spring 2005 Lecture 9 Instructor: Tim Warburton

CAAM 452 Spring 2005 Today Change of plan –I will go through in detail how to solve homework 3 step by step.

CAAM 452 Spring 2005 Homework 3 Q1) Build a finite-difference solver for Q1a) use your Cash-Karp Runge-Kutta time integrator from HW2 for time stepping Q1b) use the 4 th order central difference in space (periodic domain) Q1c) perform a stability analysis for the time-stepping (based on visual inspection of the CK R-K stability region containing the imaginary axis) Q1d) bound the spectral radius of the spatial operator Q1e) choose a dt well in the stability region Q1f) perform four runs with initial condition (use M=20,40,80,160) and compute maximum error at t=8 Q1g) estimate the accuracy order of the solution. Q1h) extra credit: perform adaptive time-stepping to keep the local truncation error from time stepping bounded by a tolerance.

CAAM 452 Spring 2005 Q1a – Use Cash-Karp RK for Time- Stepping We will use a vector version of Cash-Karp: Where f is a vector valued function – in our case it will be a linear operator acting on a vector argument.

CAAM 452 Spring 2005 Where the b,c coefficients are Provided in cashkarp.m on the web site. Original paper at:

CAAM 452 Spring 2005 Homework 3 Q1) Build a finite-difference solver for Q1a) use your Cash-Karp Runge-Kutta time integrator from HW2 for time stepping Q1b) use the 4 th order central difference in space (periodic domain) Q1c) perform a stability analysis for the time-stepping (based on visual inspection of the CK R-K stability region containing the imaginary axis) Q1d) bound the spectral radius of the spatial operator Q1e) choose a dt well in the stability region Q1f) perform four runs with initial condition (use M=20,40,80,160) and compute maximum error at t=8 Q1g) estimate the accuracy order of the solution. Q1h) extra credit: perform adaptive time-stepping to keep the local truncation error from time stepping bounded by a tolerance.

CAAM 452 Spring 2005 Recall: 4 th Order Central Difference Scheme The fourth order central difference derivative acts on any vector and gives the following value for each entry of a result vector: Where the increments on the indexing is done modulo M. Since we will use this operator repeatedly I made a function

CAAM 452 Spring 2005 Code Each time step consists of evaluating the 6 intermediate vectors k1,k2,..,k6 And piecing them together. Notice – here I set up u at the start as a vector, and delta4 accepts a vector (and dx) as arguments and returns a vector. i.e. each of k1,k2,..,k6 is a vector.

CAAM 452 Spring 2005 Alternate Code I could also have used loops Note: u is a row vector of length M so the k’s are a matrix of size 6 x M

CAAM 452 Spring 2005 Homework 3 Q1) Build a finite-difference solver for Q1a) use your Cash-Karp Runge-Kutta time integrator from HW2 for time stepping Q1b) use the 4 th order central difference in space (periodic domain) Q1c) perform a stability analysis for the time-stepping (based on visual inspection of the CK R-K stability region containing the imaginary axis) Q1d) bound the spectral radius of the spatial operator Q1e) choose a dt well in the stability region Q1f) perform four runs with initial condition (use M=20,40,80,160) and compute maximum error at t=8 Q1g) estimate the accuracy order of the solution. Q1h) extra credit: perform adaptive time-stepping to keep the local truncation error from time stepping bounded by a tolerance.

CAAM 452 Spring 2005 Cash-Karp The Cash-Karp Runge-Kutta integrator in our case is: Notice, we do not need the time component on the right hand side, because our finite-difference right hand side is independent of time.

CAAM 452 Spring 2005 Linear Stability Analysis We achieve the linear stability analysis by assuming f is linear in u:

CAAM 452 Spring 2005 cont We replace mu*dt with nu

CAAM 452 Spring 2005 cont We wish to remove all the intermediate variables and express the scheme in a one-step form like: Where the multiplier function pi(nu) is a 6 th order polynomial in nu. It is certainly possible to find all the coefficients of this polynomial by hand but a little messy. We can take a short cut – assuming Cash-Karp is actually a 5 th order scheme as claimed we know that the first 6 terms of the polynomial multiplier must be the first 6 terms of the Taylor series for

CAAM 452 Spring 2005 cont So we know that: Where C is to be determined. However, looking at the definition of the stages we see that there is only one contribution to the 6 th order term: So

CAAM 452 Spring 2005 Stability Condition We need to plot the stability region, so we determine the margin of stability by finding nu such that The curve of points in the (root) complex plane with magnitude 1 can be parameterized in theta by So for each theta in [0,2pi) we seek the corresponding nu such that:

CAAM 452 Spring 2005 Matlab roots Command The matlab roots command can be used to find roots of a polynomial. If the polynomial is say: Then construct a vector of coefficients (highest order first): And invoke: roots(a) A vector of the roots (if any) of the polynomial will be returned.

CAAM 452 Spring 2005 Adapting RKabstab.m So I took the routine from the class web page and modified it slightly I hard coded it to use the multiplier polynomial for the Cash-Karp I changed the plotting to use a scatter plot

CAAM 452 Spring 2005 Absolute Stability for Cash-Karp This is a classic picture. What is interesting is that it does not convincingly cover the imaginary axis!.

CAAM 452 Spring 2005 On The Imaginary Axis Here I used Matlab’s polyval to evaluate the multiplier polynomial for nu on the imaginary axis. Conclusion – the absolute stability region is just to the left of the imaginary axis (not a big issue here)

CAAM 452 Spring 2005 Homework 3 Q1) Build a finite-difference solver for Q1a) use your Cash-Karp Runge-Kutta time integrator from HW2 for time stepping Q1b) use the 4 th order central difference in space (periodic domain) Q1c) perform a stability analysis for the time-stepping (based on visual inspection of the CK R-K stability region containing the imaginary axis) Q1d) bound the spectral radius of the spatial operator Q1e) choose a dt well in the stability region Q1f) perform four runs with initial condition (use M=20,40,80,160) and compute maximum error at t=8 Q1g) estimate the accuracy order of the solution. Q1h) extra credit: perform adaptive time-stepping to keep the local truncation error from time stepping bounded by a tolerance.

CAAM 452 Spring 2005 Q1d) Bound the spectral radius of the derivative operator All the eigenvalues of the 4 th order central difference are on the imaginary axis, with values (recall from Lecture 6): So the gotcha is that there is no dt such that the eigenvalues*dt are all exactly inside the stability region. However, we will estimate the largest eigenvalue and make an assumption..

CAAM 452 Spring 2005 Q1d) continued We can estimate the largest magnitude eigenvalue directly.

CAAM 452 Spring 2005 Homework 3 Q1) Build a finite-difference solver for Q1a) use your Cash-Karp Runge-Kutta time integrator from HW2 for time stepping Q1b) use the 4 th order central difference in space (periodic domain) Q1c) perform a stability analysis for the time-stepping (based on visual inspection of the CK R-K stability region containing the imaginary axis) Q1d) bound the spectral radius of the spatial operator Q1e) choose a dt well in the stability region Q1f) perform four runs with initial condition (use M=20,40,80,160) and compute maximum error at t=8 Q1g) estimate the accuracy order of the solution. Q1h) extra credit: perform adaptive time-stepping to keep the local truncation error from time stepping bounded by a tolerance.

CAAM 452 Spring 2005 Q1e) Since we are only integrating for 8 periods let’s choose a reasonable maximum |nu|<=1 So for close to absolute (linear) stability Implies that we can choose: i.e. the time step restriction is: We can further reduce the right hand side of the inequality to reduce marginal growth.

CAAM 452 Spring 2005 Homework 3 Q1) Build a finite-difference solver for Q1a) use your Cash-Karp Runge-Kutta time integrator from HW2 for time stepping Q1b) use the 4 th order central difference in space (periodic domain) Q1c) perform a stability analysis for the time-stepping (based on visual inspection of the CK R-K stability region containing the imaginary axis) Q1d) bound the spectral radius of the spatial operator Q1e) choose a dt well in the stability region Q1f) perform four runs with initial condition (use M=20,40,80,160) and compute maximum error at t=8 Q1g) estimate the accuracy order of the solution. Q1h) extra credit: perform adaptive time-stepping to keep the local truncation error from time stepping bounded by a tolerance.

CAAM 452 Spring 2005 Q1f: Test Runs I already set up this initial condition for the web demos: I modified the testrig.m file to call the centraldifference4CKRK54.m file It looks like reasonable 4 th order convergence.. We examine the error ratios to be more certain T=4

CAAM 452 Spring 2005 Homework 3 Q1) Build a finite-difference solver for Q1a) use your Cash-Karp Runge-Kutta time integrator from HW2 for time stepping Q1b) use the 4 th order central difference in space (periodic domain) Q1c) perform a stability analysis for the time-stepping (based on visual inspection of the CK R-K stability region containing the imaginary axis) Q1d) bound the spectral radius of the spatial operator Q1e) choose a dt well in the stability region Q1f) perform four runs with initial condition (use M=20,40,80,160) and compute maximum error at t=8 Q1g) estimate the accuracy order of the solution. Q1h) extra credit: perform adaptive time-stepping to keep the local truncation error from time stepping bounded by a tolerance.

CAAM 452 Spring 2005 Q1g) Estimate Order of Accuracy of Solution MMax error at t=4Order of accuracy Cool – asymptotically it looks like a fourth order code (in space)

CAAM 452 Spring 2005 Homework 3 Q1) Build a finite-difference solver for Q1a) use your Cash-Karp Runge-Kutta time integrator from HW2 for time stepping Q1b) use the 4 th order central difference in space (periodic domain) Q1c) perform a stability analysis for the time-stepping (based on visual inspection of the CK R-K stability region containing the imaginary axis) Q1d) bound the spectral radius of the spatial operator Q1e) choose a dt well in the stability region Q1f) perform four runs with initial condition (use M=20,40,80,160) and compute maximum error at t=8 Q1g) estimate the accuracy order of the solution. Q1h) extra credit: perform adaptive time-stepping to keep the local truncation error from time stepping bounded by a tolerance.

CAAM 452 Spring 2005 Q1h) Estimating the Local Truncation Error Given the k vectors we can also construct a lower order (4 th order in time) approximation to the updated solution: Then we can ball park what the time step should be:

CAAM 452 Spring 2005 Q1h) Code Form alternative embedded fourth order approximation Estimate reasonable dt Check to see if we should reduce time step. Modify last time step to land on EndTime

CAAM 452 Spring 2005 Q1h) Testing I started with a fairly large time step and let the code adjust itself MMax error at t=4Order of accuracy These are pretty much unchanged from before.

CAAM 452 Spring 2005 Q1h) Adaptive Time Stepping (started with dt=100*dx) Q) Why does it take more time steps for the Lower resolution runs?

CAAM 452 Spring 2005 Note on the Cash-Karp RK Check out: There is an interesting treatment of RK schemes, with the idea of parameterizing embedded RK schemes (n+1 stage, n’th order) by choosing the coefficient in the multiplier directly. Increasing this parameter a little will make sure that at least part of the imaginary axis is inside the absolute stability region.