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

Similar documents
NUMERICAL DIFFERENTIATION

Numerical Heat and Mass Transfer

CHAPTER 5 NUMERICAL EVALUATION OF DYNAMIC RESPONSE

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

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

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

Difference Equations

Errors for Linear Systems

2.29 Numerical Fluid Mechanics Fall 2011 Lecture 12

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

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

Lecture 12: Discrete Laplacian

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

Formal solvers of the RT equation

2 Finite difference basics

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

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

Inductance Calculation for Conductors of Arbitrary Shape

Appendix B. The Finite Difference Scheme

FTCS Solution to the Heat Equation

Global Sensitivity. Tuesday 20 th February, 2018

2.29 Numerical Fluid Mechanics

Lecture 10 Support Vector Machines II

MMA and GCMMA two methods for nonlinear optimization

The Order Relation and Trace Inequalities for. Hermitian Operators

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

3.1 Expectation of Functions of Several Random Variables. )' be a k-dimensional discrete or continuous random vector, with joint PMF p (, E X E X1 E X

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

LINEAR REGRESSION ANALYSIS. MODULE IX Lecture Multicollinearity

Chapter 13: Multiple Regression

EEE 241: Linear Systems

The equation of motion of a dynamical system is given by a set of differential equations. That is (1)

Lecture 21: Numerical methods for pricing American type derivatives

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

Numerical Solution of Ordinary Differential Equations

Structure and Drive Paul A. Jensen Copyright July 20, 2003

Note 10. Modeling and Simulation of Dynamic Systems

Linear Approximation with Regularization and Moving Least Squares

1 Derivation of Point-to-Plane Minimization

1 GSW Iterative Techniques for y = Ax

Open Systems: Chemical Potential and Partial Molar Quantities Chemical Potential

APPENDIX A Some Linear Algebra

Finite Element Modelling of truss/cable structures

Some Comments on Accelerating Convergence of Iterative Sequences Using Direct Inversion of the Iterative Subspace (DIIS)

PHYS 705: Classical Mechanics. Calculus of Variations II

More metrics on cartesian products

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

Feature Selection: Part 1

The Finite Element Method

Lecture 13 APPROXIMATION OF SECOMD ORDER DERIVATIVES

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

Kernel Methods and SVMs Extension

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

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

Foundations of Arithmetic

Inner Product. Euclidean Space. Orthonormal Basis. Orthogonal

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

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

LOW BIAS INTEGRATED PATH ESTIMATORS. James M. Calvin

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

Salmon: Lectures on partial differential equations. Consider the general linear, second-order PDE in the form. ,x 2

Formulas for the Determinant

Grover s Algorithm + Quantum Zeno Effect + Vaidman

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

Linear Regression Analysis: Terminology and Notation

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

AE/ME 339. K. M. Isaac. 8/31/2004 topic4: Implicit method, Stability, ADI method. Computational Fluid Dynamics (AE/ME 339) MAEEM Dept.

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

MA 323 Geometric Modelling Course Notes: Day 13 Bezier Curves & Bernstein Polynomials

2.3 Nilpotent endomorphisms

Stanford University CS359G: Graph Partitioning and Expanders Handout 4 Luca Trevisan January 13, 2011

Chapter Newton s Method

U.C. Berkeley CS294: Spectral Methods and Expanders Handout 8 Luca Trevisan February 17, 2016

Application of B-Spline to Numerical Solution of a System of Singularly Perturbed Problems

C4B Machine Learning Answers II. = σ(z) (1 σ(z)) 1 1 e z. e z = σ(1 σ) (1 + e z )

Inexact Newton Methods for Inverse Eigenvalue Problems

Solutions to exam in SF1811 Optimization, Jan 14, 2015

ELASTIC WAVE PROPAGATION IN A CONTINUOUS MEDIUM

Problem Set 9 Solutions

THE CHINESE REMAINDER THEOREM. We should thank the Chinese for their wonderful remainder theorem. Glenn Stevens

Implicit Integration Henyey Method

Some modelling aspects for the Matlab implementation of MMA

is the calculated value of the dependent variable at point i. The best parameters have values that minimize the squares of the errors

