FTCS Solution to the Heat Equation

Similar documents
FTCS Solution to the Heat Equation

Numerical Heat and Mass Transfer

Relaxation Methods for Iterative Solution to Linear Systems of Equations

2 Finite difference basics

NON-CENTRAL 7-POINT FORMULA IN THE METHOD OF LINES FOR PARABOLIC AND BURGERS' EQUATIONS

NUMERICAL DIFFERENTIATION

CHAPTER 5 NUMERICAL EVALUATION OF DYNAMIC RESPONSE

Chapter 5. Solution of System of Linear Equations. Module No. 6. Solution of Inconsistent and Ill Conditioned Systems

Lecture 21: Numerical methods for pricing American type derivatives

Finite Element Modelling of truss/cable structures

Chapter 12. Ordinary Differential Equation Boundary Value (BV) Problems

BTCS Solution to the Heat Equation

Digital Signal Processing

Numerical Transient Heat Conduction Experiment

ME 501A Seminar in Engineering Analysis Page 1

Numerical Solution of Ordinary Differential Equations

Errors for Linear Systems

One-sided finite-difference approximations suitable for use with Richardson extrapolation

The Finite Element Method

2.29 Numerical Fluid Mechanics Fall 2011 Lecture 12

The Exact Formulation of the Inverse of the Tridiagonal Matrix for Solving the 1D Poisson Equation with the Finite Difference Method

PART 8. Partial Differential Equations PDEs

Transfer Functions. Convenient representation of a linear, dynamic model. A transfer function (TF) relates one input and one output: ( ) system

Appendix B. The Finite Difference Scheme

MATH 5630: Discrete Time-Space Model Hung Phan, UMass Lowell March 1, 2018

Lecture 13 APPROXIMATION OF SECOMD ORDER DERIVATIVES

Note 10. Modeling and Simulation of Dynamic Systems

Outline and Reading. Dynamic Programming. Dynamic Programming revealed. Computing Fibonacci. The General Dynamic Programming Technique

Lab session: numerical simulations of sponateous polarization

High resolution entropy stable scheme for shallow water equations

The Discretization Process

IV. Performance Optimization

Handout # 6 (MEEN 617) Numerical Integration to Find Time Response of SDOF mechanical system. and write EOM (1) as two first-order Eqs.

Workshop: Approximating energies and wave functions Quantum aspects of physical chemistry

Econ107 Applied Econometrics Topic 3: Classical Model (Studenmund, Chapter 4)

Implicit Integration Henyey Method

COEFFICIENT DIAGRAM: A NOVEL TOOL IN POLYNOMIAL CONTROLLER DESIGN

6.3.4 Modified Euler s method of integration

Chapter 13: Multiple Regression

Chapter 4 The Wave Equation

Lectures - Week 4 Matrix norms, Conditioning, Vector Spaces, Linear Independence, Spanning sets and Basis, Null space and Range of a Matrix

n α j x j = 0 j=1 has a nontrivial solution. Here A is the n k matrix whose jth column is the vector for all t j=0

Discretization. Consistency. Exact Solution Convergence x, t --> 0. Figure 5.1: Relation between consistency, stability, and convergence.

Consistency & Convergence

Additional Codes using Finite Difference Method. 1 HJB Equation for Consumption-Saving Problem Without Uncertainty

Introduction to Vapor/Liquid Equilibrium, part 2. Raoult s Law:

Queueing Networks II Network Performance

4DVAR, according to the name, is a four-dimensional variational method.

Lecture 2: Numerical Methods for Differentiations and Integrations

Module 3 LOSSY IMAGE COMPRESSION SYSTEMS. Version 2 ECE IIT, Kharagpur

Lecture Notes on Linear Regression

Numerical Simulation of One-Dimensional Wave Equation by Non-Polynomial Quintic Spline

Research Article Cubic B-Spline Collocation Method for One-Dimensional Heat and Advection-Diffusion Equations

Grover s Algorithm + Quantum Zeno Effect + Vaidman

Difference Equations

STAT 309: MATHEMATICAL COMPUTATIONS I FALL 2018 LECTURE 16

APPENDIX 2 FITTING A STRAIGHT LINE TO OBSERVATIONS

