0% found this document useful (0 votes)
19 views

Lecture 6

The document discusses numerical methods for solving non-linear equations that arise in process modeling and simulation. It covers iterative methods like the bisection method, secant method, and Newton-Raphson method. It also provides an example of applying the bisection method to solve an equation to two significant digits.

Uploaded by

ngduyenpham156
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Lecture 6

The document discusses numerical methods for solving non-linear equations that arise in process modeling and simulation. It covers iterative methods like the bisection method, secant method, and Newton-Raphson method. It also provides an example of applying the bisection method to solve an equation to two significant digits.

Uploaded by

ngduyenpham156
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

Modeling, Simulation and Optimization

for Chemical Engineering


for

CH3133- CC01 and CC02


Ho Chi Minh City University of Technology
Part II
Process Simulation
TABLE OF CONTENTS
Uses of numerical methods

Types of numerical methods

Iterative Convergence

Bisection Method and application


Assumptions

Secant Method and application

Newton–Raphson Method and application

Iterative Convergence (Chemical Engineering Problems)


Process Simulation

Numerical Methods

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Use of Numerical Methods
• For understanding chemical process, modeling equations need to be
solved.

• The solution of linear is easy, however for non-linear it is difficult.

• Two ways to solve: Analytical & Numerical


• Typical Chemical process is composed of ODE & algebraic equations
• ODEs are balance equations and parameter relationship equations
are algebraic

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Types of Numerical Methods

Iterative
Convergence

Numerical
Numerical Integration for
Methods ODEs

Numerical
Solution for PDEs

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Numerical Methods

Bisection method

Iterative
Secant Method
Convergence

Newton–Raphson
Method

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Bisection Method
• For a given function f(x),the Bisection Method
algorithm works as follows:

• two values a and b are chosen for which f(a) > 0


and f(b) < 0 (or the other way around)

• interval halving: a midpoint c is calculated as the


arithmetic mean between a and b, c = (a + b) / 2

• the function f is evaluated for the value of c

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Bisection Method
• if f(c) = 0 means that we found the root of the function, which is c

• if f(c) ≠ 0 we check the sign of f(c):


• if f(c) has the same sign as f(a) we replace a with c and we keep
the same value for b
• if f(c) has the same sign as f(b), we replace b with c and we keep
the same value for a

• we go back to step 2. and recalculate c with the new value of a or b


The algorithm ends when the values of f(c) is less than a defined
tolerance (e.g. 0.001). In this case we say that c is close enough to
be the root of the function for which f(c) ~= 0.

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Secant Method
• Instead of using the average of the interval
endpoints to select the next root estimate, it is
required to construct a secant line and find its x-
intercept as the next root estimate

• For xk+1

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Secant Method
• Put yk+1 = 0

• Simplifying

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Newton–Raphson Method
• Using Taylor Series

• Limit to first order and neglect the second order and above

• Next Iteration point is calculated

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Application of Bi-Section Method

• Use the Bisection method to find a root of

f(x) = 1 – 2ex

to two significant digits

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Application of Bi-Section Method

Bi-Section Method
•For a given function f(x),the Bisection Method
algorithm works as follows:

•two values a and b are chosen for which f(a) > 0


and f(b) < 0 (or the other way around)

•interval halving: a midpoint c is calculated as the


arithmetic mean between a and b, c = (a + b) / 2

•the function f is evaluated for the value of c


Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Application of Bi-Section Method
• if f(c) = 0 means that we found the root of the function, which is c

• if f(c) ≠ 0 we check the sign of f(c):



if f(c) has the same sign as f(a) we replace a with c and we keep
the same value for b
• if f(c) has the same sign as f(b), we replace b with c and we keep
the same value for a
• we go back to step 2. and recalculate c with the new value of a or b


The algorithm ends when the values of f(c) is less than a defined
tolerance (e.g. 0.001). In this case we say that c is close enough to
be the root of the function for which f(c) ~= 0.

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Application of Bi-Section Method
Solution
• Take two guesses, as these are not provided, suppose a = -1 and b = 2

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Application of Bi-Section Method
Solution
• Take two guesses, as these are not provided, suppose a = -1 and b = 2
Bi-Section Method
Iteration a b f(a) f(b) c f(c)
1 -1.00 2.00 0.2642 -13.7781 0.50 -2.2974
2 -1.00 0.50 0.2642 -2.2974 -0.25 -0.5576
3 -1.00 -0.25 0.2642 -0.5576 -0.63 -0.0705
4 -1.00 -0.63 0.2642 -0.0705 -0.81 0.1125
5 -0.81 -0.63 0.1125 -0.0705 -0.72 0.0253
6 -0.72 -0.63 0.0253 -0.0705 -0.67 -0.0215
7 -0.72 -0.67 0.0253 -0.0215 -0.70 0.0022
8 -0.70 -0.67 0.0022 -0.0215 -0.68 -0.0096
9 -0.70 -0.68 0.0022 -0.0096 -0.69 -0.0037
10 -0.70 -0.69 0.0022 -0.0037 -0.69 -0.0008

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Application of Bi-Section & Secant Methods

