Sie sind auf Seite 1von 23

Professor Walter W.

Olson
Department of Mechanical, Industrial and Manufacturing Engineering
University of Toledo

Solving ODE

Outline of Todays Lecture


Review
SIMULINK

Two common mathematical problems is controls


Numerical Methods
Newton Raphson
Homogeneous Solution
Euler Method
Runge Kutta

Simulink

SIMULINK

SIMULINK

SIMULINK

Two Mathematical Problems


Frequently Encountered in Controls
Find the roots of an equation
Methods
Trial and Error (bracketing methods add a bit of science to this)
Graphics
Closed form solutions (e.g.: quadratic formula)
Newton Raphson

Find the solution at a given time for given conditions


Various differential and difference equations analytic solutions

(sometimes reformulated as find the roots problem)


Numerical Methods
Newton Cotes Methods (trapezoidal rule, Simpsons rule. etc. for

integration)
Eulers Method
Runga Kutta/Butcher Methods
Many other techniques (Adams-Bashforth, Adams-Milne, Hermite
Obreschkoff, Fehlberg, Conjugate Gradient Methods, etc.)

Numerical Methods
Solutions can be approximated using

numerical methods
Why Numerical Methods?
Analytical methods may not exist to solve for

the exact roots or the exact solution


Use of computers
Flexibility of making changes

Numerical Methods
Numerical methods follow the procedure
Step1: Initialize: Select some initial value
Step2: 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

Newton Raphson Method for


finding roots
f(t)
Probably the most common

numerical technique
simple
efficient
flexible

f(ti)

It can be shown from a

truncated Taylors Series that


df (ti )
f (ti 1 ) f (ti )
(ti 1 ti )
dt

new value = old value + slope * step


therefore, solving for ti 1
ti 1 ti

f (ti )
df (ti ) / dt

Provided that the slope at the

test points is consistent, we


can iterate to a solution
within our error tolerance

ti+1

ti

Problems occur if the slope reverses


sign such as in an oscillation or
becomes very flat

F ( s ) 5s 4 8s 3 15s 20 s 22

Example

-1 seems to be a good first guess

Find the roots of

si 1 si

F ( s ) s 5 2 s 4 5s 3 10s 2 22 s 48
To within 0.01 of the value of
s

F ( 1) 1 2 5 10 22 48 =32
F ( 1) 5 8 15 20 s 22 14
F ( si )
32
1
3.2857
F ( si )
14

the root lies between -1 and -3.2857

3.2857 1 2.2857
F ( 3.2857) 243.53
F ( 3.2857) 417.2
si 1 2.702

2.702 -3.2857 0.5837

F ( 2.702) 74.487
F ( 2.702) 186.17

0.4
F ( 2.302) 19.126
F ( 2.302) 98.266
si 1 2.107 0.195
F ( 2.302) 2.838
F ( 2.302) 70.164
si 1 2.067 0.04
F ( 2.067) 0.00219
F ( 2.067) 65.137
si 1 2.302

There appears to be a

crossing between -2 and 0,


but where?

si 1 2.065

0.002 0.01 Stop!

ODE for Linear Control


Theory
In Linear Control Theory, the equations that are encountered

are almost always of the form

dx n
dx n 1
dx n 2
dx
a0 n a1 n 1 a2 n 2 K an 1
an x ( t ) u ( t )
d t
d t
d t
dt

with constant coefficients subject to initial conditions.


Most problems are 2nd order.
The electric motor example:

dia
Ra ia Kb d Va

dt
La La dt La
d 2 Kia b d

dt
J J dt

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

Solution Methods
To solve
dx n
dx n 1
dx n 2
dx
a0 n a1 n 1 a2 n 2 K an 1
a n x (t ) u (t )
d t
d t
d t
dt

We can use
Reduction in order
Undetermined coefficients
Variation of parameters
Laplace Transforms
Superposition of particular integrals
Cauchy-Euler equation
Numerical methods

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 unitT
length under tension T:
y

H T cos
dy W
tan

dx H

W T sin ws

d 2 y 1 dW w ds w
dy


dx 2 H dx H dx H
dx
dy
dp w
Let p , then

1 p2
dx
dx H
dp
wdx

H
1 p2
wx
dy
wx
p
sinh
H
dx
H
wx

dy sinh dx
H

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

sinh 1 p

wx
cos
h

1
, a catenary
H
H

Homogenous Case
When
n
a0

n 1

n 2

dx
dx
dx
dx

a
an x (t ) 0
1
2
n

1
d nt
d n 1t
d n 2t
dt

we form the characteristic


equation and solve for its
a0 m n roots
a1m n 1 a2 m n 2 K an 1m an 0

2) Repeated Real Roots:


Assume roots r and r+1
are repeated, that is,
Then the term in the
mr mr 1corresponding to
solution
the repeated root is m t
(k0 were
k1 x )e v
and if there
mt
( k0 k1 x roots
k2 x 2 ...
x v )esame
repeated
ofkvthe
value, the term would be
r

We have three possible