Parametric fractional imputation for missing data analysis. Jae Kwang Kim Survey Working Group Seminar March 29, 2010

New Method for Solving Poisson Equation. on Irregular Domains

Normally, in one phase reservoir simulation we would deal with one of the following fluid systems:

Lecture 5.8 Flux Vector Splitting

MMA and GCMMA two methods for nonlinear optimization

Construction of Serendipity Shape Functions by Geometrical Probability

The Multiple Classical Linear Regression Model (CLRM): Specification and Assumptions. 1. Introduction

Lecture 12: Discrete Laplacian

Numerical Methods. ME Mechanical Lab I. Mechanical Engineering ME Lab I

NON-LINEAR CONVOLUTION: A NEW APPROACH FOR THE AURALIZATION OF DISTORTING SYSTEMS

AA214B: NUMERICAL METHODS FOR COMPRESSIBLE FLOWS

U.C. Berkeley CS294: Beyond Worst-Case Analysis Luca Trevisan September 5, 2017

Inductance Calculation for Conductors of Arbitrary Shape

COMPARISON OF SOME RELIABILITY CHARACTERISTICS BETWEEN REDUNDANT SYSTEMS REQUIRING SUPPORTING UNITS FOR THEIR OPERATIONS

Visco-Rubber Elastic Model for Pressure Sensitive Adhesive

Generalized Linear Methods

Section 8.3 Polar Form of Complex Numbers

The Two-scale Finite Element Errors Analysis for One Class of Thermoelastic Problem in Periodic Composites

CME 302: NUMERICAL LINEAR ALGEBRA FALL 2005/06 LECTURE 13

Vector Norms. Chapter 7 Iterative Techniques in Matrix Algebra. Cauchy-Bunyakovsky-Schwarz Inequality for Sums. Distances. Convergence.

Complex Numbers. x = B B 2 4AC 2A. or x = x = 2 ± 4 4 (1) (5) 2 (1)

CSci 6974 and ECSE 6966 Math. Tech. for Vision, Graphics and Robotics Lecture 21, April 17, 2006 Estimating A Plane Homography

A New Refinement of Jacobi Method for Solution of Linear System Equations AX=b

CALCULUS CLASSROOM CAPSULES

ACTM State Calculus Competition Saturday April 30, 2011

Statistical Energy Analysis for High Frequency Acoustic Analysis with LS-DYNA

Remarks on the Properties of a Quasi-Fibonacci-like Polynomial Sequence

Erratum: A Generalized Path Integral Control Approach to Reinforcement Learning

Linear Feature Engineering 11

For now, let us focus on a specific model of neurons. These are simplified from reality but can achieve remarkable results.

Integrals and Invariants of Euler-Lagrange Equations

Curve Fitting with the Least Square Method

PHYS 705: Classical Mechanics. Calculus of Variations II

Numerical Solution of Boussinesq Equations as a Model of Interfacial-wave Propagation

In this section is given an overview of the common elasticity models.

DUE: WEDS FEB 21ST 2018

Linear Approximation with Regularization and Moving Least Squares

The Feynman path integral

Dynamic Programming. Preview. Dynamic Programming. Dynamic Programming. Dynamic Programming (Example: Fibonacci Sequence)

Canonical transformations

An identification algorithm of model kinetic parameters of the interfacial layer growth in fiber composites

Hongyi Miao, College of Science, Nanjing Forestry University, Nanjing ,China. (Received 20 June 2013, accepted 11 March 2014) I)ϕ (k)

Chapter Newton s Method

Transcription:

FTCS Soluton to the Heat Equaton ME 448/548 Notes Gerald Recktenwald Portland State Unversty Department of Mechancal Engneerng gerry@pdx.edu ME 448/548: FTCS Soluton to the Heat Equaton

Overvew 1. Use the forward fnte dfference approxmaton to u/ t. u t uk+1 u k t 2. Use the central dfference approxmaton to 2 u/ x 2 at tme t k. 2 u = uk 1 2uk + uk +1 x 2 x 2 x 3. Solve for u k+1. The computatonal formula s explct: each value of u k+1 updated ndependently. 4. FTCS s easy to mplement, but s only condtonally stable 5. Truncaton errors are O ( ( x) 2) and O( t). can be ME 448/548: FTCS Soluton to the Heat Equaton page 1

