10.34: numerical methods applied to chemical engineering · •in practice, it is hard to hit the...

34
10.34: Numerical Methods Applied to Chemical Engineering Lecture 9: Homotopy and bifurcation 1

Upload: others

Post on 25-Mar-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

10.34: Numerical Methods Applied to

Chemical Engineering

Lecture 9: Homotopy and bifurcation

1

Page 2: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Recap

• Quasi-Newton-Raphson methods

2

Page 3: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Recap

3

xi xi+1

|f(xi+1)| > |f(xi)|

f(xxi+1 = xi � i)

f

0(xi)

↵ = 1↵ = 1/2↵ = 1/4

backtracking line search

Page 4: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Recap

4

Page 5: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Good Initial Guesses

• Solving nonlinear equations and optimization require good initial guesses

• Where do these come from?

• Nonlinear equations can have multiple roots, optimization problems can have multiple minima.

• How can we find them all?

• The concepts of continuation, homotopy and bifurcation are useful in this regard.

5

Page 6: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Continuation• Example:

• Find the roots of:

6

f(x) = x

3 � 2x+ 1

−2 −1.5 −1 −0.5 0 0.5 1 1.5−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

Page 7: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Continuation

• Example:

• Find the roots of:

• Guess the roots based on a plot of the function

• easy in 1-D, hard in many dimensions

• Transform the problem from an easy to solve one to the problem we want to solve:

• Let

• Find roots as grows from zero to one

• When ,

• Use solution for one value of as guess for next7

f(x) = x

3 � 2x+ 1

f(x) = x

3 � 2�x+ 1

� = 0 x = �1

Page 8: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Continuation• Example:

• Find the roots of:

8

f(x) = x

3 � 2x+ 1

f(x) = x

3 � 2�x+ 1

lambda = [ 0:0.01:1 ];

xguess = -1;

for i = 1:length( lambda ) f = @( x ) x .^ 3 - 2 * lambda( i ) * x + 1; x( i ) = fzero( @( x ) f( x ), xguess ); xguess = x( i ); end;

Page 9: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Continuation• Example:

• Find the roots of:

9

f(x) = x

3 � 2x+ 1

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1−1.7

−1.6

−1.5

−1.4

−1.3

−1.2

−1.1

−1

−0.9

x

f(x) = x

3 � 2�x+ 1

Page 10: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Continuation

• Example:

• Find the roots of:

• Transform the problem from an easy to solve one to the problem we want to solve:

• Let

• When is large

• Start with large and trace back to

10

f(x) = x

3 � 2x+ 1

f(x) = x

3 � 2�x+ 1

x ⇡ 1/(2�),±p2�

� = 1�

Page 11: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Continuation• Example:

• Find the roots of:

11

f(x) = x

3 � 2x+ 1

1 2 3 4 5 6 7 8 9 10−5

−4

−3

−2

−1

0

1

2

3

4

5

f(x) = x

3 � 2�x+ 1

x

Page 12: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Continuation• Example:

• Find the roots of:

12

f(x) = x

3 � 2x+ 1

0 1 2 3 4 5 6 7 8 9 10−5

−4

−3

−2

−1

0

1

2

3

4

5

f(x) = x

3 � 2�x+ 1

x

Page 13: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Continuation

• Continuation can be used to generate a sequence of good initial guesses to different problems by varying a parameter by a small amount.

• Examples:

• fluid mechanics problems by varying the Reynolds number

• mass transport problems by varying the Peclet number

• multicomponent phase equilibria problems by varying temperature/pressure

• reaction equilibrium problems by varying reaction rates

13

Page 14: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Homotopy• This transformation from one problem to another is

termed homotopy.

• Generically, we seek the roots of an equation:

• When ,

• The roots are the roots of

• When ,

• The roots are the roots of

• There is a smooth transformation from to

• is varied in small increments from zero to one and the solution is used as the initial guess for

14

h(x;�) = �f(x) + (1� �)g(x)

� = 0 h(x; 0) = g(x)

x

⇤(�)

x

⇤(0) g(x)

� = 1 h(x; 1) = f(x)

x

⇤(1) f(x)

g(x) f(x)

x

⇤(�i) x

⇤(�i+1)

Page 15: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Homotopy

• For small changes in the homotopy parameter, the previous solution will be a good initial guess.

• Newton-Raphson like methods can be expected to converge quickly.

• In practice, the function is associated with the problem of interest, but the function is arbitrary.

• It may be difficult to find a good function

• Physically based homotopies are usually preferable.

15

f(x)g(x)

g(x)

Page 16: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Homotopy• Example:

• Find roots of the van der Waals equation of state given:

16

P̂ = 0.1, T̂ = 0.5

0 2 4 6 8 10 12 14 16 18 20−1.5

−1

−0.5

0

0.5

1

f(v̂)

3f(v̂) =

✓P̂ +

1v̂

v̂2

◆✓� 8

3

◆� T̂ = 0

3

Page 17: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Homotopy• Example:

• Find roots of the van der Waals equation of state given:

• Create the homotopy:

• with the ideal gas function:

• , ideal gas; , van der Waals

17

P̂ = 0.1, T̂ = 0.5

3f(v̂) =

✓P̂ +

1v̂

v̂2

◆✓� 8

3

◆� T̂ = 0

3

h(v̂) = �f(v̂) + (1� �)g(v̂)