outcomes for the roots
ms ( a bi ) and ms 1 (a bi )
that we must consider:
3) Complex Conjugate Roots:
1) Real Distinct Roots : for p
at
m t
m t
m t
mt
Assume
that
e
sin bt l2 cos bt
l1 roots,
c1edistinct
c2 e real
c2 eroots,
K the
cpe
The corresponding term of
solution term is of the
the solution is
form
Therefore
the complete
solution accounting
for all possible roots is
p
r
s
r

p 1

y ci e
i 1

m p i 1t

p 2

v
m t
(k 0 k1 x k 2 x 2 ... k v j x j )e j e ah t lh1 sin bh t lh2 cos bh t
j 1
h 1

where p r s n, the total number of roots

Homogenous Example
A 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.

& bx& kx 0
mx&
15 y 2 17 y 50 0
17 172 4 *15*50
y1,2
2 *15
y1 0.5667 1.7356i
y2 0.5667 1.7356i

x (t ) e 0.5667 t c1 sin 1.7356t c2 cos 1.7356t

& kx 0
mx&
x (0) 0.2

x&(t ) 0

x (0) 0.2 c2 cos 1.7356t c2 0.2


x&(0) 0 c1 0.0653

x (t ) e 0.5667 t 0.0653sin(1.7356t ) 0.2cos 1.7356t

Euler Method
Our goal is to solve equations

of the form

dy
f ( x, y )
dx

Prediction
yi
yi+1

The theory for the Euler

Error

method is the same as that of


the Newton Raphson Method:
dy
*h
dx
new value = old value + slope*step
yi 1 yi

axis crossing, we predict


where the next value of the
curve will be and then
Make successive estimates of

yi+1

xi+1

Rather than now solve for an

xi

step h

Example
& bx& kx 0
mx&
15&
x& 17 x& 50 x 0
assume x = 0.2, x& 0 at t=0
try a time step h = 0.1
dx
dx& 17
50
x&,
x& x
dt
dt
15
15
1
0
r
x
d x
50

f
(
x
, t)
17

&
x
dt x&


15
15
x
x
d x

x&


x& h
i 1 x& i 0 dt

i 0
0
x
0.2

x&

0 50
i 1
15
x
x&

i2

0.2

0.0007

1

17

15
0
50

15

continuing :
x
x&

i 3

0
0.1999

50
0.0013

15

...

0.2
0.2

0.1

0.0007

1

17

15

0.2
0.1999

0.1

0.0007
0.0013

1

17

15

0.1999

0.1

0.0013

0.1999

0.002

Example
Try a smaller time

step,
say, h =
0.01seconds

Runge Kutta/Butcher Method


Has its origins in a 2

variable Taylor Series


Expansion
dy
f ( x, y )
dx
yi 1 yi ( xi , yi , h ) h

The function
( xi , yi , h )

is called the
increment function
RK4 is a four factor
expansion of the
incrementing function

k1 k2 k3 k4

6 3 3 6For RK4:
k1 f ( xi , yi )

( xi , yi , h )

hk
h
k2 f ( xi , yi 1 )
2
2
hk
h
k3 f ( xi , yi 2 )
2
2
k4 f ( xi h, yi hk3 )

Butchers method uses 5 factors is

more accurate than RK4 at a given


time step

Example

& bx& kx 0
mx&
15&
x& 17 x& 50 x 0

assume x = 0.2, x& 0 at t=0, h = 0.1


dx
dx& 17
50
x&,
x&
x
dt
dt
15
15
1
0
r
x
d x

f ( x , t ) 50
17


dt x&
x&

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

r
k1 f (ti , xi )

1 0.2
0

0.6667
3.333 1.133 0

0
1 0.2
0
0.0333

h r hk
k 2 f (ti , xi 1 )

0.05

0.6667
0.629
2
2
3.333 1.133 0


0
1 0.2

0.0333
hk
h
k 3 f ( xi , y i 2 )
0.05


2
2
3.333 1.133 0
0.629

0.0314

0.625

1 0.2
0.0314
0.0625

0.1

0.625
0.585
3.333 1.133 0

k 4 f ( xi h, yi hk3 )

( xi , yi , h )

0
0.0320
1 0.0333

1 0.0625

k1 k2 k3 k4 1
1 0.0314

0.627
6 3 3 6 6 0.6667
3 0.625
3 0.629

6 0.585

Example
0
1 0.0333

1 0.0314


0.0320
k1 k2 k3 k4 1
1 0.0625

6 3 3 6 6 0.6667
6 0.585
3 0.629

3 0.625

0.627
0.1968
0.2 0.0320

yi 1 yi ( xi , yi , h ) h
* 0.1

0.0637
0 0.627

then we would continue with further iterations

( xi , yi , h )

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

Summary
Models for Control Systems are either differential

equation or difference equations


The problems we commonly see will be
Finding the roots of the equation
Finding 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 used
Newton Raphson for finding roots
Methods such as the Runge Kutta 4 are used for

trajectories
Next Class: Analyzing stability

Das könnte Ihnen auch gefallen