21
CBE 250: Computer Applications in Chemical Engineering Lecture 4 Sept 9, 2015 *first finish bracketing example

CBE250 Lecture 4 F15

Embed Size (px)

DESCRIPTION

Computer Applications in Chem E

Citation preview

Page 1: CBE250 Lecture 4 F15

CBE 250: Computer Applications in Chemical Engineering

Lecture 4Sept 9, 2015

*first finish bracketing example

Page 2: CBE250 Lecture 4 F15

f(x)=5x3-5x2+6x-2

Page 3: CBE250 Lecture 4 F15

Open MethodsChapter 6

• Open methods require only a single starting value of x or two starting values that do not necessarily bracket the root.

Page 4: CBE250 Lecture 4 F15

Newton-Raphson Method

• Most widely used open method.• Based on first order Taylor series expansion:

)(

)(

)(0

g,Rearrangin

0)f(x when xof value theisroot The!2

)()()()(

1

1

1i1i

32

1

i

iii

iiii

iiii

xf

xfxx

xx)(xf)f(x

xOx

xfxxfxfxf

Page 5: CBE250 Lecture 4 F15

• A convenient method for functions whose derivatives can be evaluated analytically.

Page 6: CBE250 Lecture 4 F15

Newton-Raphson Visual Example

http://en.wikipedia.org/wiki/File:NewtonIteration_Ani.gif

Page 7: CBE250 Lecture 4 F15

Newton Raphson MethodGoal: to find value of x where f(x) = 0– Start with initial guess for x (xn) – Function approximated with tangent line

(derivative)

– Compute x-intercept of this tangent line: =0– Use this value as new approximation– Iterate as necessary

Page 8: CBE250 Lecture 4 F15

Newton-Raphson Example

Page 9: CBE250 Lecture 4 F15

Class Examples

1. Solve the following nonlinear equation f(x)=e-x-x=0 using Newton method in Excel.

2. Use Polymath to find real root of:f(x)=-1+5.5x-4x2+0.5x3

a) Initial guess 4.52b) Initial guess 4.54

Page 10: CBE250 Lecture 4 F15

Graphical examples of functions for which the Newton-Raphson technique (as formulated) doesn’t work.

Page 11: CBE250 Lecture 4 F15

Numerical Differentiation• Definition of derivative

• Secant line approximation to derivative– A secant line is a line that (locally)

intersects two points on a curve

– Called a Newton difference quotient

Page 12: CBE250 Lecture 4 F15

The Secant Method (6.3)• A variation of Newton’s method for

derivatives that are difficult to evaluate. For these cases the derivative can be approximated by a backward finite divided difference.

,3,2,1)()(

)(

)()()(

1

11

1

1

ixfxf

xxxfxx

xx

xfxfxf

ii

iiiii

ii

iii

Page 13: CBE250 Lecture 4 F15

• Requires two initial x values that DO NOT need to bracket the root.

• The secant method has the same properties as Newton’s method. Convergence is not guaranteed for all xo, f(x).

Page 14: CBE250 Lecture 4 F15

Secant Method

Page 15: CBE250 Lecture 4 F15

Secant example

𝑓 (𝑥 )=𝑒−𝑥 −𝑥

Page 16: CBE250 Lecture 4 F15

Systems of NonLinear Equations

0),,,,(

0),,,,(

0),,,,(

321

3212

3211

nn

n

n

xxxxf

xxxxf

xxxxf

More than one function with more than one variable….

Page 17: CBE250 Lecture 4 F15

• Taylor series expansion of a function of more than one variable

• The root of the equation occurs at the value of x1 and x2 where ui+1 and vi+1 equal to zero.

)()( ,21,2

2

,11,1

1

1 iii

iii

ii xxx

uxx

x

uuu

)()( ,21,2

2

,11,1

1

1 iii

iii

ii xxx

vxx

x

vvv

Page 18: CBE250 Lecture 4 F15

y

vy

x

vxvy

y

vx

x

v

y

uy

x

uxuy

y

ux

x

u

ii

iiii

ii

i

ii

iiii

ii

i

11

11

• A set of two nonlinear equations with two unknowns that can be solved for.

Page 19: CBE250 Lecture 4 F15

x

v

y

u

y

v

x

ux

uv

x

vu

yy

x

v

y

u

y

v

x

uy

uv

y

vu

xx

iiii

ii

ii

ii

iiii

ii

ii

ii

1

1

Determinant of the Jacobian of the system.

Page 20: CBE250 Lecture 4 F15

CLASS PROBLEM

Solve two simultaneous nonlinear equations:

10xxx21

2

1

57xx3x 2

212

Using Newton-Raphson technique programmed in Excel and Polymath.

Page 21: CBE250 Lecture 4 F15

The Wilson equations are used to correlate the activity coefficients of strongly non-ideal, but miscible systems. These equations reads:

21

121212211

)()ln(ln

GGx

21

121212122

)()ln(ln

GGx

where: θ1=x1+x2G12 and θ2=x2+x1G21, x are expressed as mole fractions

At the azeotrope point both vapor and liquid compositions are identical and γi = P/Pio

Determine constants G12 and G21 knowing that azeotrope point is at P=760 mm Hg located at T=58.7oC and x1=33.21 mole% (1-is ethanol; 2 – is n-hexane). logP1

o=8.04494 - 1554.3/(222.65 + T) logP2

o = 6.87776 – 1171.530/(224.366 + T)where T is in oC and Pi

o in mm Hg. The molecular weights of ethanol and n-hexane are 46.07 and 86.18. respectively.

This is an example of a chemical engineering problem when you solve a set of nonlinear equations by finding

their roots!! Set up in Polymath…