Exercises. 18 Algorithms

Speeding up Computation of Scalar Multiplication in Elliptic Curve Cryptosystem

Lecture 2: Numerical Methods for Differentiations and Integrations

Mathematical Preparations

Convergence of random processes

The Feynman path integral

Hidden Markov Models & The Multivariate Gaussian (10/26/04)

Research Article Green s Theorem for Sign Data

Consistency & Convergence

Lecture 5.8 Flux Vector Splitting

= = = (a) Use the MATLAB command rref to solve the system. (b) Let A be the coefficient matrix and B be the right-hand side of the system.

College of Computer & Information Science Fall 2009 Northeastern University 20 October 2009

MAE140 - Linear Circuits - Winter 16 Final, March 16, 2016

Thermal-Fluids I. Chapter 18 Transient heat conduction. Dr. Primal Fernando Ph: (850)

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

Lecture 14: Forces and Stresses

Lecture Note 3. Eshelby s Inclusion II

Transcription:

Chapter 5 Theory The numercal smulaton of PDE s requres careful consderatons of propertes of the approxmate soluton. A necessary condton for the scheme used to model a physcal problem s the consstency of the employed scheme wth the actual set of dfferental equatons. Consstency requres that the error for algebrac equatons s small such that to sgnfcant order the algebrac equatons are a far representaton of the actual PDE s. In other words the the actual set of PDE s can be recovered from the set of algebrac equatons. A second mportant property of the algebrac equatons s stablty. It has already been ndcated that a numercal scheme s not necessarly stable. Numercal stablty s absolutely necessary for the numercal method. Thrd the approxmate soluton s requred to actually converge to the exact soluton n the lmt of x 0 and t 0. However, ths convergence s not obvous. In the followng t wll be demonstrated that for some cases consstency and stablty are necessary for the convergence of the approxmate soluton to the actual soluton. The relaton between consstency, stablty, and convergence s llustrated further n Fgure (5.1). PDE s Dscretzaton Consstency System of algebrac equatons Stablty Exact Soluton Convergence x, t --> 0 Approxmate Soluton Fgure 5.1: Relaton between consstency, stablty, and convergence. Two other mportant consderatons for the numercal soluton method are accuracy and effcency. If at all possble means to acheve a partcular accuracy are hghly desrable and mportant. For 63

CHAPTER 5. THEORY 64 the choce of the actual approxmaton method effcency s also mportant. The followng secton address these basc concepts of numercal modelng and smulaton. 5.1 Convergence A soluton of a set of algebrac equatons s convergent f the approxmate soluton approaches the exact soluton of the set of PDE s for each value of the ndependent varable as the grd spacng and tme step goes to 0. lm T n = T exact (x, t n ) (5.1) x, t 0 Ths mples for the error at x and t n e n = T exact (x, t n ) T n 0 for x, t 0 (5.2) The proof for ths s n general dffcult, however, for a specal case the followng theorem apples. Lax Equvalence Theorem: Gven a properly posed lnear ntal value problem and a fnte dfference approxmaton to t that satsfes the consstency condton, stablty s the necessary and suffcent condton for convergence Notes: the theorem s applcable to any dscretzaton real flud dynamcs s usually nonlnear typcal problem are usually boundary value or mxed ntal and boundary value problems In concluson: For most problems the Lax Equvalence Theorem s only a necessary but not necessarly suffcent condton. 5.1.1 Numercal convergence In cases where an analytc soluton s known t can be used to verfy convergence for a numercal soluton. In the case of the dffuson equaton the error for dfferent grd resoluton s gven n Table 5.1 for a dffuson coeffcent α = 10 5. Table 5.1: Soluton error for sm1.f for dfferent values of s and x. s = α t/ x 2 x = 0.2 0.1 0.05 0.025 0.5 1.66 0.35 0.086 0.021 0.3 0.6 0.19 0.048 0.012