Fnte Dfference Operators Choose the forward dfference to evaluate the tme dervatve at t = t k. u t = uk+1 u k + O( t) (1) tk,x t Approxmate the spatal dervatve wth the central dfference operator and take all nodal values at tme t k. 2 u = uk 1 2uk + uk +1 + O( x 2 ) (2) x 2 x 2 x ME 448/548: FTCS Soluton to the Heat Equaton page 2

FTCS Approxmaton to the Heat Equaton Substtute Equaton (1) and Equaton (2) nto the heat equaton u k+1 u k t = α uk 1 2uk + uk +1 x 2 + O( t) + O( x 2 ) (3) Drop truncaton error terms to get u k+1 u k t = α uk 1 2uk + uk +1 x 2 (4) ME 448/548: FTCS Soluton to the Heat Equaton page 3

FTCS Computatonal Molecule t k+1 k k 1....... FTCS scheme enables explct calculaton of u at ths node Soluton s known for these nodes t=0, k=1 =1 1 +1 n x x=0 x=l ME 448/548: FTCS Soluton to the Heat Equaton page 4

FTCS Approxmaton to the Heat Equaton Solve Equaton (4) for u k+1 u k+1 = ru k +1 + (1 2r)uk + ruk 1 (5) where r = α t/ x 2. FTCS s an explct scheme because t provdes a smple formula to update u k+1 ndependently of the other nodal values at t k+1. t....... k+1 k k 1 t=0, k=1 =1 1 +1 n x x=0 x=l ME 448/548: FTCS Soluton to the Heat Equaton page 5

demoftcs Code functon errout = demoftcs(nx,nt) %... Comments and processng of optonal nputs skpped % --- Assgn physcal and mesh parameters alfa = 0.1; L = 1; tmax = 2; % Dffuson coeffcent, doman length and max tme dx = L/(nx-1); dt = tmax/(nt-1); r = alfa*dt/dx^2; r2 = 1-2*r; % --- Assgn IC and BC. u s ntalzed to a vector that ncludes BC x = lnspace(0,l,nx) ; u = sn(p*x/l); % --- Loop over tme steps for k=2:nt uold = u; % prepare for next step for =2:nx-1 u() = r*uold(-1) + r2*uold() + r*uold(+1); end end Remember that the formula for updatng u k+1 s u k+1 = ru k +1 + (1 2r)uk + ruk 1 ME 448/548: FTCS Soluton to the Heat Equaton page 6

Alternatve formulaton to the FTCS Algorthm Equaton (5) can be expressed as a matrx multplcaton. u (k+1) = Au (k) (6) where u (k+1) s the vector of u values at tme step k + 1, u (k) s the vector of u values at tme step k, and A s the trdagonal matrx 1 0 0 0 0 0 r (1 2r) r 0 0 0 0 r (1 2r) r 0 0 A = 0 0......... (7). 0 0 0 0 r (1 2r) r 0 0 0 0 0 1 The frst and last rows of A are set to enforce the Drchlet boundary condtons at x = 0 and x = L. ME 448/548: FTCS Soluton to the Heat Equaton page 7

Run the demoftcs code >> demoftcs Error n FTCS soluton = 0.002221 0.14 0.12 FTCS Exact 0.1 0.08 u 0.06 0.04 0.02 0 0 0.2 0.4 0.6 0.8 1 x ME 448/548: FTCS Soluton to the Heat Equaton page 8

Unstable FTCS Soluton moveftcs(15): 2 1.5 t = 0.41 Intal Condton FTCS soluton 2 1.5 t = 1.63 Intal Condton FTCS soluton 2 1.5 t = 1.96 Intal Condton FTCS soluton 1 1 1 0.5 0.5 0.5 0 0 0 0.5 0.5 0.5 1 0 0.2 0.4 0.6 0.8 1 1 0 0.2 0.4 0.6 0.8 1 1 0 0.2 0.4 0.6 0.8 1 2 1.5 t = 0.82 Intal Condton FTCS soluton 2 1.5 t = 1.88 Intal Condton FTCS soluton 2 1.5 t = 2.00 Intal Condton FTCS soluton 1 1 1 0.5 0.5 0.5 0 0 0 0.5 0.5 0.5 1 0 0.2 0.4 0.6 0.8 1 1 0 0.2 0.4 0.6 0.8 1 1 0 0.2 0.4 0.6 0.8 1 2 1.5 t = 1.22 Intal Condton FTCS soluton 2 1.5 t = 1.92 Intal Condton FTCS soluton 2 1.5 t = 2.04 Intal Condton FTCS soluton 1 1 1 0.5 0.5 0.5 0 0 0 0.5 0.5 0.5 1 0 0.2 0.4 0.6 0.8 1 1 0 0.2 0.4 0.6 0.8 1 1 0 0.2 0.4 0.6 0.8 1 ME 448/548: FTCS Soluton to the Heat Equaton page 9

