10.34, Numerical Methods Applied to Chemical Engineering Professor William H. Green Lecture #14: Implicit Ordinary Differential Equation (ODE) Solvers. Shooting. Implicit ODE Solvers dy /dt = -y y(t=0) = 1 with explicit Euler ytrue = e-t G = F(Y(t)) for this case, instability if Δt > 1 G = F(Y with implicit Euler (t+Δt)) old Yt +new + Δt*F(Y new ) Δt = Yt ynew = 1+2(-ynew) 3ynew = 1 Î ynew = 1/3 1 1/3 For Δt = 2, e-2=ytrue ynew = 1/3 + 2(-ynew) x 3ynew = 1/3 Î ynew = 1/9 x 1/4 true 2 e-4=ytrue 4 Figure 1. Comparison of implicit Euler to true value. Accuracy low, but Implicit Euler does not become numerically unstable. Explicit Euler decays too fast. Implicit Euler decays too slow, but it allows one to use larger timesteps. Stiff Solvers Stiff: tf – t0 >> Δtmax because of instability because of accuracy Explicit |λ|maxΔt ≤ 1 for stability Stiff solvers: ode15s Å usually better ode23s Å super stiff Non-stiff ode45 Å explicit method Example: CO + ½O2 Æ CO2 In the presence of H2, H2O OH + CO Æ H + CO2 H + O2 Æ OH + O 1/λOH ~ 10-9 s -9 Δtexplicit ≤ 10 1/λCO ~ 1 s s Cite as: William Green, Jr., course materials for 10.34 Numerical Methods Applied to Chemical Engineering, Fall 2006. MIT OpenCourseWare (http://ocw.mit.edu), Massachusetts Institute of Technology. Downloaded on [DD Month YYYY]. 9 orders of magnitude difference in time scales In diffusion problems λfast/λslow ~ Nmesh2 ~ 1/(Δx)2 so a fine mesh makes the problem very stiff. Shooting Figure 2. |-------------------| x y = height of cannonball ⎛ Y0known ⎞ Y(t=0)= ⎜ guess ⎟ ⎟ ⎜Y ⎠ ⎝ 0 Yi(tf) = Yspecial Y(tf) Å ode15s(…,Yos,…) Root-finding (Newton, Broyden) g(Yguess) = 0 g = Yi(tf) – Yspecial Yi(tf) Å ode15s(…, Yguess,…) Ybestguess = bisect(@g, [Ylowguess,Yhighguess],tol) |g(Ybestguess)|<ftol |Ybestguess – Ytrueguess| < xtol function error = g(Yguess) Y0 = […, Yguess] Yf = ode15s(@F,Yo,tf,tol,options) error = Yf(nspecial) - Yspecial inside ode’s events Î stop integrating when something happens 10.34, Numerical Methods Applied to Chemical Engineering Prof. William Green Lecture 14 Page 2 of 2 Cite as: William Green, Jr., course materials for 10.34 Numerical Methods Applied to Chemical Engineering, Fall 2006. MIT OpenCourseWare (http://ocw.mit.edu), Massachusetts Institute of Technology. Downloaded on [DD Month YYYY].