CHAPTER 5. THEORY 65 The result demonstrates that the error decreases wth x 2 ndcatng that the numercal soluton ndeed converges to the exact soluton. Fgure (5.2) provdes a graphc representaton of the error as a functon of x. Note that the convergence of sm1.f for s = 1/6 s a specal case and of order x 4. 10 0 FTCS Error 10-1 10-2 10-3 10-4 s=1/2 s=1/4 s=1/10 s=1/6 10-5 0.01 0.10 x Fgure 5.2: Error for the dffuson equaton approxmated by the FTCS scheme as a functon of x. In cases where where an analytc soluton s not know one can test convergence usng the dfference of two approxmate solutons,.e., e x = T ( x, t) n T ( x/2, t/2)2n 2 (5.3) for the lmt x, t 0. 5.2 Consstency Consstency requres that the orgnal equatons can be recovered from the algebrac equatons. Obvously ths s a mnmum requrement for any dscretzaton. n the followng we wll llustrate how ths can be done n terms of a Taylor expanson of the dscretzed equatons. FTCS scheme The FTCS scheme used for sm1.f uses the approxmaton T n+1 = T n + s ( T 1 n + T +1 n 2T ) n A Taylor expanson of the ndvdual terms n ths equaton yelds

CHAPTER 5. THEORY 66 whch yelds [ ] n [ [ T T n+1 = T n + t + t2 2 T + t3 3 T + O ( t 4) t 2 t 2 6 t 3 [ ] n [ ] T T+1 n = T n + x + x2 2 n [ ] T + x3 3 n [ T + x4 4 T x 2 x 2 6 x 3 24 x 4 [ ] + x5 5 n [ ] T + x6 6 n T + O ( x 7) 120 x 5 720 x 6 [ ] n [ ] T T 1 n = T n x + x2 2 n [ ] T x3 3 n [ T + x4 4 T x 2 x 2 6 x 3 24 x 4 [ ] x5 5 n [ ] T + x6 6 n T + O ( x 7) 120 x 5 720 x 6 T t + t 2 T tt + t2 6 T ttt = (T s x2 xx + x2 t 12 T xxxx + O ( x 4) ) wth s = α t/ x 2 and T tt = α 2 T xxxx and some rearrangng one obtans T t + αt xx + α x2 2 Thus the error for ths scheme s ] n ] n ( s 1 ) T xxxx + O ( x 4, t 2) = 0 (5.4) 6 ] n ] n E n = α x2 2 ( s 1 ) [ ] 4 n T + O ( x 4, t 2) (5.5) 6 x 4 Ths result also explans the pror note on 4th order accuracy of the FTCS scheme for s = 1/6. In ths case the second order error terms are zero such that the lowest order error becomes 4th order. It s also worth notng that a refnement of x mples an actually smaller tme step because the ntegraton parameter s s such that the temporal ntegraton step for some fxed value of s s t = s x 2 /α. In other words wth a fxed value of s a smaller grd spacng mples a smaller tme step. Fully mplct scheme. A fully mplct scheme can be expressed as st n+1 1 + (1 + 2s)T n+1 st n+1 +1 = T n (5.6) Usually a faster way to recover the orgnal equatons s acheved by castng the algebrac equatons nto a form that s more sutable to apply the Taylor expanson. Here ths s

CHAPTER 5. THEORY 67 T n+1 t T n Let us frst substtute the expanson n x. T n+1 t T n = α T 1 n+1 In the next step we apply the expanson n tme. n+1 2T + T+1 n+1 (5.7) x 2 { } α T xx n+1 + x2 12 T xxxx n+1 + x4 360 T xxxxxx n+1... = 0 T t + t 2 T tt + t2 6 T ttt +... α {T xx + tt xxt + t2 2 T xxtt +... + x2 12 [T xxxx + tt xxxxt +...] + x4 360 T xxxxxx +... } = 0 Substtutng t = s x 2 /α and T tt = α 2 T xxxx yelds T t + s x2 2 αt xxxx + s 2 x4 6 αt xxxxxx +... α {T xx + s x 2 T xxxx + s 2 x4 2 T xxxxxx +... + x2 12 [ Txxxx + s x 2 T xxxxxx +... ] + x4 360 T xxxxxx } = 0 Re-orderng terms wth all terms retaned up the 4th order n x gves T t αt xx α x2 2 whch shows an error of ( s + 1 ) ( T xxxx α x4 s 2 + s 6 3 4 + 1 ) T xxxxxx = 0 (5.8) 120 E n = α x2 2 ( s + 1 ) ( n α x4 T xxxx s 2 + s 6 3 4 + 1 ) T xxxxxx n 120 + O ( x 6). (5.9) Smlar to the FTCS scheme one recovers a second order accuracy. However n order to acheve a fourth order scheme one would requre s = 1/6 correspondng to a negatve tme step n the ntegraton such that t s not possble to construct a fourth order scheme n ths case.

