DynamicSystems ModelingSimulation VB Part1
DynamicSystems ModelingSimulation VB Part1
Control 1
Modeling
,
and Simulation
Control Design
Requirement Requirement
Analysis Specifications
Modeling & Simulation
Classification of models
● Static/Dynamic
𝑑
– Static: time derivative 𝑑𝑡=0
– Dynamic: function of time
In control, the model must be dynamic to represent the rate change of the variables
as a function of time
● Deterministic/Probabilist
– Deterministic: variables known anytime with no randomness
– Probabilist: a probability distribution describes the uncertainties and variations
of the system variables
● Continuous/Discrete
– variables known at every point in time
– variables known at every sampling time
● Mathematical/Physical
– Model described by coefficients with no physical meaning (black box)
– Physical model (based on convervative laws or physical fundamental laws )
Classical modeling methods for physical models
Note: most examples of this course can be found in Control Engineering: A Modern Approach by P. Belanger,
Ed. Oxford University Press
Modeling methodologies
The conservation law of energy states that the total quantity of energy in an
isolated system does not change .
But its nature may change !
Example of conservative principles
Kirchoff’s laws
Motion of a fluid
• Conservation of the mass
𝝏𝝆
+ 𝐝𝐢𝐯𝝆𝒗 = 𝟎
𝝏𝒕
with 𝝆: density and 𝒗: fluid velocity
𝟏
Note: 𝒗. 𝛁 𝒗 = 𝛁 𝒗 𝟐
+ 𝒓𝒐𝒕𝒗Λ𝒗
𝟐
Example of conservative principles
● First law:
Every object will remain at rest or in uniform motion in a straight line unless forced to
change its state by the action of an external force
● Second law:
Force 𝑭 is equal to change in momentum 𝒑 (mass times velocity) per change in time.
For an object with a constant mass m, force 𝑭 is the product of an object's mass
and its acceleration 𝒂
𝒅𝒑 𝒅(𝒎𝒗)
𝑭= = = 𝒎𝒂
𝒅𝒕 𝒅𝒕
● Third law:
For every action (force) in nature there is an equal and opposite reaction.
if object A exerts a force on object B, then object B exerts an equal force of
opposite direction on object A.
Modeling from fundamental physic laws
● Translation motion:
Force is equal to change in momentum (mass times velocity 𝑝Ԧ = 𝑚𝑣)
Ԧ per change in
time.
𝒅𝒑 𝒅𝒗
𝑭= =𝒎 = 𝒎𝒂
𝒅𝒕 𝒅𝒕
● Rotational motion:
Torque is equal to change in angular momentum (inertia moment times angular
velocity 𝜏Ԧ = 𝐼Ω) per change in time.
𝒅𝝉 𝒅𝛀
𝑻= =𝑰
𝒅𝒕 𝒅𝒕
Example of fundamental physic laws
Te
NTe
Jm
Example of fundamental physic laws and
conservative laws
Electromechanical actuator connected to a load:
electrical equation
𝒗 𝒆𝒎𝒇
Examples of fundamental physic laws
Aircraft model
Notation:
m: aircraft mass
𝚪: acceleration
𝑽: linear speed
𝛀: rotation speed
𝑴: angular momentum
𝑭𝒘 : gravity force
𝑭𝒂𝒆 and 𝑴𝒂𝒆 : aerodynamic forces and couples
𝑭𝑷 and 𝑴𝑷 : propulsion forces and couples
𝚯, 𝝋 𝐚𝐧𝐝 𝝍: euler angles (yaw, pitch, roll)
𝜶: incidence angle
Examples of fundamental physic laws
Aircraft model
Force equations:
𝒎𝚪 = 𝑭𝒘 + 𝑭𝒂𝒆 + 𝑭𝑷
Moment equations:
𝑴ሶ + 𝛀Λ𝑴 = 𝑴𝒂𝒆 + 𝑴𝑷
Kinematic equations:
𝚪 = 𝑽ሶ + 𝛀Λ𝑽
with
𝟏
𝑭𝒂𝒆 = − 𝟐 𝝆 𝒛 𝑺𝑽𝟐 𝑪𝑭
𝟏
𝑴𝒂𝒆 = − 𝝆 𝒛 𝑺𝑳𝑽𝟐 𝑪𝑴
𝟐
and
𝝆 𝒛 : air density, S: aircraft reference surface, L: aircraft reference length
𝑪𝑭 and 𝑪𝑴 : aerodynamic coefficients
Modeling with Lagrange’s Equations
Lagrange’s equations are a powerful tool for modeling systems. The approach is based
on the computation of energy.
𝒒ሶ 𝒊 − 𝑽(𝒒𝒊 )
𝑳 = 𝑻 𝒒𝒊 , 𝑹
with
𝑻: kinetic energy
𝑽: potential energy
Linear case:
Analysis Analysis
in the frequency domain in the time-domain
𝑑𝑓 1 𝑑²𝑓 1 𝑑3 𝑓 3
𝑓 𝑥 = 𝑓 𝑥0 + ቚ 𝑥 − 𝑥0 + ቚ 𝑥− 𝑥0 ²+ 3ቚ 𝑥 − 𝑥0 +…
𝑑𝑥 𝑥0 2 𝑑𝑥² 𝑥0 6 𝑑𝑥 𝑥0
Some definitions:
nc nk
ak + bk s
ci
G( s) = +
i =1
s + pi k =1 s 2 + 2 k nk s + n2k
Frequency domain analysis
from transfer function
BODE plot:
- magnitude plot: GdB = 20Log10 ( F( jw ) )
- phase plot: f = arg(F( jw ))
NICHOLS plot:
Parametric curve scaled according to :
20Log10 ( F( jw ) ) = f (arg(F( jw )))
NYQUIST plot:
Parametric curve scaled according to :
Im(F( jw )) = f (Re(F( jw ))
Example of frequential analysis
𝐾 𝐾
𝐻 𝑠 = 𝑠 𝐻 𝑗𝜔 = 𝑗𝜔
1+𝜔 1+𝜔
0 0
𝐾
𝑔𝑎𝑖𝑛 = |𝐻 𝑗𝜔 | =
𝜔2
1+ 2
𝜔0
𝐾 𝜔2
|𝐻 𝑗𝜔 |𝑑𝐵 = 20𝑙𝑜𝑔 =20log(K)-10log(1 + )
𝜔2
𝜔02
1+ 2
𝜔0
𝜔
phase (𝐻 𝑗𝜔) = −atan( )
𝜔0
Example of frequential analysis
𝐾
𝐻 𝑠 =
2𝜀𝑠 𝑠2
1+ 𝜔 +
0 𝜔²0
𝑔𝑎𝑖𝑛 = |𝐻 𝑗𝜔 |
𝐾
=
2 2
𝜔 2 2𝜀𝜔
1− 2 + 𝜔
𝜔0 0
2𝜀𝜔
𝜔0
phase (𝐻 𝑗𝜔) = −atan
𝜔2
1− 2
𝜔0
Example of frequential analysis
1 1
𝐻 𝑠 = 𝑠
1 + 10 1 + 2 ∗ 0.7 𝑠 + 𝑠²
100 100²
𝒅𝒊
𝑳 𝒅𝒕 + 𝑹𝒊 = 𝒗 − 𝒌𝒆 𝑵𝝎 𝑳𝒔𝒊 + 𝑹𝒊 = 𝒗 − 𝒌𝒆 𝑵𝝎
𝒗−𝒌𝒆 𝑵𝝎
𝒊= 𝑳𝒔+𝑹
State-space representation
State equations
𝑑𝑦 𝑛 𝑡 𝑑𝑦 𝑘 𝑡
𝑎𝑛 + ⋯ +𝑎𝑘 + ⋯ + 𝑎0 𝑦 𝑡 = 𝑢(𝑡)
𝑑𝑡 𝑛 𝑑𝑡𝑘
𝑡 is “continuous time”
● Question:
Can we write this equation as a set of first-order differential equations?
State equations
Example: Mass moving at the speed 𝑣 under the influence of an external force 𝐹 against a
friction force 𝑘 ∗ 𝑣
𝑑𝑣 𝑑𝑥
𝑀 = 𝐹 − 𝑘 ∗ 𝑣 with =𝑣
𝑑𝑡 𝑑𝑡
𝑑2 𝑥 𝑑𝑥
𝑀 =𝐹−𝑘∗ 1 equation of order 2
𝑑𝑡² 𝑑𝑡
𝑥(𝑡)
ሶ = 𝑓(𝑥, 𝑢, 𝑡)
𝑦(𝑡) = ℎ(𝑥, 𝑢, 𝑡)
𝑥(𝑡) is a state vector for the system S if it is a vector containing the minimum
number of variables required to satisfy the following property:
If, at a given instant t0, x0(t) is known, then y(t1) and x(t1) can be uniquely determined
for all t1>t0 if u(t) is known on the interval [t0 t1].
u y
Input vector Output vector
System S
x state vector
State space representation: linear system
𝑥(𝑡)
ሶ = 𝐴 𝑡 𝑥(𝑡) + 𝐵 𝑡 𝑢(𝑡)
𝑦(𝑡) = 𝐶 𝑡 𝑥(𝑡) + 𝐷 𝑡 𝑢(𝑡)
If the system is linear and the matrices are constant, the system is linear time-
invariant (LTI).
𝑥(𝑡)
ሶ = 𝐴𝑥(𝑡) + 𝐵𝑢(𝑡)
𝑦(𝑡) = 𝐶𝑥(𝑡) + 𝐷𝑢 (𝑡)
Example of linear state-space representation
𝑵 𝟏
𝑱𝒆 𝝎ሶ = 𝑵𝒌𝒎 𝒊 − 𝑻𝑳 𝝎ሶ = 𝑱 𝒌𝒎 𝒊 − 𝑱 𝑻𝒍
𝒆 𝒆
𝒅𝒊 𝒅𝒊 𝑹 𝟏 𝒌𝒎 𝑵
𝑳 + 𝑹𝒊 = 𝒗 − 𝒌𝒎 𝑵𝝎 = − 𝒊+ 𝒗− 𝝎
𝒅𝒕 𝒅𝒕 𝑳 𝑳 𝑳
𝒅 𝝎 𝝎 𝒗
= + 𝑻𝒍
𝒅𝒕 𝒊 𝒊
𝝎
If 𝝎 is the output, 𝒀 =
𝒊
Example of linear state-space representation
𝑵 𝟏
𝑱𝒆 𝝎ሶ = 𝑵𝒌𝒎 𝒊 − 𝑻𝑳 𝝎ሶ = 𝑱 𝒌𝒎 𝒊 − 𝑱 𝑻𝒍
𝒆 𝒆
𝒅𝒊 𝒅𝒊 𝑹 𝟏 𝑵𝒌𝒆
𝑳 𝒅𝒕 + 𝑹𝒊 = 𝒗 − 𝑵𝒌𝒆 𝝎 𝒅𝒕 = − 𝑳 𝒊 + 𝑳 𝒗 − 𝝎
𝑳
𝒅 𝜽 𝜽 𝒗
𝝎 = 𝝎 + 𝑻𝒍
𝒅𝒕
𝒊 𝒊
𝜽
If 𝜽 is the output, 𝒀 = 𝝎
𝒊
Non uniqueness of state space representation
𝑵 𝟏
𝝎ሶ = 𝒌𝒎 𝒊 − 𝑻𝒍
𝑱𝒆 𝑱𝒆
𝒅𝒊 𝑹 𝟏 𝑵
= − 𝒊 + 𝒗 − 𝒌𝒆 𝝎
𝒅𝒕 𝑳 𝑳 𝑳
𝑻𝒎 = 𝒌𝒎 𝒊
𝟎 𝟏 𝟎 𝟎 𝟎
𝜽 𝑵𝒌𝒎 𝜽 𝒗
𝒅 𝟎 𝟎 −𝟏
1° state-space representation:
𝒅𝒕
𝝎 = 𝑱𝒆 𝝎 + 𝟎
𝟏 𝑱𝒆 𝑻𝒍
𝒊 𝑵𝒌𝒆 𝑹 𝒊
𝟎 − − 𝑳 𝟎
𝑳 𝑳
𝑵𝒌𝒆 𝑹
𝒊 𝟎 − − 𝒊
𝟏 𝟎
𝑳 𝑳 𝒗
𝒅 𝑳 −𝟏
2° state-space representation: 𝝎 = 𝟎 𝟎
𝑵𝒌𝒎 𝝎 + 𝟎 𝑱 𝑻
𝒅𝒕 𝒆 𝒍
𝜽 𝑱𝒆 𝜽
𝟎 𝟏 𝟎 𝟎 𝟎
𝟎 𝟏 𝟎
𝜽 𝑵 𝜽 𝟎 𝟎
𝒅 𝟎 𝟎 −𝟏 𝒗
3° state-space representation: 𝝎 = 𝑱𝒆 𝝎 + 𝟎 𝑱 𝑻
𝒅𝒕 𝒌𝒎 𝒆 𝒍
𝑻𝒎 𝑵𝒌 𝒌 𝑹𝒌𝒎 𝑻𝒎
𝟎 − 𝒆 𝒎 − 𝑳 𝟎
𝑳 𝑳
Example of nonlinear state-space representation
We define 𝑿 = 𝒙 𝜽 𝒗 𝝎 𝒕
𝑥ሶ = 𝑣
𝜃ሶ = 𝜔 𝑿ሶ = 𝒇 𝑿, 𝑭
𝐹 + 𝑚𝑙𝜔2 sin 𝜃 − 𝑚𝑔 sin 𝜃 cos 𝜃 𝐘 = 𝒈 𝑿, 𝑭
𝒙ሷ = 𝑣ሶ =
𝑀 + 𝑚(1 − 𝑐𝑜𝑠 2 𝜃)
−𝐹 cos 𝜃 − 𝑚𝑙𝜔2 sin 𝜃 cos 𝜃 + 𝑀 + 𝑚 𝑔 sin 𝜃
𝜃ሷ = 𝜔ሶ =
𝑙(𝑀 + 𝑚 1 − 𝑐𝑜𝑠 2 𝜃 )
Linearization
𝒄 𝑭
𝒍ሶ = − 𝑨 𝒖 𝒍 + 𝑨𝒊𝒏 = 𝒇(𝒍, 𝒖, 𝑭𝒊𝒏 )
Compute u*
𝑐 𝐹∗𝑖𝑛 𝐹𝑑
− 𝐴 𝑢 ∗ 𝑙𝑑 + =0 𝑢 ∗=
𝐴 𝑐 𝑙𝑑
Compute
𝜕𝑓 𝑐 𝜕𝑓 𝑐 𝜕𝑓 1
𝜕𝑙
= − 2𝐴 𝑙 𝑢 𝜕𝑢
= −𝐴 𝑙 𝜕𝐹𝑖𝑛
=𝐴
Linearized model
𝒄𝒖∗ 𝒄 𝟏
∆𝒍ሶ = − ∆𝒍 − 𝑨 𝒍𝒅 ∆𝒖 + 𝑨 ∆𝑭𝒊𝒏
𝟐𝑨 𝒍𝒅
Linearization: Jacobian of matrices
For small deviations, expanding the components of 𝑓 and 𝑔 in a Taylor series, we get
the linearized system:
𝛿𝑓 𝛿𝑓
Δ𝑥ሶ = ቤ Δ𝑥 + ቤ Δ𝑢
𝛿𝑥 𝑥=𝑥∗ 𝛿𝑢 𝑢=𝑢∗
𝛿𝑔 𝛿𝑔
Δ𝑦ሶ = ቤ Δ𝑥 + ቤ Δ𝑢
𝛿𝑥 𝑦=𝑦∗ 𝛿𝑢 𝑢=𝑢∗
where
𝛿𝑓
ቚ is the Jacobian of 𝑓 with respect to 𝑥
𝛿𝑥 𝑥=𝑥∗
𝛿𝑔
ቚ is the Jacobian of 𝑔 with respect to 𝑥
𝛿𝑥 𝑥=𝑥∗
𝛿𝑓
ቚ is the Jacobian of 𝑓 with respect to 𝑢
𝛿𝑢 𝑢=𝑢∗
𝛿𝑔
ቚ is the Jacobian of 𝑔 with respect to 𝑢
𝛿𝑢 𝑢=𝑢∗
Example of linearization
𝑥ሶ = 𝑣
𝜃ሶ = 𝜔
𝐹+𝑚𝑙𝜔2 sin 𝜃−𝑚𝑔 sin 𝜃 cos 𝜃
𝑥ሷ = 𝑣ሶ =
𝑀+𝑚(1−𝑐𝑜𝑠 2 𝜃)
−𝐹 cos 𝜃−𝑚𝑙𝜔2 sin 𝜃 cos 𝜃+ 𝑀+𝑚 𝑔 sin 𝜃
𝜃ሷ = 𝜔ሶ = 𝑙(𝑀+𝑚 1−𝑐𝑜𝑠 2 𝜃 )
𝐶
𝐶𝐴
𝑟𝑎𝑛𝑘 𝑂 = 𝑟𝑎𝑛𝑘 =𝑛
𝐶𝐴𝑛−1
𝑂 is called observability matrix.
Controllability
An LTI system is controllable if, for every 𝑥𝑡 , there exists an input function 𝑢 𝑡 such
that the system state is taken from 𝑥0 to 𝑥𝑡 between 0 and 𝑡.
The controllability allows the state to get any desired value.
The concept of controllability indicates if the actuators can control the state of the
system. If a state is uncontrollable, the it cannot be altered by the input 𝑢.
𝑥(𝑡)
ሶ = 𝐴𝑥(𝑡) + 𝐵𝑢(𝑡)
𝑦(𝑡) = 𝐶𝑥(𝑡)
And let apply the Laplace transform:
𝑠𝐼𝑋 𝑠 − 𝑥 0 = 𝐴𝑋 𝑠 + 𝐵𝑈 𝑠
𝑌 𝑠 = 𝐶𝑋(𝑠)
Solve and get:
𝑋 𝑠 = 𝑠𝐼 − 𝐴 −1 𝐵𝑈 𝑠 + 𝑠𝐼 − 𝐴 −1 𝑥(0)
𝑌 𝑠 = 𝐶 𝑠𝐼 − 𝐴 −1 𝐵𝑈 𝑠 + 𝐶 𝑠𝐼 − 𝐴 −1 𝑥(0)
𝑌 𝑠 −1 𝐵
𝑇 𝑠 = = 𝐶 𝑠𝐼 − 𝐴
𝑈 𝑠
Link Transfer function – State-space
representation
𝑌 𝑠 −1
𝑇 𝑠 = = 𝐶 𝑠𝐼 − 𝐴 𝐵
𝑈 𝑠
The order of the LTI model is the highest degree of the characteristic polynomial.
It is egal to the number of states of the model.
Time-domain analysis
from state space representation
𝑥(𝑡)
ሶ = 𝐴𝑥(𝑡) + 𝐵𝑢(𝑡) x(t ) = e A ( t −t 0 )
x(t0 ) + e A(t − ) Bu ( )d
t0
Starting from:
𝑥ሶ 𝑡 = 𝐴𝑥(𝑡) + 𝐵𝑢(𝑡)
We get:
e𝑒−−𝐴𝑡
At
x (𝑥t )ሶ = − At −𝐴𝑡
𝑡 e= + Bu (t ))+ 𝐵𝑢(𝑡)
𝑒( Ax(t) 𝐴𝑥(𝑡)
− At
𝑒e−𝐴𝑡 ( x𝑥(tሶ )𝑡− Ax t )) = e − At=Bu𝑒(−𝐴𝑡
− (𝐴𝑥(𝑡) t ) 𝐵𝑢(𝑡)
t
d − At x(t ) = e A ( t −t 0 )
x(t0 ) + e A(t − ) Bu ( )d
[e x(t )] = e − At Bu (t )
dt t0
t t
d − A − A
d [e x( )]d = e Bu( )d
t0 t0
Initial condition response Particular solution
t
e − At x(t ) − e − At 0 x(t0 ) = e − A Bu ( )d
t0
Transfer function vs state space representation
b0 + b1s + ... + bm s m N ( p)
F ( p) = =K
a0 + a1s + ... + an s n
D( p ) initial conditions : x(0) = x0
non uniqueness of state space representation:
poles : pi such than D ( pi ) = 0
x = Mx˜
zeros : zi such that N ( zi ) = 0
𝑱𝒕 𝝎ሶ = 𝑵𝒌𝒎 𝒊
𝒅𝒊
𝑳𝒆 𝒅𝒕 + 𝑹𝒆 𝒊 = 𝒗 − 𝒌𝒆 𝑵𝝎
Block diagram:
example of a nonlinear system
Differential equation
1
𝜃ሷ = (Γ −mgl sinθ − kl𝜃)ሶ
m𝑙2
Block diagram
𝜃ሷ 𝜃ሶ 𝜃
Block diagram:
State space representation of linear invariant system
X Y
U
B C
A
𝑥(𝑡)
ሶ = 𝐴𝑥(𝑡) + 𝐵𝑢(𝑡)
𝑦(𝑡) = 𝐶𝑥(𝑡) + 𝐷𝑢 (𝑡)
D
Simulation from bloc diagrams is based on causality: inputs are chosen when
implementing the model and the outputs are computed for defined inputs .
Outputs are consequences or effects of inputs (causes).
Matlab/ Simulink ® simulation program only deals with causal models: the model is
defined by mean of assignments (block diagram have an input and an output).
Causal Acausal
Model Model
● Origin of uncertainties:
– Unmodelled (usually high-frequency) dynamics
– nonlinearities in the modelling
– effects of deliberate reduced-order models,
– system-parameter variations due to environmental changes and system wear
Modeling of uncertainties
● Example:
Model of a mass-stiffner-damper system
𝑚𝑥ሷ + 𝑐 𝑥ሶ + 𝑘𝑥 = 𝑓
with 𝑚 , 𝑐, 𝑘 : mass, damping constant and spring stiffness
Model with uncertainties
𝑚𝑂 + 𝛿𝑚 𝑥ሷ + 𝑐0 + 𝛿𝑐 𝑥ሶ + 𝑘0 + 𝛿𝑘 𝑥 = 𝑓
with 𝑚𝑂 , 𝑐0 ,𝑘0 : nominal parameter values
Modeling of uncertainties
Unstructured uncertainties
𝑦 = 𝑥1
Block diagram:
representation of structured uncertainties
d1, d2 and d3 are the signals coming out from the perturbation blocks
𝑑1 = 𝛿𝑚 𝑧1 ; 𝑑2 = 𝛿𝑐 𝑧2 ; 𝑑3 = 𝛿𝑘 𝑧3