8g(v̂) = P̂ v̂ � T̂

3� = 0 � = 1

Page 18: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Homotopy• Example:

• Find roots of the van der Waals equation of state given:

18

P̂ = 0.1, T̂ = 0.5

T = 0.5;P = 0.1;

vguess = 8 / 3 * T / P;

f = @( v ) ( P + 3 ./ v .^ 2 ) .* ( v - 1/ 3 ) - 8 / 3 * T;g = @( v ) P .* v - 8 / 3 * T;h = @( v, l ) l * f( v ) + ( 1 - l ) * g( v );

lambda = [ 0:0.01:1 ];

for i = 1:length( lambda ) v( i ) = fzero( @( v ) h( v, lambda( i ) ), vguess ); vguess = v( i ); end;

Page 19: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Homotopy• Example:

• Find roots of the van der Waals equation of state given:

19

P̂ = 0.1, T̂ = 0.5

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 20

2

4

6

8

10

12

14

v̂(�)

Page 20: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

• Example:

• Find roots of the van der Waals equation of state given:

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 20

2

4

6

8

10

12

14

Homotopy

20

P̂ = 0.1, T̂ = 0.5

v̂(�)

Page 21: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

• Example:

• Find roots of the van der Waals equation of state given:

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 20

2

4

6

8

10

12

14

Homotopy

21

P̂ = 0.1, T̂ = 0.5

v̂(�)

Page 22: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

• Example:

• Find roots of the van der Waals equation of state given:

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 20

2

4

6

8

10

12

14

Homotopy

22

P̂ = 0.1, T̂ = 0.5

turning points detJh(x⇤(�),�) = 0v̂(�)

Page 23: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

• Parameterize the roots and homotopy parameter in terms of the distance travelled along the solution curve:

• Determine how to change homotopy parameter from arclength constraint:

Arclength Continuation

230 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 20

2

4

6

8

10

12

14

x

⇤(�(s)),�(s)

k d dx

⇤(�(s))ds

k22 +✓ 2

�(s)ds

◆= 1

x

⇤(�(s))

�(s)

Page 24: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Bifurcation

• Example:

• Find the real roots of

24

f(x) = x

3 � rx

−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1−2

−1.5

−1

−0.5

0

0.5

1

1.5

2

f(x)

x

r < 0

r = 0

r > 0

Page 25: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Bifurcation

• Example:

• Find the real roots of

25

f(x) = x

3 � rx

x

rr < 0, x⇤ = 0

r > 0, x⇤ = 0,±pr

r = 0, f 0(x⇤) = 0

Page 26: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Bifurcation

• Occasionally, a problem will switch from having 1 solution to having many solutions as a parameter is varied.

• We have seen how this occurs discontinuously with turning points.

• When additional solutions appear continuously, it is termed bifurcation.

• Bifurcations in a homotopy enable finding of multiple solutions to the same nonlinear equation

• Finding bifurcation (and turning) points can be of great physical interest.

• Like turning points, the Jacobian is singular at a bifurcation point:

26

detJ(x⇤) = 0

Page 27: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Bifurcation

27

x1

h(x,�i�1) = 0

x2

Page 28: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Bifurcation

28

x1

h(x,�i) = 0

detJh(x,�i) = 0

x2

Page 29: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Bifurcation

29

x1

h(x,�i+1) = 0

x2

Page 30: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Bifurcation

• In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter.

• The bifurcation is detected by checking the sign of the determinant of the Jacobian.

• If det J

h ( x , � ) = 0 at the bifurcation, then it changed from positive to negative (or negative to positive) as the homotopy parameter changed.

• We can find the bifurcation point exactly by solving an augmented system of nonlinear equations:

✓h(x;�)

◆= 0

detJh(x,�)

• which finds the value of x

and � at the bifurcation30

Page 31: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Bifurcation

• Example:

• Find the radius where two circles just touch: ✓

(x + 3)2 + (x + 1)2 �R

2

f(x) = 1 2

(x1 � 2)2 + (x2 � 2)2 �R

2

too big too small 31

Page 32: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Bifurcation

• Example:

• Find the radius where two circles just touch: ✓

(x + 3)2 + (x + 1)2 R

x) = 1 2 � 2

f((x1 � 2)2 + (x2 � 2)2 �R

2

• This is a bifurcation point (from 0 to 2 solutions)

f(x) = 0detJ(x) = 0

• Find this point by solving the augmented equations✓

f(x)fo

J(x)

◆= 0 r y =

det

✓x

R

32

Page 33: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

Bifurcation

• Example:

• Find this point by solving the augmented equations:

✓f(x)

detJ( )

◆= 0 for

y =

✓x

x R

• Newton-Raphson iteration:

yi+1 = yi +�yi

✓J(x) @

@R f(x) f(x)�y =r detJ(x) @

@R detJ(x)

◆���� iyi

�✓

detJ(x)

◆����yi

33

Page 34: 10.34: Numerical Methods Applied to Chemical Engineering · •In practice, it is hard to hit the bifurcation point exactly while stepping with the homotopy parameter. • The bifurcation

MIT OpenCourseWarehttps://ocw.mit.edu

10.34 Numerical Methods Applied to Chemical EngineeringFall 2015

For information about citing these materials or our Terms of Use, visit: https://ocw.mit.edu/terms.