CHAPTER 5. THEORY 68 100.0 Temperature 67.9 35.9 3.8 Tme = 6050. Nx = 21 Dt = 137.5 s = 0.550 RMS E =39.95550-28.3 0.00 0.25 0.50 0.75 1.00 x Fgure 5.3: Grd oscllatons ncreasng wth tme are typcal for numercal nstabltes. 5.3 Stablty For any numercal model small perturbatons (such as truncaton errors) should decay n tme. However, for nstance the FTCS scheme for the dffuson equaton (sm1.f) wll generate ncreasng errors for s = 0.55 as llustrated n Fgure 5.3. The cause for the nstablty s an amplfcaton of errors whch occur and accumulate durng a smulaton. Round-off errors occur at any stage n a computaton such that the computatonal soluton s not actually T n but T n,.e., a value whch contans some newly generated round-off errors and the entre accumulaton of pror errors. The error between the computed soluton and the expected soluton to the algebrac equaton can be expressed as ξ n = T n T n (5.10) Smlar to T n, the soluton T n whch ncludes the errors also satsfes the algebrac equatons. For nstance for the FTCS scheme appled to the dffuson equaton T n+1 = (1 2s) T n ( + s T n 1 + T ) +1 n If the algebrac equatons are homogeneous and lnear the error also satsfes the same equaton whch can be demonstrated by subtractng the equaton for T n from the one for T n. ξ n+1 = ξ n + s ( ξ 1 n + ξn +1 ) 2ξn (5.11) For gven ntal condtons all ntal errors ξ 0 are zero for all grd ponts. Smlarly Drchlet boundary condtons mply that the error at the boundary ponts ξ1 n and ξn n x are zero for all tmes t n. The two most common methods to analyze stablty are the matrx method and the von Neumann method.

CHAPTER 5. THEORY 69 5.3.1 Matrx method FTCS scheme Consder the FTCS scheme for the dffuson equaton wth Drchlet boundary condtons,.e., ξ1 n = 0 and ξn n x = 0. The equatons for the soluton are Thus the soluton equatons can be wrtten as ξ2 n+1 = (1 2s) ξ2 n + sξn 3 ξ3 n+1 = sξ1 n + (1 2s) ξn 2 + sξn 3 ξ n+1 = sξ 1 n + (1 2s) ξ n + sξ+1 n ξ n+1 N x = sξn n + (1 2s) x 1 ξn N x wth ξ n+1 = A ξ n (5.12) ξ = ξ n 2. ξ n ị. ξ n N x 1, A = (1 2s) s 0 s (1 2s) s 0 s (1 2s) s....... s (1 2s) (5.13) It can be shown that all errors are bounded f all Egenvalues are dstnct and the absolute values are smaller than 1. If the Egenvectors are gven by ξ k = T 1 η k (5.14) where η k s the unt vector n the kth drecton the equaton can be re-wrtten as η n+1 = ( T A T 1) η n (5.15) where the matrx à = T A T 1 s a dagonal matrx wth the Egenvalues on the dagonal. Thus for all Egenvectors η n+1 < η n f all Egenvalue are 1. The Egenvalues of a trdagonal (N x 2) (N x 2) matrx

