Class Notes (808,146)
Canada (493,092)
CH E374 (5)


11 Pages
Unlock Document

University of Alberta
Chemical Engineering
CH E374
Joe Mmbaga

CHE 374 Computational Methods in Engineering MODULE 6: Ordinary differential equations (ODE’s): initial value problems (IVP) Basics Equations involving derivatives are called differential equations. If there is one independent variable the equations are known ordinary differential equations (ODE’s), if there is more than one independent variable and the equation(s) involve partial derivatives we speak of partial differential equations (to be discussed in Lecture Module 8)  Order of an ODE: order of the highest derivative.  General form of an n order ODE with y  :  dy d y d y  F ,y, , 2 , , n 0 (6.1)  dx dx dx  th  General form of a linear n order ODE: n n1 a x d y a  d y  a x dy a x  g x   (6.2) n dx n n1 dx n1 1 dx 0 In a homogeneous, linear ODE the term g x  0 :   n n1 an  d y a n1  d y  a 1  y a 0   0 (6.3) dxn dx n1 dx Important feature of homogeneous, linear ODE’s: Suppose 1   and y2  are solutions to a linear ODE, then also y 1 y x 2  is a solution of the same ODE with  and  constants.  Non-linear ODE’s e.g. contain products of y and its derivatives, e.g. d y dy dx2 by dx csin   0 (6.4)  An n order ODE needs n boundary conditions. If these are known at one point (e.g. x=0) we call the problem an initial value problem. An ODE with boundary nd conditions at different locations (or moments in time), e.g. a 2 order ODE with two boundary conditions (one at x=0, one at x=L) is called a boundary value problem. Boundary value problems are discussed in Lecture Module 7 1 nd In the context of numerically solving ODE’s, it is common practice to write 2 nd and higher order ODE’s as systems of first order ODE’s. The most common 2 order ODE comes from applying Newton’s second law of motion (remember the falling object problem): 2 2 ma m d x  F   OR d x  1F x  (6.5) dt2 dt2 m with time t the independent variable, x the position of mass m in space, and F a force (that in general depends on x and t). We can write the second order equation as a system of two 1 order ODE’s by introducing the velocity v: dx  v and dt (6.6) m dv  F   dt We write this in a vector form as: dy1  f1 1 y2,t dt dy (6.7) 2 f2 y1, 2 t dt or dy  f y,t (6.8) dt   with y  x, 1 y2 y1v Giving our two first order differential equations as: dy 1  y2 dx (6.9) dy2 dv 1   F(t,x) dx dx m Euler’s method Take the single, first-order ODE 2 dy  f ,t  (6.10) (0) dt with initial condition y  y att 0 . We want to numerically solve for y, i.e. we want to compute how y develops in time t. The simplest way to do this is to divide the time in (small) steps h (such that t ih with dy i=0,1,2,…) and writing the in terms of its forward derivative: dt dy y(i1y ( i)  (6.11) dti h Then the ODE can be written as: (i1) (i) y  y  f  ,t) (i)ih  (6.12) h This gives us a rule for updating y: y(i1 y(i)hf  (i),ti) (6.13) Since we know y(0, we can determine y(1)etc. This is called Forward Euler or Explicit Euler method. It is explicit because we use the current known values to estimate the value at a future time. The method can be used to solve a single first order ODE or a system of first order ODE’s, written in vector form as: y(i1 y(i)hf y (i),ti) (6.14)   . Example Consider the falling object problem discussed earlier in this course (Figure 1). The forces acting on the object are gravity (F ) and Dhe air resistance or drag force (F ). The U drag force can be approximated by FU C vDv (if we assume a non-linear velocity relationship) and the gravity force FDmg 3 Figure 1 In order to calculate the trajectory x(t) of the object, we have to solve two coupled first order differential equations: dv C D 2  g  v dt m and dx dt  v Thus solving for the object’s velocity involves solving two ordinary differential equations. Error analysis of Euler’s method Figure 2 4 Consider for this a single, first-order ODE: dy  f ,t . dt We want to know what error we make with the Euler method: (i1) (i) (i)(i) (6.15) y  y hf y ,t  It is easy to show that each time step we make an error of the order of h2 : Suppose the (i) (i) (i1) (i) solution y at t is the exact solution. The approximation y of y according to the Euler method is y (i1 y(i)hf y (i,ti) (6.16) (i1) A Taylor expansion of y up to three terms gives: (i1) (i) dy h d y2 h d y3 y  y h  2  3 (6.17) dt i 2 dt i 6 dt i dy (i) (i) Since h dt hf x,t  the error we make is: i 2 2 y(i1 y (i1 h d y O h 3 O h 2 (6.18) 2 dt 2     i This is the local truncation error, i.e. error obtained by truncating the Taylor series after the first term. Suppose we take more time steps, say n time steps from t(0)to t n, we obtain the global truncation or total error. The total error we make follows from adding up the error per time step: h2 n d y h 2 d y h d y E   2  n 2  t(nt (0 2 (6.19) 2 i1dt i 2 dt 2 dt As we see, the Euler method is first-order accurate, which is not very good (the error reduces at the same pace with which we reduce the time step). An additional problem is that the Euler method can get unstable as we take smaller time steps. This can be demonstrated with the following example: 5 dy (0)  y with  a positiv
More Less

Related notes for CH E374

Log In


Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.