You are on page 1of 40

Mathematical Models of Chemical Engineering systems

When I complete this, I want to be able to do the following.


Simulate dynamic system

Use the concepts in designing control systems

Numerical Integration ODE

What is Integration?
Integration
The process of measuring the area under a curve.
y
b

f ( x )dx
a

f(x)

I ! f ( x )dx
a

Where: f(x) is the integrand a= lower limit of integration b= upper limit of integration
a b x

K.D Mokebe

KD Mokebe

Contributes

M.W Kutta ( 1867-1944) Leonhard Euler(1756-?) Sir Isaac Newton ( 1642-1727) Carl Runge ( 1856-1927)

Carl Friedrich Gauss (1777 1855)

KD Mokebe

Review
    

Trapezoidal Rule Simpson Rule Trapezoidal Rule Simpson Euler Integration


KD Mokebe

Trapezoid Rule

Area of Trapezoid = * parallel side x perpendicular height


b f ( a )  f (b ) f ( x ) dx ! ( b  a ) 2 a

KD Mokebe

In practice
Divide Integration Area into small trapezoid, then sum over the entire integration horizon

Note : This equation can easily be programmed

n 1 b a f ( x)dx ! f (a) 2 f (a ih) f (b) 2n i! 1


KD Mokebe

Simpson s 1/3rd Rule

n2 n1 ba f ( x)dx $ f ( x0 ) 4 f ( xi ) 2 f ( xi ) f ( xn ) 3n i !2 i !1 a i !even i !odd


b

Easy to program as well


KD Mokebe

Euler Algorithm!
Given: ODE
dx ! f ( x ,t ) dt x ! x0 @ t ! 0 x x
n 1

! x ! x

 f

( x

,t n )

(t (t

Leonhard Euler(1756-?)

n 1

dx  dt

KD Mokebe

baba ba f ( x) dx ! f x dx 2 2 2 1

Gauss Quadrature Rule of Integration

Carl Friedrich Gauss (1777 1855)

KD Mokebe

Classical Quadrature
Nth order

f (x)dx
1

c f (x )
i i i!1

Any integral with limits of [a,b] can be converted into integral with limits [-1,1]

baba ba f ( x ) dx ! f x dx 2 2 2 1
KD Mokebe

10

Basis of the Gaussian Quadrature Rule


Previously, the Trapezoidal Rule was developed by the method of undetermined coefficients. The result of that development is summarized below.
b

f ( x)dx } c f (a)  c
1 a

f (b)

ba ba ! f (a)  f (b) 2 2


Trapezoidal Rule
11
KD Mokebe

Basis of the Gaussian Quadrature Rule


The two-point Gauss Quadrature Rule is an extension of the Trapezoidal Rule approximation where the arguments of the function are not predetermined as a and b but as unknowns x1 and x2. In the two-point Gauss Quadrature Rule, the integral is approximated as

I ! f ( x )dx } c1 f ( x1 )  c 2 f ( x 2 )
a

12
KD Mokebe

Basis of the Gaussian Quadrature Rule


The four unknowns x1, x2, c1 and c2 are found by assuming that the formula gives exact results for integrating a general third order polynomial, f ( x ) ! a  a x  a x 2  a x 3 .
0 1 2 3

Hence
b

f ( x )dx ! 0  a1 x  a 2 x 2  a3 x 3 a dx
a

x x x ! a0 x  a1  a 2  a3 2 3 4 a
2 3 4

b2  a2 b3  a3 b4  a4 ! a0 b  a  a1 2  a 2 3  a3 4
13
KD Mokebe

Basis of the Gaussian Quadrature Rule


It follows that
b

f ( x )dx ! c1 a 0  a1 x1  a 2 x1  a3 x1  c2 a0  a1 x2  a 2 x2  a3 x2
Equating Equations the two previous two expressions yield

b2  a2 b3  a3 b4  a4 a 0 b  a  a1 2  a 2 3  a3 4 ! c1 a0  a1 x1  a 2 x1  a3 x1  c 2 a0  a1 x 2  a 2 x 2  a3 x 2 ! a0 c1  c 2  a1 c1 x1
2 2 2 2 2 1 1

 c x  a x c
3

 c 2 x 2  a3 c1 x1  c 2 x 2

K.D Mokebe

KD Mokebe

14

Basis of the Gaussian Quadrature Rule


Since the constants a0, a1, a2, a3 are arbitrary
Difficult problem! Must chose formulations carefully!