CHAPTER 5. THEORY 70 are gven by b c 0 0 a b c 0 0 a b c..... a b c 0 a b λ k = b + 2 (ac) 1/2 cos kπ N x 1 (5.16) for k = 2,..., N x 2. Thus the Egenvalues of the FTCS algorthm are λ k = 1 2s + 2s cos kπ kπ = 1 4s sn2 N x 1 2 (N x 1) (5.17) Thus the condton for stablty s 1 1 4s sn 2 kπ 2 (N x 1) 1 (5.18) or s 1/2. Therefore convergence of the approxmate soluton requres s 1/2 and n ths case all perturbatons decrease n ampltude over tme. General two level scheme For the dffuson equaton ths scheme s gven by T n+1 t T n where the operator L xx s defned by αβl xx T n+1 α (1 β) L xx T n = 0 (5.19) L xx T n = 1 x 2 (T 1 2T + T +1 ) (5.20) Substtutng ths operator and usng the defnton s = α t/ x 2 leads to the error equaton sβξ 1 n+1 +(1 + 2sβ) ξn+1 sβξ+1 n+1 = s (1 β) ξn 1+[1 2s (1 β)] ξ n +s (1 β) ξ+1 n (5.21) such that the set of equatons (for Drchlet condtons) can be wrtten as

CHAPTER 5. THEORY 71 A ξ n+1 = B ξ n (5.22) wth and A = (1 + 2sβ) sβ 0 sβ (1 + 2sβ) sβ 0 sβ (1 + 2sβ)....... sβ (1 + 2sβ) (5.23) B = 1 2s (1 β) s (1 β) 0 s (1 β) 1 2s (1 β) s (1 β) 0 s (1 β) 1 2s (1 β) s....... s (1 β) 1 2s (1 β) (5.24) Clearly ths algorthm s stable f the absolute value of all egenvalues of A 1 B are smaller than unty. In ths case the magntude of the egenvalues s For the above matrces the Egenvalues are (λ B ) (λ A ) 1 (5.25) kπ kπ λ A = 1 + 2s 2sβ cos = 1 + 4sβ sn2 (5.26) N x 1 2 (N x 1) kπ kπ λ B = 1 + 2s (1 β) 2s (1 β) cos = 1 4s (1 β) sn2 N x 1 2 (N x 1) (5.27) and for the stablty requrement a) for sn 2 kπ 2(N x 1) = 0 wth λ k = 1 b) for sn 2 kπ 2(N x 1) 1 4s (1 β) sn 2 kπ 2(N λ k = x 1) 1 + 4sβ sn 2 kπ 1 (5.28) 2(N x 1) = 1 one obtans two condtons:. 1 4s (1 β) 1 + 4sβ whch s always satsfed.. 1 4s (1 β) 1 4sβ whch mples 2 4s (1 β) or s 0.5/ (1 2β) for β < 1/2.

CHAPTER 5. THEORY 72 Dervatve boundary condtons Assumng Neumann boundary condtons of the form whch can be mplemented by T t = δ, at x = 0 or T 0 = T 2 2δ x. Substtuton nto the equaton for T 2 T 2 T 0 2 x = δ (1 + 2sβ) ξ n+1 1 2sβξ n+1 2 = [1 2s (1 β)] ξ n 1 + 2s (1 β) ξn 2 2sδ x (5.29) Thus compared to the case of Drchlet condtons the frst equaton (or terms n the matrces) are altered and an nhomogenety s ntroduced nto the equatons,.e., or A ξ n+1 = B ξ n + C (5.30) ξ n+1 = A 1 B ξ n + A 1 C Solutons to the egenvectors can be found through teraton of X n+1 = D X n (5.31) wth D = A 1 B. The teraton s repeated untl X n+1 concdes wth X n. The modfcaton of the Egenvalues by Neumann boundary condtons s usually relatvely small. 5.3.2 Von Neumann method The von Neumann method s usually easy to apply, straghtforward, and dependable. However, smlar to the matrx method the von Neumann method s applcable strctly only to lnear equatons wth constant coeffcents (whch s already assumed n the defnton for ξ). Nonlnear equatons can be lnearzed to attempt to apply the method. However, n cases of larger sets of equatons also the von Neumann methods can be challengng. The basc dea s the followng: Assume that the error can be expanded n a Fourer seres N x ξj 0 = a l exp (Θ l j) (5.32) l=1

