autumn 2008 eee8013 revision lecture 1 ordinary differential equations
TRANSCRIPT
Autumn 2008
Model:
Ordinary Differential Equations (ODE):
ModelingModeling
f(t)
x(t)
frictionmaF
Dynamics: Properties of the system, we have to solve/study the ODE.
2
2
dt
xdm
dt
dxBf
maff friction
maBuf
Autumn 2008
First order ODEs:
First order systems: Study approachesFirst order systems: Study approaches
),( txfdt
dx
Analytic:
Explicit formula for x(t) (a solution – separate variables, integrating factor)
which satisfies ),( txfdt
dx
adt
dx INFINITE curves (for all Initial Conditions (ICs)). Cattx adtdx
Autumn 2008
First order linear equationsFirst order linear equations
First order linear equations - (linear in x and x’)
General form:
Autonomouscbxax
autonomousNontcxtbxta
,'
),()(')(
ukxx '
Numerical Solution: k=5, u=0.5
u
u Scope
1s
Integrator
k
Gain
x
x
Dxu
0 1 2 3 40
0.02
0.04
0.06
0.08
0.1
Autumn 2008
Analytic solution: Step inputAnalytic solution: Step input
ktconstkkdt
ee
uexeuekxxe ktktktkt ''
udtedtxe ktkt '
ceudteexcudtexe ktktktktkt
t
ktktkt udteexex0
110
Autumn 2008
Response to a sinusoidal inputResponse to a sinusoidal input
tkkyy cos' 11 tkkyy sin' 22
tktkjkyykjyjy cossin'' 1122 tjtkjyykjyy sincos'' 2121
tjkeyky ~'~
kte tjkkt keey '~ tjkkt etjk
key
~
ktj
e
k
y
1tan
2
21
1~
ktje
k
y
1tan
2
21
1Re~Re
tkjkjyjy sin' 22
tjetjk
ky
~
kt
k
1
2
2tancos
1
1
Autumn 2008
Response to a sinusoidal inputResponse to a sinusoidal input
Sine Wave
Scope3
Scope2
Scope1
Scope
Product1Product
eu
MathFunction1
eu
MathFunction
1s
Integrator1
1s
Integrator
0.1
Gain3
k
Gain2
-k
Gain1
k
Gain
Clock
total
total
steady state
Transient
0 2 4 6 8 10-0.2
-0.15
-0.1
-0.05
0
0.05
0.1
0.15
0.2
0.25
TransientSteadystate Overall
Autumn 2008
Second order ODEsSecond order ODEs
Second order ODEs: ),,'(2
2
txxfdt
xd
uBxAxx ''' u=0 => Homogeneous ODE
0''' BxAxx rtex rtrex ' rterx 2''
00''' 2 rtrtrt BeAreerBxAxx 02 BArr
21
2
,2
4xx
BAAr
2211 xCxCx
rtex
adt
xd
2
2
1Catdt
dx21
25.0 CtCatx So I am expecting 2 arbitrary constants
Let’s try a
Autumn 2008
Overdamped systemOverdamped system
BA 42 2
42 BAAr
Roots are real and unequal
trex 11 trex 2
2 trtr eCeCxCxCx 21212211
03'4'' xxx
tt eCeCx 23
1
10 x 00' x 10 21 CCx
tt eCeCx 23
13'
030' 21 CCx
tt eex 235.0 3
0130342 rrrr
rtex
0 1 2 3 4 5 6-0.5
0
0.5
1
1.5
Overall solution
x2
x1
Autumn 2008
Critically damped systemCritically damped system
BA 42 2
42 BAAr
Roots are real and equal
rtex 1rttex 2
rtrt teCeC
xCxCx
21
2211
A=2, B=1, x(0)=1, x’(0)=0 => c1=c2=1
0 2 4 6 8 100
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
e-t
te-t
overall
Autumn 2008
Underdamped systemUnderdamped system
BA 42 2
42 BAAr
Roots are complex Underdamped system
r=a+bj
0A
jbtatee
Theorem: If x is a complex solution to a real ODE then Re(x) and Im(x) are the real solutions of the ODE:
)sin(),cos( 21 btexbtex atat )sin()cos( 212211 btecbtecxcxcx atat
1
21
1
21
1 tan&,tancos
cc
cc
cG
bjtattbjart eeex )sin()cos( btjbteat
btGebtcbtce atat cos)sin()cos( 21
Autumn 2008
Underdamped system, exampleUnderdamped system, example
A=1, B=1, x(0)=1, x’(0)=0 => c1=1, c2=1/sqrt(3)
0 2 4 6 8 10-1.5
-1
-0.5
0
0.5
1
1.5
C1cos(bt)
C2sin(bt)
C1cos(bt)+C
2sin(bt)
0 2 4 6 8 10-1.5
-1
-0.5
0
0.5
1
1.5
C1cos(bt)+C
2sin(bt)
eat
Overall
)sin()cos( 21 btcbtceat btGeat cos
Autumn 2008
UndampedUndamped
0A Undamped system 00'' Bxx
btGbtcbtcx cos)sin()cos( 21 A=0, B=1, x(0)=1, x’(0)=0 =>c1=1, c2=0:
0 2 4 6 8 10-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
Overall
BrBeer rtrt 22 00
Autumn 2008
StabilityStability
In all previous cases if the real part is positive then the solution will diverge to infinity and the ODE (and hence the system) is called unstable.
jb
a
Critical or overdamped
underdamped
jb
a
Stable
Unstable
Autumn 2008
Natural frequency, damping frequency, damping factorNatural frequency, damping frequency, damping factor
2,2 nn BA 0'2'' 2 xxx nn
is the damping factor and n is the natural frequency of the system.
2
422
2
4 222nnnBAA
r
222nnnr
110
2222
nn
2222,1 nnnr
=> Overdamped system implies that 1
trtr eCeCx 2121
Case 1:
Autumn 2008
Natural frequency, damping frequency, damping factorNatural frequency, damping frequency, damping factor
112222 nn => Critically damped system implies that 1
nr tt nn teCeCx 21
110
2222
nn => Underdamped systems implies 1
22222,1 1 nnnnn jjr
dn jnd
21
tGex dtn cos d called damped frequency or pseudo-frequency
njr tGx ncos0 No damping the frequency of the oscillations = natural frequency
Case 2:
Case 3:
Case 4:
Autumn 2008
Stability revisedStability revised
0If then cases 1-3 are the same but with 0k
dj
n
Critical or overdamped
underdamped
Stable
Unstable
dj
n
Autumn 2008
NonHomogeneous (NH) differential equationsNonHomogeneous (NH) differential equations
uBxAxx '''
u=0 => Homogeneous => x1 & x2. Assume a particular solution of the nonhomogeneous ODE: xp
If u(t)=R=cosnt => B
RxP
Then all the solutions of the NHODE are 2211 xcxcxx P
So we have all the previous cases for under/over/un/critically damped systems plus a constant R/B.
If complementary solution is stable then the particular solution is called steady state.
Autumn 2008
ExampleExample
22''' Pxxxx )sin()cos(22 212211 btcbtcexcxcx at
x(0)=1, x’(0)=0 => c1=-1, c2=-1/sqrt(3)
0 2 4 6 8 10-1
-0.5
0
0.5
1
1.5
2
2.5
Overall
Homogeneous solution
Particular solution
Autumn 2008
State SpaceState Space
1,...'',', nn xxxxfx
Very difficult to be studied => so we use computers
Computers are better with 1st order ODE
1 nth => n 1st
Powerful tools from the linear algebra
kxxBFxm
xx
xx
2
1
mFx
x
m
B
m
k
x
x 010
2
1
2
1
xx1 2x
xx2 12
1kxBxF
m
Fmx
x
m
B
m
k
x
x
1
010
2
1
2
1 UBAXX
Use sensors: Output = x =>
DUyx
xxy
CX
2
101
Autumn 2008
State SpaceState Space
DUy
U
CX
BAXX Input Output
U yDUy
U
CX
BAXX
U1 y1
DUCX
BUAXX
y
U1
Uq
y2
yp
DUCXy
BUAXX
U Y
pq y
y
y
y
u
u
u
3
2
1
2
1
, YU
)()()()()(
)()()()(
ttttt
ttttt
UDXCY
UBXAX
Autumn 2008
Block DiagramBlock Diagram
)()()()()(
)()()()(
ttttt
ttttt
UDXCY
UBXAX
•X is an n x 1 state vector•U is an q x 1 input vector•Y is an p x 1 output vector•A is an n x n state matrix•B is an n x q input matrix•C is an p x n output matrix•D is an p x m feed forward matrix (usually zero)
)()()(
)()()(
ttt
ttt
DUCXY
BUAXX
BU dt C
DX X Y
A
Autumn 2008
State space rulesState space rules
The state vector describes the system => Gives its state =>
The state of a system is a complete summary of the system at a particular point in time.
If the current state of the system and the future input signals are known then it is possible to define the future states and outputs of the system.
The choice of the state space variables is free as long as some rules are followed:1. They must be linearly independent.2. They must specify completely the dynamic behaviour of the system.3. Finally they must not be input of the system.
Autumn 2008
State spaceState space
The system’s states can be written in a vector form as:
Tx 0,,0,11 x ...0,,,0 22Tx x Tnn x,,0,0 x
A standard orthogonal basis (since they are linear independent) for an n-dimensional vector space called state space.
x1
x2 R2
x2
x3 R3
Matlab definition
Autumn 2008
SolutionSolution
2
1
2
1
52
22
x
x
x
x
067
41025
252
5
2
1
252
125
2
1
52
1
52
1
52
22
222
22222
22222
22222
221
221
212
211
xxx
xxxxx
xxxxx
xxxxx
xxx
xxx
xxx
xxx
067 222 xxx
0672 rr
ta Cex
tb Dex 6
Autumn 2008
Solution IISolution II
2
1
2
1
52
22
x
x
x
x tea
a
2
1X
21
21
2
1
2
1
2
1
52
22
52
22
aa
aa
a
ae
a
ae
a
a tt
X
tea
a
2
1X
How can we solve that ???
Assume is a parameter => A homogeneous linear system
052
022
21
21
aa
aa
0672 052
22
(This last equation is the characteristic equation of the system, why???).
Autumn 2008
Solution IIISolution III
6
1067
2
12
11
042
02
21
21
aa
aa
I assume that a2=1 so a1=2 :1
1
2
2
1
a
a tet
1
2)(1X
61
02
024
21
21
aa
aaI assume that a1=2 so a2=-2 tet 6
2 6
1)(
X
tt eCeCt 621 2
1
1
2
X
Matlab example
Autumn 2008
General SolutionGeneral Solution
AXX
tec eX 0 eAIeAe 0 AI
The roots of this equation are called eigenvalues
ie in ...221
negative eigenvalues => stable
positive eigenvalues => unstable
repeated eigenvalues => eigenvectors are not linearly independent.
Complex eigenvalues => conjugate and the eigenvector will be complex =>solution will consists of sines, cosines and exponential terms
Autumn 2008
Properties of general solutionProperties of general solution
If we start exactly on one eigenvector then the solution will remain on that forever.
Hence if I have some stable and some unstable eigenvalues it is still possible (in theory) for the solution to converge to zero if we start exactly on a stable eigenvector.
tii
ieC e
tie Determines the nature of the time response (stable, fast..)
ie Determines the extend in which each state contributes to tie
iC Determines the extend in which the IC excites the tie
To find the eigenvalues and eigenvectors use the command eig()
Autumn 2008
ExampleExample
2
1
2
1
52
22
x
x
x
x
-1 -0.5 0 0.5 1 1.5-1
-0.5
0
0.5
1
1.5
x1
x 2
state space
0,0
e1
e2
Autumn 2008
State Transition MatrixState Transition Matrix
Until now the use of vector ODEs was not very helpful.
We still have special cases 0 AI
axx
0xetx at AXX
0XX Ate
teA => No special cases are needed then
...!3
1!2
1 32 ttte t AAAA Use the command expm (not exp)!
2
1
2
1
52
22
x
x
x
x
52
22A
X(0)=[1 2]
X(5) =?
4 ways to calculate it!!!
Autumn 2008
0XX Ate
iii λeAe
n
nn
1
2121 eeeeeeA
TΛAT 1TΛA
...!3
1
!2
1 31211 ttt TΛTΛTΛ ...!3
1
!2
1 32 ttte t AAAA
1211 TΛTΛTΛ 21TΛ
...!3
1
!2
1 31321211 ttte t TΛTΛTΛTIA
1132 ...!3
1
!2
1
tettt ΛTΛΛΛT
t
t
t
ne
e
e
1
Λ
State Transition MatrixState Transition Matrix
Autumn 2008
00 1XTXX ΛA tt ee
012121
1
XeeeeeeX
nt
t
nne
e
02
1
21
1
X
w
w
w
eeeX
n
t
t
nne
e
n
ii
ti bet i
1
0eX ...00 22211121 xexet tt weweX
n
iii
ti xe i
1
0we
)0(
)0(
)0(
2
1
2
1
21
1
nn
t
t
n
x
x
x
e
e
n
w
w
w
eeeX
State Transition MatrixState Transition Matrix
Autumn 2008
SolutionSolution
buaxxbuaxx
ate txedt
daxxe atat
t
at
a budedxedt
d
00
bue at
t
aat budextxe0
0
t
aatat budeexetx0
0 t
taat budexetx0
0
t
tt deet0
0 BUXX AA
Autumn 2008
SS => TF???SS => TF???
LTttt
)()()( BUAXX )()()0()( ssss BUAXXX
)0()()( 11 XAIBUAIX ssss )0()()( XBUXAI sss
)()()( sss DUCXY )()0()()( 11 sssss DUXAIBUAICY
)0()()( 11 XACUDBACY sIssIs
DBAIC 1s TF
)0(1XAIC s Response to ICs
Autumn 2008
SS => TF???SS => TF???
ILT
ssss )0()()( 11 XAIBUAIX
)0()()( 1111 XAIBUAIX sLssLt
)0()( 11 XAIX sLt
)0()( XX Atet 11 AIA sLe t
DBAICG 1ss AsI CE of the TF AI
BCDAIG
s
ss
The TF is a matrix
)()()(
)()()(
)()()(
)(
21
22221
11211
sGsGsG
sGsGsG
sGsGsG
s
pqpp
q
q
G ...,,, 222
221
1
212
2
111
1
1 GUY
GUY
GUY
GUY
Autumn 2008
Basic properties of state space Basic properties of state space
State space transformations
State space representations are not unique
Same input/output properties, => same eigenvalues
)()()( ttt BUAXX
)()()( ttt DUCXY
TZXT is an invertible matrix
Z is the new state vector
)()( 11 tt BUTAXTZ
XTZ 1
XTZ 1
)(~~
)(11 tt UBZAZBUTATZTZ
ATTA 1~ BTB 1~ )(~~
)( tt UDXCY )()( tt DUCTXY
CTC~DD~
Autumn 2008
Do these two systems have the TF? DBAICG 11 ss DBAICG
~~~~ 12
ss
DBTTAITTCG~111
1 ss
DBAICG 11 ss
DBTTAITCTG~111
1 ss
DBTATICG
~~~ 111 ss
sss 21
1~~~~
GDBAICG
Matlab example
Basic properties of state space Basic properties of state space
Autumn 2008
Observability - Controllability
xy
uxx
3
22
X
XX
03
1
2
10
02
y
uNotice the structure of A and C
2
6223
3
22 1
ss
xy
uxx
X
XX
03
1
2
10
02
y
u
1
2
10
0203
1
s
s
1
22
2
0312
2
1203
12
1
2
20
0103
s
sss
s
s
ss
s
s
2
6
s
Observability - ControllabilityObservability - Controllability
Autumn 2008
There is a pole zero cancellation
0
DC
BAIs
pzmap(ss_model) Matlab verification
The cancellation is due to C=[3 0].
We can influence x2 through U but we cannot observe how it behaves
and hence there is no way to feedback that signal to a controller!!!
0
001
110
202
s
s
001
102
01
100
00
112
sss
101 ss
X
XX
03
1
2
10
02
y
u
2
1
2
1
2
1
03
1
2
10
02
x
xy
ux
x
x
x
1
2
1
3
2
2
1
xy
uxx
uxx
Observability - ControllabilityObservability - Controllability
Autumn 2008
X
XX
03
1
2
10
02
y
u
21
0
2
20
0123
ss
s
s
X
XX
23
0
2
10
02
y
u
2
6
0
2
1
2
2
3
sss
In this case we can see how both states behave but we can not change U in any way so that we can influence x2 due to the form of B.
Unobservable & uncontrollable Unobservable & uncontrollable Minimal realisation.
Difficult task if the system is nonlinear!!!!
Observability - ControllabilityObservability - Controllability