EE 616 Computer Aided Analysis of Electronic Networks Lecture 12 Instructor: Dr. J. A. Starzyk, Professor School of EECS Ohio University Athens, OH, 45701 Note: materials in this lecture are from the notes of EE219A UC-berkeley 1 http://wwwcad.eecs.berkeley.edu/~nardi/EE219A/contents.html Methods for Ordinary Differential Equations By Prof. Alessandra Nardi Outline 2 Transient Analysis of dynamical circuits – i.e., circuits containing C and/or L Examples Solution of Ordinary Differential Equations (Initial Value Problems – IVP) – Forward Euler (FE), Backward Euler (BE) and Trapezoidal Rule (TR) – Multistep methods – Convergence Application Problems Signal Transmission in an Integrated Circuit Signal Wire Wire has resistance Wire and ground plane form a capacitor Logic Gate Logic Gate Ground Plane • Metal Wires carry signals from gate to gate. • How long is the signal delayed? 3 Application Problems Signal Transmission in an IC – Circuit Model resistor capacitor Constructing the Model 4 • Cut the wire into sections. • Model wire resistance with resistors. • Model wire-plane capacitance with capacitors. Application Problems Signal Transmission in an IC – 2x2 example iC1 C1 v1 iR2 v2 iR1 R2 R1 R3 iR3 Constitutive Equations iC2 C2 dvc ic C dt 1 iR vR R Conservation Laws iC1 iR1 iR2 0 iC2 iR3 iR2 0 Nodal Equations Yields 2x2 System C1 0 5 1 1 dv1 R R 0 dt 1 2 C2 dv2 1 R dt 2 1 R2 v1 1 1 v2 R3 R2 Application Problems Signal Transmission in an IC – 2x2 example Let C1 C2 1, R1 R3 10, R2 1 C1 0 1 1 dv1 R R 0 dt 1 2 C2 dv2 1 R dt 2 1 R2 v1 1 1 v 2 R3 R2 dx 1.1 1.0 x dt 1.0 1.1 A Eigenvalues and Eigenvectors 1 1 0.1 0 1 1 A 2.1 1 1 1 1 0 6 eigenvectors Eigenvalues 1 An Aside on Eigenanalysis dx(t ) Consider an ODE: Ax(t ), dt Eigen decomposition: A E1 E2 1 En 0 0 x(0) x0 0 0 0 0 E1 n E2 En 1 E 1 Change of variables: Ey(t ) x(t ) y (t ) E x(t ) dEy (t ) Substituting: AEy (t ), Ey (0) x0 dt 1 0 0 1 dy (t ) 1 0 y(t ) Multiply by E : E AEy (t ) 0 0 0 dt n An Aside on Eigenanalysis From last slide: 1 dy(t ) 0 dt 0 0 0 0 0 n Decoupled Equations! y(t) dyi (t ) Decoupling: i yi (t ) yi (t ) eit y (0) dt dx(t ) Steps for solving Ax(t ), dt 8 1) Determine E, 2) Compute y (0) E 1 x0 e1t 3) Compute y (t ) 0 0 4) x(t ) Ey (t ) x(0) x0 0 0 0 0 y (0) n t e Application Problems Signal Transmission in an IC – 2x2 example v1 (0) 1 v2 (0) 0 Notice two time scale behavior 9 • v1 and v2 come together quickly (fast eigenmode). • v1 and v2 decay to zero slowly (slow eigenmode). Circuit Equation Formulation For dynamical circuits the Sparse Tableau equations can be written compactly: dx(t ) F( , x, t ) 0 dt x(0) x0 where x is the vector of circuit va riables For sake of simplicity, we shall discuss first order ODEs in the form: dx(t ) f ( x, t ) dt 10 Ordinary Differential Equations Initial Value Problems (IVP) Solve Initial Value Problem (IVP) : dx(t ) f ( x, t ) dt x(t0 ) x0 in an interval [t0 ,T] given the initial condition x0 . Typically analytic solutions are not available solve it numerically 11 Ordinary Differential Equations Assumptions and Simplifications Not necessarily a solution exists and is unique for: dy F ( , y, t ) 0 dt It turns out that, under rather mild conditions on the continuity and differentiability of F, it can be proven that there exists a unique solution. We shall assume that 12 F( dy , y, t ) 0 dt Also, for sake of simplicity only consider linear case: dx(t ) Ax(t ) dt x(t0 ) x0 has a unique solution Finite Difference Methods Basic Concepts First - Discretize Time t t 0 t1 t t L 1 tL T t2 Second - Represent x(t) using values at ti x̂ 2 x̂ 1 x̂ 0 t1 t2 tL t3 3 x̂ 4 xˆ l Approx. sol’n x(tl ) Exact sol’n l Third - Approximate d x(tl ) using the discrete xˆ 's dt 13 d Example: x(tl ) dt xˆ l xˆ l 1 xˆ l 1 xˆ l or tl tl 1 Finite Difference Methods Forward Euler Approximation d slope x(tl ) d dt x slope tl tl 1 x(tl 1 ) x(tl ) t x(tl 1 ) x(tl ) x(tl ) A x(tl ) dt t or x(tl 1 ) x(tl ) t A x(tl ) t x(tl 1 ) x(tl ) t A x(tl ) 14 Finite Difference Methods Forward Euler Algorithm x(t1 ) xˆ1 x(0) tAx 0 x(t2 ) xˆ 2 xˆ1 tAxˆ1 x tAxˆ1 tAx(0) x(t L ) 15 xˆ L xˆ L 1 tAxˆ L 1 t1 t2 t3 t Finite Difference Methods Backward Euler Approximation d slope x(tl 1 ) dt x slope tl tl 1 x(tl 1 ) x(tl ) t x(t ) x(tl ) d x(tl 1 ) A x(tl 1 ) l 1 dt t or x(tl 1 ) x(tl ) t A x(tl 1 ) t x(tl 1 ) x(tl ) t A x(tl 1 ) 16 Finite Difference Methods Backward Euler Algorithm Solve with Gaussian Elimination x(t1 ) xˆ1 x(0) tAxˆ1 [ I tA] xˆ1 x(0) x(t2 ) xˆ 2 [ I tA] 1 xˆ1 x tAxˆ 2 tAxˆ1 t1 x(t L ) 17 xˆ L [ I tA] 1 xˆ L 1 t2 t Finite Difference Methods Trapezoidal Rule Approximation d 1 d d slope x(tl ) ( x(tl 1 ) x(tl )) d dt 2 dt dt slope x(tl 1 ) dt x 1 ( Ax(tl 1 ) Ax(tl )) 2 x(tl 1 ) x(tl ) x(tl 1 ) x(tl ) slope t t 1 x(tl 1 ) x(tl ) tA( x(tl 1 ) x(tl )) t 2 18 1 1 ( x(tl 1 ) tAx(tl )) ( x(tl ) tAx(tl 1 )) 2 2 Finite Difference Methods Trapezoidal Rule Algorithm Solve with Gaussian Elimination t x(t1 ) xˆ x(0) Ax(0) Axˆ1 2 t 1 t I A xˆ I A x (0) 2 2 1 x ( t2 ) xˆ I 2 t 2 1 t A I 2 x A xˆ1 t1 x (tL ) 19 t xˆ L I 2 1 t A I 2 A xˆ L1 t2 t Finite Difference Methods Numerical Integration View tl 1 d x(t ) A x(t ) x(tl 1 ) x(tl ) Ax( )d tl dt tl 1 t Ax ( ) d Ax(tl ) Ax(tl ) Trap tl 2 tAx(tl 1 ) BE tAx(tl ) FE 20 tl tl 1 Finite Difference Methods - 21 Sources of Error Finite Difference Methods Summary of Basic Concepts Trap Rule, Forward-Euler, Backward-Euler Are all one-step methods ˆx l is computed using only xˆ l 1 , not xˆ l 2 , xˆ l 3 , etc. Forward-Euler is simplest No equation solution explicit method. Box approximation to integral Backward-Euler is more expensive Equation solution each step implicit method Trapezoidal Rule might be more accurate Equation solution each step implicit method Trapezoidal approximation to integral 22 Multistep Methods Basic Equations Nonlinear Differential Equation: k-Step Multistep Approach: l 2 xˆ l k d x(t ) f ( x(t ), u (t )) dt l j l j ˆ ˆ x t f x , u tl j j j k k j 0 j 0 xˆ ˆ l 1 l x xˆ Multistep coefficients Solution at discrete points tl k 23 tl 3 tl 2 tl 1 tl Time discretization Multistep Methods – Common Algorithms TR, BE, FE are one-step methods k Multistep Equation: j xˆ l j j 0 t j f xˆ l j , u tl j k j 0 Forward-Euler Approximation:x tl x tl 1 t f x tl 1 , u tl 1 FE Discrete Equation:xˆ xˆ t f xˆ , u tl 1 Multistep Coefficients:k 1, 0 1, 1 1, 0 0, l l 1 l 1 1 1 l l 1 l ˆ ˆ ˆ x x t f x , u tl BE Discrete Equation: Multistep Coefficients:k 1, 0 1, 1 1, 0 1, 1 0 t f xˆ l , u tl f xˆ l 1 , u tl 1 2 1 1 Multistep Coefficients:k 1, 0 1, 1 1, 0 , 1 2 2 Trap Discrete Equation:xˆ l xˆ l 1 24 Multistep Methods Definition and Observations Multistep Equation: l j l j ˆ ˆ x t f x , u tl j j j k k j 0 j 0 1) If 0 0 the multistep method is implicit 2) A k step multistep method uses k previous x ' s and f ' s 3) A normalization is needed, 0 1 is common 4) A k -step method has 2k 1 free coefficients 25 How does one pick good coefficients? Want the highest accuracy Multistep Methods – Convergence Analysis Convergence Definition Definition: A finite-difference method for solving initial value problems on [0,T] is said to be convergent if given any A and any initial condition max xˆ x l t 0 as t 0 l T l0, t xˆ l computed with t t xˆ computed with 2 l xexact 26 Multistep Methods – Convergence Analysis Order-p Convergence Definition: A multi-step method for solving initial value problems on [0,T] is said to be order p convergent if given any A and any initial condition max xˆ x l t C t l T l0, t p for all t less than a given t0 Forward- and Backward-Euler are order 1 convergent Trapezoidal Rule is order 2 convergent 27 Multistep Methods – Convergence Analysis Two types of error The Local Truncation Error (LTE) of an integratio n method at tl 1 is the difference between th e computed value xˆ l 1 and the exact valu e of the solution x(tl 1 ), assuming no previous error has been made. The Global Truncation Error (GTE) of an integratio n method at tl 1 is the difference between th e computed value xˆ l 1 and the exact valu e of the solution x(tl 1 ), 28 assuming that only the initial condition is known exactly. Multistep Methods – Convergence Analysis Two conditions for Convergence For convergence we need to look at max error over the whole time interval [0,T] – Not enough to look at LTE, in fact: – 29 We look at GTE As I take smaller and smaller time steps t, I would like my solution to approach exact solution better and better over the whole time interval, even though I have to add up LTE from more time steps. Multistep Methods – Convergence Analysis Two conditions for Convergence 1) Local Condition: One step errors are small (consistency) Typically verified using Taylor Series 2) Global Condition: The single step errors do not grow too quickly (stability) All one-step methods are stable in this sense. 30 One-step Methods – Convergence Analysis Consistency definition Definition: A one-step method for solving initial value problems on an interval [0,T] is said to be consistent if for any A and any initial condition xˆ x t 1 t 31 0 as t 0 Multistep Methods 32 - Local Truncation Error Multistep Methods 33 - Local Truncation Error Local Truncation Error (cont’d) 34 Local Truncation Error (cont’d) 35 Examples 36 Examples 37 Examples (cont’d) 38 Examples (cont’d) 39 Determination of Local Error 40 Determination of Local Error 41 Implicit Methods 42 Implicit Methods 43 Convergence 44 Convergence (cont’d) 45 Convergence (cont’d) 46 Convergence (cont’d) 47 Convergence (cont’d) 48 Other methods 49 Summary 50