CHAPTER 5. THEORY 73 wth Θ l = lπ x. Consderng an ntal error from one partcular mode wth ampltude 1 one can express ξ n j = g n exp (Θ l j) (5.33) where g s an amplfcaton factor for ths mode. Stablty requres g 1. Equvalent and maybe more ntutve we can assume that an error s gven by a ξ n j = ξ 0 exp [ (kx j + qt n )], (5.34).e., a Fourer mode wth ampltude ξ 0, wave number k, and frequency q. ξ n+1 j = ξ 0 exp [ (kx j + qt n ) + q t] (Agan a general error s expanded by an approprate superposton of all modes as n (5.32)). The amplfcaton (or dampng) of ths mode s ξ n+1 j ξ n j = exp [q t] = g (5.35) Smlarly we can express ξ n j+1 = ξ 0 exp [ (kx j + qt n ) + k x] and ξ n j+1 ξ n j = exp [k x] (5.36) The task now becomes to derve g for all modes from the dscretzed equatons and to nsure that g 1 for all modes (all values of k). FTCS scheme The basc equaton for the FTCS scheme s ξ n+1 = (1 2s) ξ n + s ( ) ξ 1 n + ξ+1 n By substtutng the sngle Fourer mode and dvson by ξ n j we obtan exp [q t] = (1 2s) + s [exp (k x) + exp ( k x)] Substtutng the amplfcaton factor g and applyng the defnton for the cosne functon yelds

CHAPTER 5. THEORY 74 g = 1 2s + 2s cos (k x) = 1 4s sn 2 (k x/2) (5.37) where 1 cos (x) = 2 sn 2 (x/2) has been used. Thus the stablty condton reads 1 1 4s sn 2 (k x/2) 1 (5.38) Note that stablty requres that the above condton s satsfed for all possble wave numbers k. The condton on the rght s always satsfed and the left nequalty requres s 1 2 (5.39) General two-level scheme The general two level scheme can be expressed by ξ n+1 ξ n t αβl xx ξ n+1 α (1 β) L xx ξ n = 0 wth the second dervatve operator L xx ξ = (ξ 1 + ξ +1 2ξ ) / x 2. Substtuton of s = α t/ x 2 leads to the equaton Wth ξ n+1 ξ n sβ x 2 L xx ξ n+1 s (1 β) x 2 L xx ξ n = 0 (5.40) we obtan x 2 L ξ n xx ξ n = exp (k x) + exp ( k x) 2 = 2 cos (k x) 2 = 4 sn 2 (k x/2) or g 1 + 4gsβ sn 2 (k x/2) + 4s (1 β) sn 2 (k x/2) = 0 (5.41) g = 1 4s (1 β) sn2 (k x/2) 1 + 4sβ sn 2 (k x/2) (5.42) The condton for stablty s g 1 such that

CHAPTER 5. THEORY 75 a) The nequalty on the rght yelds 1 1 4s (1 β) sn2 (k x/2) 1 + 4sβ sn 2 (k x/2) 1 (5.43) 1 4s sn 2 (k x/2) 1 whch s always satsfed. b) The condton on the left yelds or 1 4sβ sn 2 (k x/2) 1 4s (1 β) sn 2 (k x/2). For β 1/2 ths s always satsfed.. For β < 1/2 4s(1 2β) sn 2 (k x/2) 2 s 1 2(1 2β) sn 2 (k x/2) Ths condton must be satsfed for all values of k or equvalently all values of sn 2 (k x/2). The rght sde mnmzes for sn 2 (k x/2) = 1 mplyng s 1 2(1 2β) (5.44) In concluson the general two level scheme s uncondtonally stable (.e., there s no stablty lmt for s) for β 1/2 and has the stablty lmt s 0.5/(1 2β) for β < 1/2. The pror examples demonstrate the stablty analyss of numercal approxmatons for a sngle equaton (dependent varable) and cases where only two tme levels are nvolved n the analyss. In cases wth more tme levels the equaton for g becomes a hgher order polynomal whch wll have several solutons for g. Each of the roots of the polynomal must satsfy g 1 for stablty. The solutons n ths case are n general complex solutons such that the amplfcaton s best measured by g 2 = g g where g s the complex conjugate of g and the condton for stablty becomes g g 1. It may be necessary to dentfy the solutons numercally for a range of parameters such as s and β. In cases of systems of equatons the amplfcaton factor becomes a vector where each component has to satsfy the stablty condton. Strctly the demonstrated approach s vald only for lnear equatons. In a general nonlnear case t may be a rather complex task to dentfy the amplfcaton factor. The frst step n such cases s the lnearzaton of the underlyng equatons. A second complcaton n a more general case s the occurrence of physcal nstabltes whch have naturally growng solutons. In that case t s allowed that the magntude of the amplfcaton factor s g 1 + O( t).