Condtonally Stable FTCS Scheme Observatons: The FTCS soluton appears to be stable at frst Toward the end of the smulaton tme, oscllatons grow exponentally Instablty s not caused by truncaton error Instablty s fed by round-off errors, but not drectly caused by round-off We ll use a smplfed form of Fourer Stablty Analyss Suppose that the ntal condton s a small sne wave The correct soluton s a decay of the sne wave Under what condton does the soluton grow nstead of decay?

Stablty Analyss Suppose the ntal condton looks lke ths ( ) πx u 0 (x) = σ cos x = σ( 1) 1 where σ s a sutably small value The soluton at tme step k = 2 s u (2) = r ( u 0 (x +1 ) + u 0 (x 1 ) ) + (1 2r)u 0 (x ) = rσ ( ( 1) + ( 1) 2) + (1 2r)σ( 1) 1 = rσ ( ( 1) +1 + ( 1) 1) + (1 2r)σ( 1) 1 ME 448/548: FTCS Soluton to the Heat Equaton page 11

Stablty Analyss Snce ( 1) +1 = ( 1) 1 for any, the soluton at k = 2 can be further smplfed u (2) = 2rσ( 1) 1 + (1 2r)σ( 1) 1 = (1 4r)σ( 1) 1 = (1 4r)u 0 (x ) The pattern s u (2) = (1 4r)u 0 (x ) u (3) = (1 4r)u (2) (x ) = (1 4r) 2 u 0 (x ) u (4) = (1 4r)u (3) (x ) = (1 4r) 3 u 0 (x ) where u (2) s the numercal soluton at x and k = 2; and where (1 4r) 2 s the square of (1 4r) ME 448/548: FTCS Soluton to the Heat Equaton page 12

Stablty Analyss The general pattern s u k = (1 4r)k 1 u 0 (x ). where (1 4r) k 1 s (1 4r) rased to the k 1 power. Therefore, the soluton grows when 1 4r > 1. Therefore, stablty requres 1 4r < 1 and (1 4r) < 1. 1 4r < 1 = 4r < 2 = r > 1 2 true for any r > 0. The second case s (1 4r) < 1 = 4r < 2 = r < 1 2 ME 448/548: FTCS Soluton to the Heat Equaton page 13

Stablty Analyss The quck and drty stablty analyss shows that the FTCS scheme s stable only f r = α t x 2 < 1 2. (8) Recall: α s a parameter of the physcal problem. We must choose t and x so that Equaton (8) s satsfed. ME 448/548: FTCS Soluton to the Heat Equaton page 14

Workng wth the FTCS Stablty Crteron To ncrease accuracy, we want to decrease both x and t. For a gven x, the stablty lmt for FTCS mposes an upper lmt on t t < x2 2α (9) Choosng t and x so that r < 1 2 does not guarantee an accurate numercal soluton. r < 1 2 only guarantees that the FTCS soluton wll not blow up. ME 448/548: FTCS Soluton to the Heat Equaton page 15

Workng wth the FTCS Stablty Crteron When reducng x and t to mprove accuracy, follow a path lke A C not A B. Note that the axes have logarthmc scales. log( t) Unstable B C A Stable ( x) t = 2 2α log( x) ME 448/548: FTCS Soluton to the Heat Equaton page 16

Measurng the FTCS Truncaton Error The error reported by demoftcs s defned as E(n x, n t ) = 1 nx u k u(x, t k ) 2 (10) The factor of 1/ n x converts u k u(x, t k ) 2 to an average error. ME 448/548: FTCS Soluton to the Heat Equaton page 17

