23
Professor Walter W. Olson Department of Mechanical, Industrial and Manufacturing Engineering University of Toledo Solving ODE

Solving ODE

  • Upload
    tabib

  • View
    80

  • Download
    3

Embed Size (px)

DESCRIPTION

Solving ODE. Professor Walter W. Olson Department of Mechanical, Industrial and Manufacturing Engineering University of Toledo. Outline of Today’s Lecture. Review SIMULINK Two common mathematical problems is controls Numerical Methods Newton Raphson Homogeneous Solution Euler Method - PowerPoint PPT Presentation

Citation preview

Page 1: Solving ODE

Professor Walter W. OlsonDepartment of Mechanical, Industrial and Manufacturing Engineering

University of Toledo

Solving ODE

Page 2: Solving ODE

Outline of Today’s Lecture Review

SIMULINKTwo common mathematical problems is controlsNumerical MethodsNewton RaphsonHomogeneous SolutionEuler MethodRunge Kutta

Page 3: Solving ODE

Simulink

Page 4: Solving ODE

SIMULINK

Page 5: Solving ODE

SIMULINK

Page 6: Solving ODE

SIMULINK

Page 7: Solving ODE

Two Mathematical Problems Frequently Encountered in ControlsFind the roots of an equation

MethodsTrial and Error (bracketing methods add a bit of science to this)GraphicsClosed form solutions (e.g.: quadratic formula)Newton Raphson

Find the solution at a given time for given conditionsVarious differential and difference equations analytic solutions

(sometimes reformulated as find the roots problem)Numerical Methods

Newton Cotes Methods (trapezoidal rule, Simpson’s rule. etc. for integration)

Euler’s Method Runga Kutta/Butcher Methods Many other techniques (Adams-Bashforth, Adams-Milne, Hermite–

Obreschkoff, Fehlberg, Conjugate Gradient Methods, etc.)

Page 8: Solving ODE

Numerical MethodsSolutions can be approximated using

numerical methodsWhy Numerical Methods?

Analytical methods may not exist to solve for the exact roots or the exact solution

Use of computersFlexibility of making changes

Page 9: Solving ODE

Numerical MethodsNumerical methods follow the procedure

Step1: Initialize: Select some initial valueStep2: Estimate using (guess, some

analytical technique) a new value at increment “i”

Step 3: Is the system converging? If not, use something else. We usually know a priori whether a method will converge or not form mathematics. Therefore, this step is often omitted.

Step 4: Is the change from the previous value to current value smaller than our acceptable error? If not, make the current value the previous value and

return to step 2. If so, stop and accept the new value as the solution.

Page 10: Solving ODE

Newton Raphson Method for finding roots Probably the most common

numerical technique simpleefficientflexible

It can be shown from a truncated Taylor’s Series that

Provided that the slope at the test points is consistent, we can iterate to a solution within our error tolerance

t

f(t)

f(ti)

titi+1

1 1

1

1

( )( ) ( ) ( )

new value = old value + slope * step

therefore, solving for

( )( ) /

ii i i i

i

ii i

i

df tf t f t t t

dt

t

f tt t

df t dt

Problems occur if the slope reversessign such as in an oscillation or becomes very flat

Page 11: Solving ODE

ExampleFind the roots of

To within 0.01 of the value of s

There appears to be a crossing between -2 and 0, but where?

5 4 3 2( ) 2 5 10 22 48F s s s s s s

24 3

1

( ) 5 8 15 20 22-1 seems to be a good first guess

( 1) 1 2 5 10 22 48 =32( 1) 5 8 15 20 22 14

3.2857

the root li

( )

es between -1 and -3.28573.2857 1 2.285

321( ) 14

(

7

ii i

i

F s s s s s

FF s

F ss s

F s

F

1

1

1

3.2857 243.53( 3.2857 417.2

2.702 2.702 -3.2857 0.5837

2.702 74.487( 2.702 186.17

2.302 0.42.302 19.126

( 2.302 98.

))

( ))

( ))

(

2662.107 0.195

)2.302 2.838(

i

i

i

s

F

sF

s

F

F

F

FF

1

1

2.302 70.1642.067 0.04

2.067 0.00219( 2.06

)

( ))7 65.137

2.065 0.002 0.01 Stop!

i

i

sF

s

F

Page 12: Solving ODE

ODE for Linear Control Theory In Linear Control Theory, the equations that are encountered

are almost always of the form

with constant coefficients subject to initial conditions. Most problems are 2nd order.

The electric motor example:

Subject to {Va(0), ia(0)=0 and q(0) = 0}

1 2

0 1 2 11 2 ( ) ( )n n n

n nn n n

dx dx dx dxa a a a a x t u td t d t d t dt

2

a a a b a

a a a

a

di R i K Vddt L L dt L

Kid b ddt J J dt

q

q q

Page 13: Solving ODE

Solution Methods To solve

We can use Reduction in orderUndetermined coefficientsVariation of parametersLaplace TransformsSuperposition of particular integralsCauchy-Euler equationNumerical methods

1 2

0 1 2 11 2 ( ) ( )n n n

n nn n n

dx dx dx dxa a a a a x t u td t d t d t dt

Page 14: Solving ODE

Reduction of Order The object is to reduce

the order of the equation by substitutions until it can be solved

Example:A hanging cable with a

weight of w per unit length under tension T:

22

2

2

2

1

cos sin

tan

1 1

Let , then 1

1

sinh sinh

sinh

with limits x=0, y=0 and x=x, y =y

cos

H T W T wsdy Wdx H

d y dW w ds w dydx H dx H dx H dx

dy dp wp pdx dx H

dp wdxHp

wx dy wxp pH dx Hwxdy dxH

wyH

q q

q

h 1 , a catenarywxH

W

H

T

q