CHAPTER 5. THEORY 76 5.4 Soluton accuracy In cases where both consstency and stablty are satsfed t can usually be expected that the soluton error wll be approxmately the truncaton error. Ths s partcularly the case f the grd spacng and tme step are suffcently small, boundary condtons are wthout dscontnutes, and the soluton s analytc,.e., nvolve on fnte order dervatves. Even though the numercal soluton may converge to the accurate soluton t s usually not necessary to approxmate the exact soluton wth arbtrary accurateness. In many cases t expected to derve qualtatve or quanttatve results wth suffcent accurateness for the partcular purpose of the model. To obtan confdence n more complex nonlnear models where analytc soluton are n general not avalable a varety of confdence buldng measure can be appled. For many applcatons t s not only helpful but necessary to test smplfed related problems frst. In fact ndustral/commercal applcatons of numercal models have usually a long hstory of varous applcatons. In terms of smplfed problems there s usually a varety of smplfcatons whch yeld analytc solutons such as equlbrum confguratons, steady state systems, and lnear modes (waves). In addton consstency test should use refnng the spatal grd and/or the tme step, establsh that gradents are resolved by the grd scale, and test conservaton law such as mass, momentum, energy, and magnetc flux conservaton. The followng presents a rather specfc example on how grd refnement can be used to ncrease accuracy

CHAPTER 5. THEORY 77 Rchardson extrapolaton Consder two soluton T a and T b wth dfferent resoluton x a and x b of the dffuson equaton obtaned wth the FTCS scheme sm1.f. The goal here s to combne the solutons T c = at a + bt b (5.45) where a and b are constants such that the combned errors of the solutons partally cancel each other wth a net soluton of hgher accuracy. wth T t n α 2 T x 2 n + a E a n + b E b n = 0 (5.46) E a n = α x2 a 2 E b n = α x2 b 2 For x b = x a /2 one obtans the condton ( s 1 ) [ 4 T 6 x 4 ( s 1 ) [ 4 T 6 x 4 ] n ] n + O ( x 4) + O ( x 4) wth the soluton a + 1 4 b = 0 a + b = 1 a = 1 3, b = 4 3 (5.47) Ths lnear combnaton of two solutons reduces the Error to O ( 4 ) but requres two computatons of solutons. The tme to reach a partcular soluton s proportonal to 1/ x and 1/ t (or N x N t ). Thus we can wrte the computer tme need for a partcular result wth fxed t max c t = K x t = αk (5.48) s x 3 where K s a constant. For s = 1/2 the computer tmes needed for the two runs (wth x and 2 x) are

