E91: Dnamcs Numercal Integraton & State Space Representaton
The Algorthm In steps of Δ f ( new ) f ( old ) df ( d old ) Δ
Numercal Integraton of ODEs d d f() h Δ Intal value problem: Gven the ntal state at 0 ( 0 ), to compute the whole trajector () ' 1 -, (0) 0 Eplct Euler Soluton
Euler s Method Eplct: evaluate dervatve usng values at the begnnng of the tme step h f ( ) O( ) 1 h Not ver accurate (global accurac O(h)) & requres small tme steps for stablt Implct: Evaluate dervatve usng values at the end of the tme step h f ( ) O( ) 1 h 1 Ma requre teraton snce the answer depends upon what s calculated at the end. Stll not ver accurate (global accurac O(h)). Uncondtonall stable for all tme step szes.
Truncaton errors Local truncaton error Global truncaton error 1 1 o 1 o 1
Stablt A numercal method s stable f errors occurrng at one stage of the process do not tend to be magnfed at later stages. A numercal method s unstable f errors occurrng at one stage of the process tend to be magnfed at later stages. In general, the stablt of a numercal scheme depends on the step sze. Usuall, large step szes lead to unstable solutons. Implct methods are n general more stable than eplct methods.
Second-order Runge-Kutta (mdpont method) Second-order accurac s obtaned b usng the ntal dervatve at each step to fnd a mdpont halfwa across the nterval, then usng the mdpont dervatve across the full wdth of the nterval. In the above fgure, flled dots represent fnal functon values, open dots represent functon values that are dscarded once ther dervatves have been calculated and used. A method s called nth order f ts error term s O(h n1 )
Classc 4th-order R-K method ). ( of s error Global ). ( of s error Local sze. step the s where ), ( ), ( ), ( ), ( ) ( 6 3 4 1 3 4 3 1 1 4 3 1 1 h O h O h hk h f k k h h f k k h h f k f k k k k k h
State Space
Modelng State
Modelng State cont d
State Space and Tme
ODE n one varable E91: Dnamcs Integraton n State Space
Mass-Sprng-Damper Sstem ) ( t f k c m & && f(t) k c & Free-bod dagram m f(t) m t f m C m K ) ( 1 1 1 & & & m t f m C m K ) ( 0 1 0 &
Dnamc Smulaton Eample Gven 0 ( 0, 0), solve for (t) for t[0, T]. Intal condtons ODE solver (ode45) dfferental equatons (dff_msd.m) output (demo_msd.m)
Smulaton Results 0.5 m 1.0 kg C 1.0 N*sec/m K 100.0 N/m Dsplacement 0-0.5 0 1 3 4 5 6 7 8 9 10 4 Veloct 0 - -4-6 0 1 3 4 5 6 7 8 9 10 Tme (s)
Stff ODEs Eample
Stff ODEs Stff sstems are characterzed b some sstem components whch combne ver fast and ver slow behavor. Requres effcent step sze control that adapt the step sze dnamcall, as onl n certan phases the requre ver small step szes. Implct method s the cure! Nonlnear sstems: solvng mplct models b lnearzaton (semmplct methods) Rosenbrock generalzatons of RK method Bader-Deuflhard sem-mplct method Predctor-corrector methods
Matlab Solvers for Stff Problems ode15s Varable-order solver based on the numercal dfferentaton formulas (NDFs). Optonall t uses the backward dfferentaton formulas (BDFs). Multstep solver. If ou suspect that a problem s stff or f ode45 faled or was ver neffcent, tr ode15s frst. ode3s Based on a modfed Rosenbrock formula of order One-step solver Ma be more effcent than ode15s at crude tolerances ode3t An mplementaton of the trapezodal rule usng a "free" nterpolant Use ths solver f the problem s onl moderatel stff and ou need a soluton wthout numercal dampng
Matlab Solvers for Nonstff Problems ode45 Eplct Runge-Kutta (4,5) formula One-step solver Best functon to appl as a "frst tr" for most problems ode3 Eplct Runge-Kutta (,3) One-step solver Ma be more effcent than ode45 at crude tolerances and n the presence of mld stffness. ode113 Varable order Adams-Bashforth-Moulton PECE solver Multstep solver It ma be more effcent than ode45 at strngent tolerances and when the ODE functon s partcularl epensve to evaluate.
References Numercal Intal Value Problems n Ordnar Dfferental Equatons, Gear, C.W., Englewood Clffs, NJ: Prentce-Hall,1971. Numercal Recpes n C : The Art of Scentfc Computng Wllam H. Press, Bran P. Flanner, Saul A. Teukolsk, Wllam T. Vetterlng, Cambrdge Unverst Press, 199. (onlne at http://www.lbrar.cornell.edu/nr/bookcpdf.html) Dr. Vja Kumar Unverst of Pennslvana and Dr. Peng Song Rutgers Unverst
Smulator vs. a Smulaton Objectve Monolthc vs. Modular User Interface