Measurng the FTCS Truncaton Error Desgnate the local error at x = x and t = t k as e k = uk u(x, t k ). (11) Defne ē k as an RMS average error per node at tme step t k ē k [ 1 n x nx =1 (e k )2 ] 1/2 (12) Algebrac substtuton shows that E(n x, n t ) = ē k. If the soluton to the heat equaton s smooth, then E(n x, n t ) = O( t) + O( x 2 ) ME 448/548: FTCS Soluton to the Heat Equaton page 18

Measurng the truncaton error Systematcally reduce x and t to determne whether truncaton error predcton s realzed by the code. We know the exact soluton, so we use Equaton(10).

Measurng the truncaton error Suppose we don t know the exponent of the truncaton error for our code. In other words, nstead of we have where p s uknown E(n x, n t ) = O( x 2 ) E(n x, n t ) = O( x p ) Snce x = L n x 1 we have ( E(n x, n t ) = O( x p L p ) ) = O (n x 1) p ME 448/548: FTCS Soluton to the Heat Equaton page 20

Measurng the truncaton error Smplfy the precedng expresson E(n x, n t ) = O( x p ) ( L p ) = O (n x 1) p ( ) 1 O gnore multplcatve constants (n x 1) p ( 1 O n p x ) leadng powers domnate Therefore, we expect ( 1 E(n x, n t ) = O n p x ) ME 448/548: FTCS Soluton to the Heat Equaton page 21

Measurng the truncaton error Measure E(n x, n t ) on two dfference meshes, n x,1 and n x,2. Wth we form the rato Solve for p ( 1 E(n x, n t ) = O E(n x,2, n t ) E(n x,1, n t ) = n p x,1 n p x,2 = n p x ) ( ) p nx,1 n x,2 p = log (E(n x,2, n t )/E(n x,1, n t )). log (n x,1 /n x,2 ) ME 448/548: FTCS Soluton to the Heat Equaton page 22

convftcs Code functon convftcs % convftcs Convergence of FTCS on a seres of fner spatal meshes % --- Set constants to be consstent wth demoftcs alfa = 0.1; L = 1; tmax=2; rsafe = 0.49999; % stable r<0.5 % --- Specfy nx and compute nt consstent wth stablty lmt nx = [8 16 32 64 128 256]; dx = L./(nx-1); nt = cel( 1 + alfa*tmax*((nx-1).^2)/(rsafe*l^2) ); % --- Loop over mesh szes, store error and compute order of scheme fprntf( \n nx nt error E(j)/E(j-1) p\n ); er = NaN; p = 0; for j=1:length(nx); e(j) = demoftcs(nx(j),nt(j)); f j>1 er = e(j)/e(j-1); p = log(er)/log(nx(j-1)/nx(j)); end fprntf( %5d %5d %11.3e %8.4f %8.4f\n,nx(j),nt(j),e(j),er,p); end % -- plottng code skpped... ME 448/548: FTCS Soluton to the Heat Equaton page 23

Runnng the convftcs Code >> convftcs 10 2 FTCS deal nx nt error E(j)/E(j-1) p 8 21 6.028e-03 NaN 0.0000 16 92 1.356e-03 0.2249 2.1524 32 386 3.262e-04 0.2406 2.0553 64 1589 7.972e-05 0.2444 2.0329 128 6453 1.970e-05 0.2471 2.0170 256 26012 4.895e-06 0.2485 2.0085 The last column of text output shows that demoftcs has the rght truncaton error behavor. E(n x,n y ) 10 3 10 4 10 5 10 6 10 3 10 2 10 1 10 0 x ME 448/548: FTCS Soluton to the Heat Equaton page 24

Summary for the FTCS Scheme FTCS s easy to mplement. The update formula s u k+1 = ru k +1 + (1 2r)uk + ruk 1 The FTCS scheme s condtonally stable when r = α t x 2 < 1/2 In two spatal dmensons wth y = x, the stablty condton s r < 1/4. In 3D wth y = z = x, the stablty condton s r < 1/8. There are much better schemes for solvng the heat equaton. FTCS s a toy used to ntroduce the numercal soluton of PDEs ME 448/548: FTCS Soluton to the Heat Equaton page 25