Soluons o Ordnary Derenal Equaons An ordnary derenal equaon has only one ndependen varable. A sysem o ordnary derenal equaons consss o several derenal equaons each wh he same ndependen varable. An eample o an ordnary derenal equaon ses he dervave o velocy wh respec o me equal o acceleraon. dv a d. Includng he ordnary derenal o dsance wh me as velocy maes a sysem o ordnary derenal equaons. v d dv a d. Anoher way hs sysem may be wren nvolves he epresson o acceleraon as he second derenal o dsance wh me. a d. where v.4 d Boh o he orms descrbed by Eqs.. and. requre wo consans o negraon o solve. These are well nown o be he velocy and dsance a some me usually a he nal me. Ths sysem can be made more neresng he acceleraon ne orce dvded by he mass bears a unconal relaonshp o velocy and dsance as s he case or a allng meeore. As eners he Earh s amosphere encouners drag ha s relaed o boh elevaon and velocy. In hs case dv v sv.5 d d The acceleraon uncon can even be a uncon o he ndependen varable me as s he case or a reurnng space capsule wh a me-deployed parachue. dv v sv.6 d d In general a sysem o hree ordnary equaons may be wren as d dy dz yz y yz z yz.7 d d d MATH 7 Sanley M. Howard
4 Ordnary Derenal Equaons -. Euler s Mehod Every engneerng and scence suden qucly realzes ha a slope uncon may be used o appromae he poson o he slope s dependen varable provdng a sarng value or he varable s nown. For eample or he uncon dy y.y y when d.8 an appromaon o y.5 s ound as shown n Table or a sep sze erapolaon dsance o.5. Alhough Euler s Mehod s easy he sep sze and s eec on he resul need o be eamned. Table repeas he negraon usng a sep sze o. and has a very deren resul 5.9 vs.... Table. Euler Eample wh sep sze o.5 y y' = +.*y + y = y *...4.7.5.7.4...7.744.7.5 5.9.584.759 Table. Euler Eample wh sep sze o. y y' = +.*y + y = y *.4.4..4.48.48..88.45656.45656..48456.4847685.484769.................48.4496 5.5448859.5544886.49.7748784 5.55497569.5554976.5.748 5.546548564.55465486 The order o error or Euler s Mehod s ound by recognzng ha each erapolaon o he dependen varable y s y y h* y.9 The ne erm n hs rs order Taylor Seres conans he error and s e y h. The accumulaed error s he summaon o all hese erms over he nerval rom a o b: Souh Daoa School o Mnes and Technology Sanley M. Howard
- yc Nyc Nhyc b ayc e h h h h Oh.. N N Thereore he order o he error s relaed drecly o he sep sze. In he above eample he error s appromaely 5 mes smaller or a sep sze o.han or a sep sze o.5. I a mehod were devsed ha had an error on he order o h he error would be reduced by appromaely /5. Meho wh errors on he order o h 4 are presened n he ollowng secon.. - Runge-Kua Meho Runge-Kua s a mehod o erapolang he dependen varable n a rs order derenal equaon or all he dependen equaons n a sysem o rs order ordnary derenal equaons. The general procedure s always he same bu may be employed o acheve deren levels o accuracy. O course s rue ha addonal compuaonal eor s needed o acheve hgher accuracy. The Runge-Kua mehod consss o usng an esmae or he average o several esmaes o he change n he dependen varable over a small sep n he ndependen varable. Ths esmaon procedure requres nowng he uncon ha descrbes he slope o each dependen equaon. Also requred o nd new values o he dependen a he end o a sep n he ndependen s he nal value or each o he dependen varables. In he smples orm o Runge-Kua a sngle esmae o slope s used o deermne he change n he dependen varable. More comple orms use mulple esmaes o slope o deermne changes n he dependen varable. O course he problem nvolves wo nerdependen derenal equaons hen an esmae or each o he varables mus be deermned n order o evaluae he slopes. The ollowng eample llusraes such as case. Eample a Consder he wo slope uncons. * a = =.. a = =. MATH 7 Sanley M. Howard
4 Ordnary Derenal Equaons - 4 Souh Daoa School o Mnes and Technology Sanley M. Howard Soluon Noce ha he equaons requre a smulaneous soluon snce hey are boh uncons o and. The Frs Order Runge-Kua soluon s Where each value s an esmae o he change n he dependen varable he rse and he s he sep sze he run. Snce hs orm uses only one esmae o slope or each dependen varable s called a Frs Order Runge-Kua appromaon. I s he same as he Euler Mehod and has an error n he resul on he order o h. A second order appromaon wh error on he order o h would have wo esmaes o slope. The mos common locaons or hese wo esmaes are a he begnnng and he endng o he sep. The esmae a he sar o he ncremen s he same as or he Frs Order Runge-Kua Mehod. The esmae a he end o he sep requres an esmae or he dependen varables as shown below. The Second Order Runge-Kua soluon s where Engneers and scenss commonly use he Fourh Order Runge-Kua soluon. The Fourh Order Runge-Kua soluon s 4 6 4 6 where
- 5 MATH 7 Sanley M. Howard 4 4 In he ourh order appromaon each value s used o esmae he ne slope. A oal o s esmaes o he slope are used o deermne he change n he dependen varables: one a he sar o he sep our a he mddle o he sep + and one a he end o he sep 4. Ths provdes an ecellen appromaon o slope across he sep leadng o an error n he resul on he order o h 4.. ODE Compuaonal Opons The manual compuaon usng any o he prevous meho s a daunng as especally or he very accurae 4 h Order Runge-Kua Mehod. Thereore compuaonal soware s used. Among he more commonly used are MahCad by MahSo and MATLAB by Mah Wors. The eamples used here are prmarly MahCad and MATLAB eamples. Eample Consder he hree slope uncons and her correspondng nal values. Funcons Inal values ' ' ' a by y cy z... y z where a. b.5 c.5 =.5
4 Ordnary Derenal Equaons - 6 The MahCad soluon o hs sysem by 4 h Order RK s shown below. Souh Daoa School o Mnes and Technology Sanley M. Howard
- 7 Eample Solve Eample usng MATLAB. Frs wre he slope uncon : M.le e.m uncon dw = reacw a=.; b=.5; c=.5; =.5; dw = zeros; % a column vecor dw = a*w-b*w*; dw = c*w + w*; dw = *; Then wre he code or solvng he problem usng he ode45 uncon. M.le: Eample gure'name''eample ''NumberTle''o' opons = odese'reltol'e-5'abstol'[e-5 e-6 e-6]; [z] = ode45@e[ ][. ]opons; ploz:'-'z:'-.'z:'.-' The oupu s label 'Tme s' ylabel ' y z ' legend'''y''z' 'Locaon' 'bes' e-. -9.5 'Eample ' % placng e a boom or le MATH 7 Sanley M. Howard
4 Ordnary Derenal Equaons - 8 Eample A chemcal reacon convers A o B reversbly as shown A B wh a orward sochomerc rae consan. and a reverse rae consan.. Thereore da A B db da ABB B d and d d The speces B reacs rreversbly o orm C as ollows: B C The sochomerc rae consan or he ormaon o C s.. Fnd he mamum concenraon o B and plo he concenraon o A B and C wh me gven he nal concenraons o A B and C are and. The uns or concenraon are molar and he uns o he me consan are sec -. Thereore dc d B Frs wre he uncon called reac here ha wll reurn he slope array or he hree speces. M.le: reac.m uncon dy = reacy =; =.; =.; dy = zeros; % a column vecor dy = -*y +*y; dy = * y; dy = -dy - dy; end where y = A y = B and y = C. The slopes o A B and C are dy dy and dy. Now use he ode45 MATLAB lbrary subroune o perorm he 4 h order Runge-Kua negraon. Souh Daoa School o Mnes and Technology Sanley M. Howard
- 9 M.le: SmReacons.m gure'name''smulaneous reacon''numbertle''o' opons = odese'reltol'e-4'abstol'[e-4 e-5 e-5]; [z] = ode45@reac[ ][ ]opons; ploz:'-'z:'-.'z:'.-' MaB=maz:% prn mamum [B] label 'Tme s' ylabel 'Conc molar ' legend'[a]''[b]''[c]' 'Locaon' 'bes' e-. -. 'Fg. Smulaneous reacons' % placng e a boom or le The oupu s >> SmReacons MaB =.695 MATH 7 Sanley M. Howard