24
Slide 1 18-660: Numerical Methods for Engineering Design and Optimization Xin Li Department of ECE Carnegie Mellon University Pittsburgh, PA 15213

18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 1

18-660: Numerical Methods for Engineering Design and Optimization

Xin Li Department of ECE

Carnegie Mellon University Pittsburgh, PA 15213

Page 2: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 2

Overview

Ordinary Differential Equation (ODE) Numerical integration Stability

Page 3: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 3

Ordinary Differential Equation (ODE)

Transient analysis for electrical circuit

( ) ( ) ( )( )

( ) ( )0100≥=

=−=

ttux

txtutx Ordinary differential equation

Initial condition

F1

Ω11

0

1

0

( )tu ( )tx

Page 4: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 4

Ordinary Differential Equation (ODE)

General mathematical form

( ) ( ) ( )[ ] ( ) XxtutxtxF == 00,,

N-dimensional vector of unknown variables

Vector of input sources

Nonlinear operator

( ):tx

( ):tu

:F

Initial condition :X

Page 5: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 5

Numerical Integration

In general, closed-form solution does not exist Even if ODE is linear, we cannot find analytical solutions in

many practical cases

Numerical methods must be applied to approximate the

solution – numerical solution Numerical integration for differential operator

( ) ???≈tx

Algebraic equation

Page 6: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 6

Numerical Integration

Several different formulas exist for numerical integration One-step numerical integration approximates differential

operator from two successive time points

( )xfx = ( ) ( ) ( )[ ] ( )nn

nn tftxft

txtx=≈

∆−+1Forward

Euler (FE)

( ) ( ) ( )11

++ ≈∆−

nnn tf

ttxtxBackward

Euler (BE)

( ) ( ) ( ) ( )2

11 ++ +≈

∆− nnnn tftft

txtxTrapezoidal (TR)

( )xft