CHAPTER 5. THEORY 78 Table 5.2: RMS error obtaned by regular FTCS, Rchardson Extrapolaton, and s = 1/6 for the dffuson equaton. Scheme x = 0.1 x = 0.05 x = 0.025 ftcs, s = 1/2 0.4915 0.0869 0.0153 ftcs, s = 1/2, RE 0.9744 0.0104 0.00063 ftcs, s = 1/6 0.0017 0.000054 0.0000034 c t, x = 2αK, c x 3 t,2 x = 0.25αK x 3 such that the combned tme for the Rchardson extrapolaton s In comparson the tme needed for the specal case s = 1/6 s c t, x,re = 2.25αK x 3 (5.49) c t, x,s=1/6 = 6αK x 3 (5.50) In concluson the Rchardson extrapolaton s by more than a factor of 2 faster to acheve the same order of accuracy. Note, however, that the fourth order error has a term O ( (2 x) 4) n the Rchardson extrapolaton such that the accuracy s n factor a factor of about 16 less than n the correspondng specal case wth s = 1/6. 5.5 Effcency Computatonal effcency s a concept that s not entrely well defned. However n general a method has large effcency f t produces results wth small errors ɛ (or large accuracy) n a short perod of computer tme c t. So conceptual one can express computatonal effcency as CE = K ɛc t (5.51) Note, however, that ths s n a way subjectve and t s not alway clear what defnton should should be appled to the error ɛ. For nstance f ɛ were merely the truncaton error then the product of ɛc t mght converge to zero for ɛ 0 even though c t. Ths, however, s of no use because t would suggest to use nfnte computer tme because n ths lmt the effcency s largest. A better approach s to fx a requred qualty of the result and then to compare the executon tme for dfferent methods and realzatons ncludng aspects such as vectorzaton, parallelzaton, and the actual style of programmng n addton to the partcular method for the numercal approxmaton.

CHAPTER 5. THEORY 79 Operaton counts: Basc computatonal operatons have a typcal executon tme on any computer. The prncple categores of computer operatons are floatng pont operatons (fl) fxed pont operatons (fx) assgnments (=) logcal operatons, e.g., f, and, or (l) mathematcal lbrary functons, e.g., sn, exp, etc (m) To derve an estmate for the actual computaton tme t s necessary to derve tmes for each of the typcal operatons n a computer program. An overvew for the relatve executon tmes of varous typcal operatons s provded n Table 5.3. In the table the mcrocomputer s one of the earlest versons of an Intel based PC. The supermcro represents an early SUN workstaton. Table 5.3: Relatve executon tmes for basc operatons. Operaton Mcrocomputer Supermcro Manframe NEC-APC IV SUN Sparc St1 IBM-3090 add (fl) 1.0 1.0 1.0 subtr (fl) 1.0 1.0 0.8 multpl (fl) 1.1 1.0 0.8 dv (fl) 1.4 5.8 3.1 assgn (=) 0.1 1.0 0.1 f (l) 0.1 0.9 0.2 add (fx) 0.05 0.6 0.2 subtr (fx) 0.05 0.6 0.2 multpl (fx) 0.4 0.6 0.6 dv (fx) 0.5 5.4 3.2 power 2.7 20 16 sqrt 2.0 29 16 sn 10.0 29 17.6 exp 6.7 33 15 Inspectng the table one can conclude a number of ground rules for programmng fast code. If possble one should avod dvsons n partcular on RISC (reduced nstructon set) processors. Also lbrary calls to mathematcal functons are usually expansve and should be carefully chosen or avoded. An example program to evaluate executon tmes for dfferent operatons s provde on the web page. It should be noted that ths evaluaton s not always unque for present computer generatons.

CHAPTER 5. THEORY 80 Frst complers typcally optmze computer programs and ths optmzaton can be sophstcated. For nstance f the operatons wthn a loop are dentcal t s not necessary to execute the loop n tmes and some complers detect ths and cut the loop short by executng the requred commands only once. Other optmzatons exst of whch we may not be aware for any partcular part of a program. Also modern computer processors are usually 64 bt wde allowng more than a sngle operaton per processor cycle. Thus the tme for a partcular operaton can depend n part on the program context. As an example for an operaton count consder the FTCS equaton T n+1 = (1 2s)T n + s ( ) T 1 n + T+1 n whch comprses 3 multplcatons, two addtons, one subtracton, and nteger add, and an assgnment or n total: 6 fl, 1fx, and 1 =. Ths provdes us wth the means to carry out an operaton count for the mportant (most frequently used) subroutnes of a program. A last remark: It s of large mportance to determne always estmates on the executon tme for a smulaton/modelng program. For real applcatons Ths s helpful not only to determne possble neffcences due to neffcent programmng but also for plannng of larger sze programs and to gan an understandng of the potental for a program,.e., whether t can be scaled up to treat a compellng applcaton.