• Consider the following nonlinear algebraic equation to find the root

f(x) = x3 – 5x2 + 6x – 1

employing the

i. Bisection method; range -0.25 to 0.50 (Home Work)

ii. Secant method

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Application of Bi-Section & Secant Methods
• Instead of using the average of the interval Secant Method
endpoints to select the next root estimate, it is
required to construct a secant line and find its x-
intercept as the next root estimate

• For xk+1

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Application of Bi-Section & Secant Methods
• Put yk+1 = 0

• Simplifying

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Application of Bi-Section & Secant Methods
Solution (Secant Method)
• Take two guesses, as these are not provided, suppose xk-1 = -0.25 and xk = 0.50

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Application of Bi-Section & Secant Methods
Solution (Secant Method)
• Take two guesses, as these are not provided, suppose xk-1 = -0.25 and xk = 0.50

Secant Method
Iteration (k) xk-1 xK xk+1 f(xk+1) Error
f(xk-1) f(xk)
1 -0.25 0.5 -2.82813 0.8750 0.3228 0.4494 0.5490
2 0.5 0.3228 0.875 0.4494 0.1357 -0.2755 1.3792
3 0.3228 0.1357 0.4494 -0.2755 0.2068 0.0358 0.3439
4 0.1357 0.2068 -0.2755 0.0358 0.1986 0.0023 0.0411
5 0.2068 0.1986 0.0358 0.0023 0.1981 0.0000 0.0028
6 0.1986 0.1981 0.0023 0.0000 0.1981 0.0000 0.0000

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Application of Bi-Section, Secant & Newton Raphson

• Find the root of the followingMethods


equations:

(a) f(x) = x3 – 5x + 1

(b) f(x) = x2ex – 1

using the

(i) Bisection method.....................(ii) Secant method

(iii) Newton–Raphson method

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Application of Bi-Section, Secant & Newton Raphson
Methods
Class Discussion
• Newton Raphson Method for f(x) = x3 – 5x + 1

Home Work
• Apply Bi-Section & Secant Methods for f(x) = x3 – 5x + 1; ranges 1.5 to 4.5

• Apply Bi-Section, Secant & Newton Raphson Methods for f(x) = x2ex – 1; ranges -
5 to 5

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Application of Bi-Section, Secant & Newton Raphson
• Using Taylor Series Methods
Newton–Raphson Method

• Limit to first order and neglect the second order and above

• Next Iteration point is calculated

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Application of Bi-Section, Secant & Newton Raphson
Methods Method
Solution for (a) using Newton–Raphson
• Take two guesses, as these are not provided, suppose xk = 4.5

f(x) = x3 - 5x + 1 & f'(x) = 3x2 - 5

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Application of Bi-Section, Secant & Newton Raphson
Methods Method
Solution for (a) using Newton–Raphson
• Take two guesses, as these are not provided, suppose xk = 4.5

f(x) = x3 - 5x + 1 & f'(x) = 3x2 - 5

Newton Raphson Method


Iteration (k) xK f(xk) f'(xk) xk+1
0 4.5 69.6250 55.7500 3.2511
1 3.2511 19.1081 26.7094 2.5357
2 2.5357 4.6257 14.2895 2.2120
3 2.2120 0.7632 9.6789 2.1331
4 2.1331 0.0408 8.6510 2.1284
5 2.1284 0.0001 8.5907 2.1284

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Iterative Convergence (Chemical Engineering Problems)
Methods
Estimate the isothermal volume of a real gas composing 100% benzene with
tolerance of 0.0001 using the van der waals equation at 4,727C and 200 atm using:
• Bi-section method (initial guess is -1 to 2.5)

• Secant method (initial guess is -1 to 2)

• Newton Raphson Method (initial guess is 2)

The van der waals constants for benzene are a = 18.82 & b = 0.1193.

The van der waals equation is

PV3 - (Pb + RT)V2 + aV - ab = 0

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Iterative Convergence (Chemical Engineering Problems)
Solution
The function is given as

f(x) = 0

x in this problem is V, therefore the equation is:

f(V) = PV3 - (Pb + RT)V2 + aV – ab

f’(V) = 3PV2 - 2(Pb + RT)V + a

Temperature is T = 4727 C = 5000 K


Pressure is P = 200 atm R = 0.082 lit.atm/mol.K

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Iterative Convergence (Chemical Engineering Problems)
Solution
Bi-Section Method Secant Method
Iteration a b f(a) f(b) c f(c) Vk-1 VK f(Vk-1) f(Vk) Vk+1 f(Vk+1) Error
Iteration (k)
1 -1 2.5 -654.925 458.1798 0.7500 -147.8015 1 -1.0 2.0 -654.9252 -100.0452 2.5409 525.4006 0.2129
2 0.75 2.5 -147.801 458.1798 1.6250 -259.1212
2 2.0 2.5409 -100.0452 525.4006 2.0865 -35.0531 0.2178
3 1.625 2.5 -259.121 458.1798 2.0625 -54.2924
3 2.5409 2.0865 525.4006 -35.0531 2.1149 -11.0717 0.0134
4 2.0625 2.5 -54.2924 458.1798 2.2813 157.2077
4 2.0865 2.1149 -35.0531 -11.0717 2.1281 0.4535 0.0062
5 2.28125 2.5 157.2077 458.1798 2.3906 295.7247
5 2.1149 2.1281 -11.0717 0.4535 2.1275 -0.0055 0.0002
6 2.28125 2.5 157.2077 458.1798 2.3906 295.7247
7 2.28125 2.5 157.2077 458.1798 2.3906 295.7247 6 2.1281 2.1275 0.4535 -0.0055 2.1276 0.0000 0.0000
8 2.28125 2.5 157.2077 458.1798 2.3906 295.7247 7 2.1275 2.1276 -0.0055 0.0000 2.1276 0.0000 0.0000