x

y

s

Page 15: Solving ODE

Homogenous CaseWhen

we form the characteristic equation and solve for its roots

We have three possible outcomes for the roots that we must consider:

1) Real Distinct Roots : for p distinct real roots, the solution term is of the form

2) Repeated Real Roots: Assume roots r and r+1 are repeated, that is, Then the term in the solution corresponding to the repeated root is and if there were v repeated roots of the same value, the term would be

3) Complex Conjugate Roots: Assume that roots, The corresponding term of the solution is

12

0121 12()0nnn

nn nnn

dxdxdxdx aaaaaxtdtdtdtdt

1 20 1 2 1 0n n n

n na m a m a m a m a

1 21 2 2

p p pm t m t m t mtpc e c e c e c e

1r rm m

0 1( ) rm tk k x e2

0 1 2( ... )r r

r

v m tvk k x k x k x e

1( ) and ( )s sm a bi m a bi

1 2sin cosate l bt l bt

Therefore the complete solution accounting for all possible roots is 1

1 2

20 1 2

1 1 1

( ... ) sin cos

where , the total number of roots

p i j j h

j

p r sm t v m t a t

i v h h h hi j h

y c e k k x k x k x e e l b t l b t

p r s n

Page 16: Solving ODE

Homogenous ExampleA weight of 15 Kgf is supported (x = 0, at rest,) by a spring

with a spring rate of 50 N/m. At t = 0, the weight is extended by 20 centimeters and released.

Model and solve.

0.5667

0

2

2

1,2

1

2

1 2

2 2

.5667

1

0.5667 1.73560.5667 1.7356

1.7356 1.7356

1.7356

0.0653

0.0653sin(1.735

0

15 17 50 0

17 17

6

4*15*502*15

( ) sin cos

(0) 0.2 cos 0.2

(0) 0

( )

t

t

mx bx kx

y y

y

yy

x t e c c

x c c

x c

t t

t

x t e

ii

0.2cos) 1.7356t t(0) 0.2 ( ) 0x x t

0mx kx

Page 17: Solving ODE

Euler Method Our goal is to solve equations

of the form

The theory for the Euler method is the same as that of the Newton Raphson Method:

Rather than now solve for an axis crossing, we predict where the next value of the curve will be and then

Make successive estimates of yi+1

( , )dy f x ydx

1 *

new value = old value + slope*step

i idyy y hdx

yi

xi

Prediction

Error}yi+1

xi+1

step h

}

Page 18: Solving ODE

Example

1 0 0

015 17 50 0assume x = 0.2, 0 at t=0try a time step h = 0.1

17 50, 15 15

0 1( , )50 17

15 15

i i i

mx bx kxx x x

x

dx dxx x xdt dt

x xd f x tx xdt

x x xdx x xdt

1

2

0 10.2 0.2 0.20.150 170 0 0.0007

15 150 10.2 0.2 0.1999

0.150 170.0007 0.0007 0.001315 15

i

i

h

xx

xx

3

:0 10.1999 0.1999 0.1999

0.150 170.0013 0.0013 0.00215 15

...

i

continuing

xx

Page 19: Solving ODE

ExampleTry a smaller time

step,say, h = 0.01seconds

Page 20: Solving ODE

Runge Kutta/Butcher MethodHas its origins in a 2

variable Taylor Series Expansion

The function is called the increment function

RK4 is a four factor expansion of the incrementing function

For RK4:

Butcher’s method uses 5 factors is more accurate than RK4 at a given time step

1

( , )

( , , )i i i i

dy f x ydxy y x y h h

( , , )i ix y h

31 2 4

1

12

23

4 3

( , , )6 3 3 6

( , )

( , )2 2

( , )2 2

( , )

i i

i i

i i

i i

i i

kk k kx y h

k f x yhkhk f x y

hkhk f x y

k f x h y hk

Page 21: Solving ODE

Example

1

015 17 50 0assume x = 0.2, 0 at t=0, h = 0.1

17 50, 15 15

0 1( , ) 50 17

15 15note: y x and x t for the RK4 formulae

0 1( , )i i

mx bx kxx x x

xdx dxx x xdt dt

x xd f x tx xdt

k f t x

12

23

0.2 03.333 1.133 0 0.6667

0 1 0.2 0 0.0333( , ) 0.05

3.333 1.133 0 0.6667 0.6292 2

0 1 0.2 0.0333( , ) 0.05

3.333 1.133 02 2

i i

i i

hkhk f t x

hkhk f x y

4 3

31 2 4

0.03140.629 0.625

0 1 0.2 0.0314 0.0625( , ) 0.1

3.333 1.133 0 0.625 0.585

0 0.03331 1( , , )0.6667 0.6296 3 3 6 6 3

i i

i i

k f x h y hk

kk k kx y h

0.0314 0.0625 0.03201 10.625 0.585 0.6273 6

Page 22: Solving ODE

Example31 2 4

1

0 0.0333 0.0314 0.0625 0.03201 1 1 1( , , )0.6667 0.629 0.625 0.585 0.6276 3 3 6 6 3 3 6

0.2 0.0320 0.1968( , , ) *0.1

0 0.627 0.0637

i i

i i i i

kk k kx y h

y y x y h h

then we would continue with further iterations

The result of the RK4 at h = 0.1 is essentially the same as the analytic solution:

Page 23: Solving ODE

SummaryModels for Control Systems are either differential

equation or difference equationsThe problems we commonly see will be

Finding the roots of the equationFinding the trajectory or path of the equation over time

While we have a number of analytical techniques to find exact results, we cannot address all of the equations encountered

Numerical methods for finding roots and for trajectories are most commonly usedNewton Raphson for finding rootsMethods such as the Runge Kutta 4 are used for

trajectories

Next Class: Analyzing stability