txtx nn ≈∆−+ )()( 1

Page 7: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 7

Trapezoidal Approximation

Trapezoidal is often more accurate but also more expensive than BE and FE

)(tf

nt 1+nt t ( ) ( ) ( )[ ]

( )[ ] ( )[ ]2

1

1

1

+

+

+⋅∆≈

⋅=− ∫+

nn

t

tnn

txftxft

dttxftxtxn

n

( )xfx =

( ) ( ) ( )[ ] ( )[ ]2

11 ++ +≈

∆− nnnn txftxft

txtx

Page 8: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 8

Backward Euler Approximation

Similar to TR but is less accurate and expensive Widely used for practical applications

tnt 1+nt

)(tf

( ) ( ) ( )[ ]

( )[ ]1

1

1

+

+

⋅∆≈

⋅=− ∫+

n

t

tnn

txft

dttxftxtxn

n

( )xfx =

( ) ( ) ( )[ ]11

++ ≈∆−

nnn txf

ttxtx

Page 9: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 9

Backward Euler Example

First-order system example

( ) ( ) ( )( )

( ) ( )0100≥=

=−=

ttux

txtutx

( ) ( ) ( )

( ) 0

1

0

11

=

−=∆−

++

tx

txt

txtxn

nn

( )( ) ( ) ( )1

1+

+ ≈∆−=

nnn tf

ttxtx

xfx

t

x(t)

t1 t0 t2 t3 t4 t5 t6 t7

Page 10: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 10

Backward Euler Example

First-order system example

t

x(t)

t1 t0 t2 t3 t4 t5 t6 t7

( ) ( ) ( )

( ) 0

1

0

11

=

−=∆−

++

tx

txt

txtxn

nn

( ) ( ) ( )

( ) 0

1

0

101

=

−=∆−

tx

txt

txtx

( ) ( ) ( )101 txtttxtx ⋅∆−∆=−

( ) ( )t

tttxttx

∆+∆

=∆+

+∆=

110

1

Page 11: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 11

Backward Euler Example

First-order system example

t

x(t)

t1 t0 t2 t3 t4 t5 t6 t7

( ) ( ) ( )212 1 tx

ttxtx

−=∆−

( ) ( ) ( )212 txtttxtx ⋅∆−∆=−

( ) ( )ttxttx

∆++∆

=1

12 Continue iteration to determine x(t)

( ) ( ) ( )

( ) 0

1

0

11

=

−=∆−

++

tx

txt

txtxn

nn

Page 12: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 12

Forward Euler Approximation

Least accurate compared to TR and BE Difficult to guarantee stability

tnt 1+nt

)(tf

( ) ( ) ( )[ ]

( )[ ]n

t

tnn

txft

dttxftxtxn

n

⋅∆≈

⋅=− ∫+

+

1

1

( )xfx =

( ) ( ) ( )[ ]nnn txf

ttxtx

≈∆−+1

Page 13: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 13

Forward Euler Example

First-order system example

( ) ( ) ( )( ) ( ) 010 ==

−=tux

txtutx

( ) ( ) ( )

( ) 10

1

=

−=∆−+

tx

txt

txtxn

nn

( )( ) ( ) ( )n

nn tft

txtxxfx

≈∆−=

+1

t

x(t)

t1 t0 t2 t3 t4 t5 t6 t7

Page 14: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 14

Forward Euler Example

First-order system example

t

x(t)

t1 t0 t2 t3 t4 t5 t6 t7

( ) ( ) ( )

( ) 10

1

=

−=∆−+

tx

txt

txtxn

nn

( ) ( ) ( )

( ) 10

001

=

−=∆−

tx

txt

txtx

( ) 11 +∆−= ttx

( ) ttx ∆−=11

Page 15: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 15

Forward Euler Example

First-order system example

t

x(t)

t1 t0 t2 t3 t4 t5 t6 t7

( ) ( ) ( )

( ) 10

1

=

−=∆−+

tx

txt

txtxn

nn

( ) ( ) ( )

( ) ttx

txt

txtx

∆−=

−=∆−

11

112

( ) ( ) ( )112 txtxttx +⋅∆−=

( ) ( ) ( )( )2

12

1

1

t

txttx

∆−=

⋅∆−=

Page 16: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 16

Forward Euler Example

First-order system example

( ) ( ) ( )

( ) 10

1

=

−=∆−+

tx

txt

txtxn

nn

t

x(t)

t1 t0 t2 t3 t4 t5 t6 t7

( ) ( )33 1 ttx ∆−=

( ) ( )nn ttx ∆−= 1

( ) ( )44 1 ttx ∆−=

Page 17: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 17

Forward Euler Example

First-order system example ( ) ( )nn ttx ∆−= 1

0 1 2 3 4 5 60

0.2

0.4

0.6

0.8

1

Time (Sec.)

x(t)

0 10 20 30-1000

-500

0

500

1000

1500

Time (Sec.)x(

t)

∆t = 0.1 (correct answer) ∆t = 3 (fail to converge)

Forward Euler fails to converge if ∆t is too large

Page 18: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 18

Numerical Integration Stability

∆t must be sufficiently small for FE to guarantee stability In practice, it is not easy to determine the appropriate ∆t

BE and TR do not suffer from stability issue

Stability is guaranteed for any ∆t > 0

First-order system example

( ) ( ) ( )( ) ( ) 010 ==

−=tux

txtutxBE ( )

( )nn ttx

∆+=

11

Always stable for ∆t > 0

Page 19: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 19

Nth-Order Linear ODE

Our simple example solves a first-order linear ODE

In general, an Nth-order linear time-invariant dynamic system is described by the following ODE:

( ) ( ) ( )txtutx −=

( ) ( ) ( )( ) 00 =

⋅+⋅=x

tuBtxAtx Ordinary differential equation Initial condition

N-dimensional vector of unknown variables

Vector of input sources

Matrices

( ):tx

( ):tu

:, BA

Page 20: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 20

Nth-Order Linear ODE

Backward Euler example ( ) ( ) ( ) ( ) 00 =⋅+⋅= xtuBtxAtx

( ) ( ) ( ) ( ) ( ) 00111 =⋅+⋅=∆−

+++ txtuBtxA

ttxtx

nnnn

( ) ( ) ( ) ( ) ( ) 00111 =⋅⋅∆+⋅⋅∆=− +++ txtuBttxAttxtx nnnn

( ) ( ) ( ) ( )[ ] ( ) 0011

1 =⋅⋅∆+⋅⋅∆−= +−

+ txtuBttxAtItx nnn

Solve linear algebraic equation to find x(tn+1)

Page 21: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 21

Nth-Order Nonlinear ODE

Many physical systems are both high-order and nonlinear

( ) ( ) ( )[ ] ( ) 000,, == xtutxtxF

N-dimensional vector of unknown variables

Vector of input sources

Nonlinear operator

( ):tx

( ):tu

:F

Page 22: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 22

Nth-Order Nonlinear ODE

Backward Euler example

Solving nonlinear algebraic equation requires iterative algorithm More details in future lectures...

( ) ( ) ( )[ ] ( ) 000,, == xtutxtxF

( ) ( ) ( ) ( ) ( ) 00,, 0111 ==

∆−

+++ txtutx

ttxtxF nn

nn

Solve nonlinear algebraic equation to find x(tn+1)

Page 23: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 23

Advanced Topics for ODE Solver

Local truncation error estimation Estimate approximation error for numerical integration

Adaptive time step control

Dynamically determine ∆t

High-order integration formula

Apply multi-step numerical integration

Some of these advanced topics are covered by 18-762 that

particularly focuses on ODE solver for circuit simulation

Page 24: 18-660: Numerical Methods for Engineering Design and ...users.ece.cmu.edu/~xinli/classes/cmu_18660/Lec02.pdf · Engineering Design and Optimization Xin Li Department of ECE . Carnegie

Slide 24

Summary

Ordinary differential equation (ODE) Numerical integration Stability