Newton Raphson Method

V f(Vk) f'(Vk) Vk+1 f(Vk+1)


Iteration (k)

0 2.0000 -100.0452 683.38 2.1464 17.0476


1 2.1464 17.0476 920.56 2.1279 0.2916
2 2.1279 0.2916 889.14 2.1276 0.0001
3 2.1276 0.0001 888.59 2.1276 0.0000

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Iterative Convergence (Chemical Engineering Problems)

There is a spherical storage tank containing oil. The tank has a diameter of 6 ft.
You are required to calculate the height, h, to which a dipstick 8 ft long would be
wet with oil when immersed in the tank when it contains 4 ft3 of oil.

Dipstick

Spherical Storage Tank

h Figure Spherical storage tank

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Iterative Convergence (Chemical Engineering Problems)

The equation that gives the height, h, of liquid in the spherical tank for the given volume and
radius is given by

h3 – 9h2 + 3.8197 = 0

Find the roots of equations to find the height, h, to which the dipstick is wet with oil such that
the tolerance error is 0.01. Make estimations using:
• Bi-section method (initial guess is -0.1 to 6)

• Secant method (initial guess is -1 to 2)

• Newton Raphson Method (initial guess is 2)

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Iterative Convergence (Chemical Engineering Problems)
Solution

The function is given as

f(x) = 0

x in this problem is h, therefore the equation is:

f(h) = h3 – 9h2 + 3.8197

f’(h) = 3h2 – 18h

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Iterative Convergence (Chemical Engineering Problems)
Solution
Bi-Section Method Secant Method
Iteration a b f(a) f(b) c f(c) Iteration (k) hk-1 hK f(hk-1) f(hk) hk+1 f(hk+1) Error

1 -0.1 3 3.7287 -50.1803 1.4500 -12.0542 1 -0.5 1.0 1.4447 -4.1803 -0.1147 3.6997 9.7149
2 -0.1 1.4500 3.7287 -12.0542 0.6750 0.0266 2 1.0 -0.1147 -4.1803 3.6997 0.4086 2.3851 1.2808
3 0.675 1.4500 0.0266 -12.0542 1.0625 -5.1410 3 -0.1147 0.4086 3.6997 2.3851 1.3582 -10.2778 0.6991
4 0.6750 1.0625 0.0266 -5.1410 0.8688 -2.3172 4 0.4086 1.3582 2.3851 -10.2778 0.5875 0.9161 1.3119
5 0.6750 0.8688 0.0266 -2.3172 0.7719 -1.0825 5 1.3582 0.5875 -10.2778 0.9161 0.6506 0.2859 0.0970
6 0.6750 0.7719 0.0266 -1.0825 0.7234 -0.5119 6 0.5875 0.6506 0.9161 0.2859 0.6792 -0.0186 0.0421
7 0.6750 0.7234 0.0266 -0.5119 0.6992 -0.2386 7 0.6506 0.6792 0.2859 -0.0186 0.6774 0.0003 0.0026
8 0.6750 0.6992 0.0266 -0.2386 0.6871 -0.1050
8 0.6792 0.6774 -0.0186 0.0003 0.6775 0.0000 0.0000
9 0.6750 0.6871 0.0266 -0.1050 0.6811 -0.0389
10 0.6750 0.6811 0.0266 -0.0389 0.6780 -0.0061
11 0.6750 0.6780 0.0266 -0.0061 0.6765 0.0103
12 0.6750 0.6765 0.0266 0.0103 0.6758 0.0185
13 0.6750 0.6765 0.0266 0.0103 0.6758 0.0185

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering
Iterative Convergence (Chemical Engineering Problems)
Solution
Newton Raphson Method
Iteration
h f(hk) f'(hk) hk+1 f(hk+1)
(k)
0 2.0000 -24.1803 -24.00 0.9925 -4.0680
1 0.9925 -4.0680 -14.91 0.7196 -0.4686
2 0.7196 -0.4686 -11.40 0.6785 -0.0116
3 0.6785 -0.0116 -10.83 0.6775 0.0000
4 0.6775 0.0000 -10.82 0.6775 0.0000

Course:
Course: Modeling, Process Modeling
Simulation and Simulation
and Optimization | Lecture:
for Chemical Process Modeling
Engineering

You might also like