NUMERICAL SOLUTIONS OF ORDINARY DIFFERENTIAL EQUATIONS NUMERICAL SOLUTIONS OF ORDINARY DIFFERENTIAL EQUATIONS NUMERICAL SOLUTIONS OF ORDINARY DIFFERENTIAL EQUATIONS NUMERICAL SOLUTIONS OF ORDINARY DIFFERENTIAL EQUATIONS NUMERICAL SOLUTIONS OF ORDINARY DIFFERENTIAL EQUATIONS NUMERICAL SOLUTIONS OF ORDINARY DIFFERENTIAL EQUATIONS NUMERICAL SOLUTIONS OF ORDINARY DIFFERENTIAL EQUATIONS NUMERICAL SOLUTIONS OF ORDINARY DIFFERENTIAL EQUATIONS NUMERICAL SOLUTIONS OF ORDINARY DIFFERENTIAL EQUATIONS NUMERICAL SOLUTIONS OF ORDINARY DIFFERENTIAL EQUATIONS NUMERICAL SOLUTIONS OF ORDINARY DIFFERENTIAL EQUATIONS NUMERICAL SOLUTIONS OF ORDINARY DIFFERENTIAL EQUATIONS NUMERICAL SOLUTIONS OF ORDINARY DIFFERENTIAL EQUATIONS NUMERICAL SOLUTIONS OF ORDINARY DIFFERENTIAL EQUATIONS NUMERICAL SOLUTIONS OF ORDINARY DIFFERENTIAL EQUATIONS NUMERICAL SOLUTIONS OF ORDINARY DIFFERENTIAL EQUATIONS NUMERICAL SOLUTIONS OF ORDINARY DIFFERENTIAL EQUATIONS NUMERICAL SOLUTIONS OF ORDINARY DIFFERENTIAL EQUATIONS
Trang 1NUMERICAL SOLUTIONS
OF ORDINARY DIFFERENTIAL EQUATIONS
Trang 2ODEs in Chemical Engineering
• The ODEs that occur in Chemical Engineering tend to be of the following form:
• Following the previous steps, the solution is provided by:
• Numerical methods based on “rectangular” and “trapezoidal” rules cannot be used
Trang 3Integration via Taylor Series Expansion
• Alternative methods have to be employed and all are based on the Taylor Series
• Note: any function can be expanded as a Taylor Series
• The series can be used to solve
Taylor Series expansion of x(t) about t0
Trang 4Example: solution via Taylor Series
Trang 5Solution using Taylor Series
• Accuracy of this solution is dependent on the ‘order’ of the Taylor Series expansion
• Need to have the higher order differentials of x(t) to maintain accuracy
– may not be available due to the complexity of the original equation
• Method is not iterative and thus not amenable for efficient implementation on a computer
• Nevertheless, the Taylor Series approach is the basis for all numerical ODE solution procedures
x t ( ) = x t ( ) ( 0 + − t t x t 0 ) ( ) ' 0 + ( t t − 0 ) 2 x t '' ( ) +
0
1
Trang 6Euler’s Method: derivation
• Euler’s Method is based on the first-order Taylor Series
At t = t1, the value of x is:
At t = t2, the value of x is:
At t = t3, the value of x is:
Trang 7Euler’s Method: derivation
• Note that all the values of x have
been calculated using a fixed
Trang 8Euler’s Method: derivation
• The gradient at the reference point, t0, is used
to project to another value of x
• Assumes that the function is a straight line over the interval
Trang 9Euler’s Method: derivation
• The use of a fixed reference point can lead to large errors
• Because of the fixed reference point, the interval keeps on changing and this leads to computational inefficiency
• Euler’s Method attempts to overcome these deficiencies by:
– having a moving reference each time a solution value is calculated
– the solution evolves over constant intervals
Trang 10Euler’s Method: derivation
Trang 11Euler’s Method: geometric interpretation
Trang 12Euler’s Method: implementation aspects
• The formula for Euler’s Method:
is often written as:
• is always given because it is the
equation that has to be solved
• is the integration interval and has to be specified
• Initial conditions are required before the solution can proceed
Trang 13Euler’s Method: accuracy
• Euler’s Method can be applied to a wide range of ODEs
• However, except for the simplest of problems, the integration interval has to be small for accuracy
• Time to solution becomes longer when integration intervals are too small,
• There have been many attempts to improve the efficiency and accuracy of the basic Euler’s Method, resulting in a whole family of algorithms for the numerical solution of ODEs
– Improved Euler’s Method
– Modified Euler’s Method
– Runge-Kutta algorithms
Trang 14Improved Euler’s Method
• The basic Euler’s Method formula is changed to:
• Problem: requires which has yet to be calculated
Trang 15Improved Euler’s Method
• Since is unknown, cannot be evaluated
• To overcome this problem, perform a first estimate using the basic Euler’s Method
• Then use in: x t h 1 ( + = ) x t ( ) + hf x t t ( ( ), )
Trang 16Improved Euler’s Method: geometric interpretation
Trang 17Modified Euler’s Method
• Is another variation of the basic Euler’s Method with the aim of improving accuracy
• It makes use of a gradient evaluated between integration intervals to generate the solutions to the underlying ODE
• Problem: again, the formula requires which has yet to be calculated
Trang 18Modified Euler’s Method
• The unknown is first estimated using the basic Euler’s formula:
Trang 19Modified Euler’s Method: geometric interpretation
Trang 20Euler’s Methods and variations
Euler’s Method
ImprovedEuler’s Method
ModifiedEuler’s Method
Trang 21General form of ODE solution methods
• New value
= old value + integration interval × function of gradient
• This is the basis for a family of algorithms used to provide numerical solutions of ODEs
• A particular class is the Runge-Kutta algorithms
x t h + = x t + × h function f x t t
Trang 22Runge-Kutta (RK) Algorithms
• approximates the terms
• are coefficients
• The order of the solution is given by ‘n’
• Theoretically, the higher the order of the solution, the more accurate is the method
Trang 23Special cases of RK algorithms
General form of RK algorithms
Basic Euler’s Method
ImprovedEuler’s Method
ModifiedEuler’s Method
Trang 24RK4 Algorithm (4th order method)
Trang 25Solving sets of 1st order ODEs
• Chemical engineering systems are often described by more than 1 ODE, e.g dynamic material and energy balances
• At each integration interval, the equations are solved one at a time, using the same methods as for single ODEs,
Trang 26Solving higher order ODEs
• All numerical ODE solution methods are designed for applications to 1st order ODES
• Therefore, the m’th order ODE must be reduced, somehow, to an equivalent set of 1st order ODEs
• This can be achieved by defining some new variables
Trang 27Formulating a high order ODE problem
• Define m new variables:
1 x t dt
Trang 28where CA = concentration of liquid in the tank at time t
Fi , Fo = flowrate of liquid in and out the tank
Initial conditions: CA(0) = 1
Feed enters the reactor at a rate of F = 1 L/s and exits out also at the same flow rate
The density of liquid is constant The concentration in the feed is CAi = 10 mol/L
The volume of the tank is V = 10 L and the initial concentration of A is 10 mol/L
The differential equation for this problem is
Trang 29Example: solution procedure
Select a value for = 1 (<10% of time-constant)
CA(t) CA(0) CA(1) CA(2) CA(3) ….
11 12 13 14 15 16 17 18 19 20
Trang 31Example: results
1 2 3 4 5 6 7 8 9 10
Analytic
Trang 32Numerical solution of ODEs: summary
• All numerical ODE solution methods are based on the Taylor Series
• Euler’s Method is the most basic and is a 1st order method
• Improved and Modified Euler’s methods are 2nd order methods
• Higher order methods give more accurate solutions
• The size of the integration interval also influences the accuracy of the solutions (should be less than 10% of the time constant)
• Solutions of sets of 1st order ODEs are done sequentially
• Solutions of higher order ODEs are achieved by decomposing the problem into a set of 1st order ODEs
Trang 33Example: Multiple Reactions Process
rate constant, k1 and reaction #2 (BC) with rate constant k2
Trang 34• Where k1=0.2 hr-1 and k2=0.1 hr-1 and at time t=0, Ca=1mol/L and Cb=Cc=0mol/L Solve the system of equations and plot the change in concentration of each species over time.
Example: Multiple Reactions Process
Trang 35Concentration Profile
-0.2
0 0.2
0.4
0.6
0.8
1 1.2
CA CB CC