b  a ! c1  c2 b3  a3 2 2 ! c1 x1  c2 x 2 3

b2  a2 ! c1 x1  c 2 x 2 2 b4  a4 3 3 ! c1 x1  c 2 x 2 4

15
KD Mokebe

Basis of Gauss Quadrature


The previous four simultaneous nonlinear Equations have only one acceptable solution,

b  a 1 b  a x1 !   3 2 2 ba c1 ! 2

b  a 1 b  a x2 !  2 2 3
ba c2 ! 2
KD Mokebe

K.D Mokebe

16

Basis of Gauss Quadrature


Hence Two-Point Gaussian Quadrature Rule
b

f (x)dx } c f x  c f x
1 1 2 2 a

ba ba 1 ba ba ba 1 ba ! f 2  3  2  2 f 2 3  2 2

17
KD Mokebe

Higher Point Gaussian Quadrature Formulas


b

f ( x)dx } c f ( x )  c
1 1 a

f ( x2 )  c3 f ( x3 )

is called the three-point Gauss Quadrature Rule. The coefficients c1, c2, and c3, and the functional arguments x1, x2, and x3 are calculated by assuming the formula gives exact expressions for integrating a fifth order polynomial
b

dx  a1 x  a 2 x 2  a3 x 3  a 4 x 4  a5 x 5

General n-point rules would approximate the integral


b

f ( x )dx } c1 f ( x1 )  c 2 f ( x 2 )  . . . . . . .  cn f ( xn )
18
KD Mokebe

Arguments and Weighing Factors for n-point Gauss Quadrature Formulas


In handbooks, coefficients and arguments given for n-point Gauss Quadrature Rule are given for integrals
1

Table 1: Weighting factors c and function arguments x used in Gauss Quadrature Formulas. Points 2 3 Weighting Factors c1 = 1.000000000 c2 = 1.000000000 c1 = 0.555555556 c2 = 0.888888889 c3 = 0.555555556 c1 = c2 = c3 = c4 = 0.347854845 0.652145155 0.652145155 0.347854845 Function Arguments x1 = -0.577350269 x2 = 0.577350269 x1 = -0.774596669 x2 = 0.000000000 x3 = 0.774596669 x1 = -0.861136312 x2 = -0.339981044 x3 = 0.339981044 x4 = 0.861136312

g ( x )dx
1

i !1

ci g ( xi )
4

as shown in Table 1.

19
KD Mokebe

Arguments and Weighing Factors for n-point Gauss Quadrature Formulas


Table 1 (cont.) : Weighting factors c and function arguments x used in Gauss Quadrature Formulas. Points 5 Weighting Factors c1 = c2 = c3 = c4 = c5 = c1 = c2 = c3 = c4 = c5 = c6 = 0.236926885 0.478628670 0.568888889 0.478628670 0.236926885 0.171324492 0.360761573 0.467913935 0.467913935 0.360761573 0.171324492 Function Arguments x1 = -0.906179846 x2 = -0.538469310 x3 = 0.000000000 x4 = 0.538469310 x5 = 0.906179846 x1 = -0.932469514 x2 = -0.661209386 x3 = -0.2386191860 x4 = 0.2386191860 x5 = 0.661209386 x6 = 0.932469514
KD Mokebe

20

Arguments and Weighing Factors for n-point Gauss Quadrature Formulas


So if the table is given for
1

g ( x )dx
1

So if the table is given for


b

g ( x )dx
1

integrals, how does one solve


b
How do we solve

f ( x )dx
a

f ( x )dx
a

KD Mokebe

21

Arguments and Weighing Factors for n-point Gauss Quadrature Formulas


1

So if the table is given for


b

g ( x )dx
1

integrals, how does one solve

f ( x )dx ?
a

The answer lies in that any integral with limits of

?a , bA

can be converted into an integral with limits

? 1, 1A

Let

x ! mt  c
If If

x ! a , then t ! 1

x ! b,

then

t! 1

Such that:

ba m! 2
KD Mokebe

22

Arguments and Weighing Factors for n-point Gauss Quadrature Formulas


Then

ba c! 2

Hence

ba ba x! t 2 2

ba dx ! dt 2

Substituting our values of x, and dx into the integral gives us


b

f ( x )dx !

baba ba f t dt 1 2 2 2 

K.D Mokebe KD Mokebe

23

Example 1
b

For an integral Rule.

f ( x )dx ,
a

derive the one-point Gaussian Quadrature

Solution
The one-point Gaussian Quadrature Rule is
b

