You are on page 1of 22

Numerical Methods in Chemical Engineering

(CB424)

Chemical and Biochemical Engineering


Indian Institute of Technology Patna

Atanu K Metya
atanu.metya@iitp.ac.in
Ordinary Differential Equations
Euler’s method
• !!"# = !! + $ℎ
• $ = & '! , !!
Example:
Use Euler’s method to numerically integrate
y' = 4e0.8t - 0.5y = f(y,t) from t = 0 to 4 with a step size of 1.
The initial condition at t = 0 is y = 2. The exact solution can be determined
by
Error Analysis for Euler’s Method

• The numerical solution of ODEs involves two types of error


• Truncation or discretization errors
• Round-off errors

• The truncation errors are composed of two parts.


• Local truncation error
• Propagated truncation error
• The sum of the two is the total, or global truncation, error.
Error Analysis for Euler’s Method

For sufficiently small h, the errors in the terms usually decrease as the order increases
and the result is often represented as
Improvements of Euler’s Method

The Heun method is a predictor-corrector approach.

Predictor equation
Corrector equation
Use Heun’s method to integrate y' = 4e0.8t – 0.5y from t = 0 to 4
with a step size of 1. The initial condition at t = 0 is y = 2. The
stopping criterion is 0.00001%
Midpoint Method

• The local and global errors of the midpoint method are O(h3) and O(h2),
respectively.
RUNGE-KUTTA METHODS

• Runge-Kutta (RK) methods achieve the accuracy of a Taylor series


approach without requiring the calculation of higher derivatives.

• Various type of Runge-Kutta Methods


• First-order
• Second-order
• Third-order
Second-Order Runge-Kutta Methods

• Heun Method with a Single Corrector (a2 = 1/2)

• The Midpoint Method (a2 = 1)


Second-Order Runge-Kutta Methods
Third-Order Runge-Kutta Methods
Fourth-Order Runge-Kutta Methods
Higher-Order Runge-Kutta Methods
• Fifth-order RK method
Use the classical fourth-order RK to integrate the following function
from t = 0 to 1 with a step size of 1 and initial condition is y(0) = 2.
Systems of Equations

The solution of such a system requires that n initial conditions be known


at the starting value of t.
Solve the following set of differential equations using RK method,
assuming that at x = 0, y1 = 4, and y2 = 6. Integrate to x = 2 with a step
size of 0.5.
Example: Solve for the velocity and position of the free falling bungee
jumper using Euler method. The initial condition for t = 0, x = v = 0. The
step size is 2s and integrate up to t = 10s. g = 9.81 m/s2, m = 68.1 kg, cd =
0.25 kg/m. The exact solution for v and x are given below:

Compute the true relative errors of the results


• Use the fourth-order RK method to solve for the same problem with
step size, h = 2.

You might also like