f ( x )dx } c1 f x1

KD Mokebe

24

Solution
The two unknowns x1, and c1 are found by assuming that the formula gives exact results for integrating a general first order polynomial,

f ( x ) ! a 0  a1 x.
b b 0

f ( x)dx ! a
a a

 a1 x dx
2 b

x ! a 0 x  a1 2 a
b2  a 2 ! a0 b  a  a1 2
25
KD Mokebe

25

Solution
It follows that
b

f ( x )dx ! c a
1 a

 a1 x1

Equating Equations, the two previous two expressions yield

b2  a 2 a0 b  a  a1 2 ! c1 a 0  a1 x1

! a0 ( c1 )  a1 ( c1 x1 )

26

KD Mokebe

26

Basis of the Gaussian Quadrature Rule


Since the constants a0, and a1 are arbitrary

b  a ! c1
b2  a 2 ! c1 x1 2
giving

c1 ! b  a
ba x1 ! 2
27
KD Mokebe

27

Solution
Hence One-Point Gaussian Quadrature Rule
ba f (x)dx } c1 f x1 ! (b  a) f 2 a
b

28

KD Mokebe

28

Example 2
a) Use two-point Gauss Quadrature Rule to approximate the distance covered by a rocket from t=8 to t=30 as given by

140000 x ! 2000 ln  9.8t dt 140000  2100t 8


30

b) c)

Find the true error,

Et

for part (a).

Also, find the absolute relative true error, a for part (a).
KD Mokebe

29

Solution
First, change the limits of integration from [8,30] to [-1,1] by previous relations as follows

30

30  8 1 30  8 30  8 x dx f ( t )dt ! f 2 1 2 2 8
1

! 11 f 11x  19 dx
1

30
KD Mokebe

Solution (cont)
Next, get weighting factors and function argument values from Table 1 for the two point rule,

c1 ! 1.000000000 x1 ! 0.577350269 c 2 ! 1.000000000 x 2 ! 0.577350269


31
KD Mokebe

Solution (cont.)
Now we can use the Gauss Quadrature formula
1

11 f 11x  19 dx } 11c1 f 11x1  19  11c 2 f 11x 2  19


1

! 11 f 11( 0.5773503 )  19  11 f 11( 0.5773503 )  19 ! 11 f ( 12.64915 )  11 f ( 25.35085 ) ! 11( 296.8317 )  11( 708.4811 ) ! 11058.44 m
32
KD Mokebe

Solution (cont)
since

140000 f ( 12.64915 ) ! 2000 ln  9.8( 12.64915 ) 140000  2100( 12.64915 )


! 296.8317 140000 f ( 25.35085 ) ! 2000 ln  9.8( 25.35085 ) 140000  2100( 25.35085 ) ! 708.4811
33
KD Mokebe

Solution (cont)
b) The true error,
t

, is

Et ! True Value  Approximate Value

! 11061.34  11058.44 ! 2.9000 m


c) The absolute relative true error,

, is (Exact value = 11061.34m)

11061.34  11058.44 t ! v 100% 11061.34


! 0.0262 %
KD Mokebe

34

System Model

Two tank system

KD Mokebe

35

System Model
Signal Select

yy

The process involves a CSTR with an exothermic reaction and a cooling coil. Generally, we wish to control the composition of the reactant in the effluent. However, we must keep the temperature below a maximum limit to prevent damaging the glass lining of the reactor.

FC
Looks good to me. What could go wrong?

T AC

LC

Reaction: A p B

Case study: Simulation


FIC Three Tank Storage Inlet flow (Process) Comp. sensor outlet flow Monitor

Ca3(t) Feedback controller

Dilution Ca3set set point

Actual System

KD Mokebe

37

Case Study: Simulation


Disturbance
CaD

Feedback controller Ca3 Set point Or Target

Tank 1
Cao Ca1(t) Ca1 Cam

Tank 2
Ca2 Ca2(t)

Tank 3
Ca3(t)

Ca3

monitor

E(t)

noise

noise

KD Mokebe

38

Additional Resources
For all resources on this topic such as digital audiovisual lectures, primers, textbook chapters, multiple-choice tests, worksheets in MATLAB, MATHEMATICA, MathCad and MAPLE, blogs, related physical problems, please visit http://numericalmethods.eng.usf.edu/topics/gauss_qua drature.html

39
KD Mokebe

THE END
http://numericalmethods.eng.usf.edu

KD Mokebe

40

You might also like