State-space modeling
State Space Introduction
- Introduction
- State Vector
- State Space Model
What is a System ?
Cruise control system Cardio-pulmonary system
Autopilot system
Economic system
Governance system
Grading system
Tropical storm system
Communication system
Complex system
System of systems
Taxation system Cyber-Physical systems Healthcare system
What is a System ? Intuitive defintion
Inputs u(t) Outputs y(t)
Collection of components
Non-trivial interactions
Well defined boundary
with the environment
5
What is a System ?
Inputs u(t) Outputs y(t)
Mapping from time dependent inputs to time dependent outputs
(causal definition)
6
Differential equations
Many phenomena can be expressed by equations which involve the rates of change of quantities (position,
population, concentraition, temperature…) that describe the state of the phenomena.
Economics Chemistry Mechanics
Engineering Social Science Biology
7
The state of a system describes enough information about the
system to determine its future behavior in the absence of any
external inputs affecting the system.
The set of possible combinations of state variable values is called
the state space of the system.
8
Differential equations
The state of the system is characterized by state variables, which describe the system.
The rate of change is (usually) expressed with respect to time
Economics Chemistry Mechanics
Engineering Social Science Biology
9
Differential equations – A simple example
After drinking a cup of coffee, the amount C of caffeine in
person’s body follows the differential equation:
𝑑𝐶
= −𝛼𝐶
𝑑𝑡
Where the constant 𝛼 has a value of 0.14 hour-1
How many hours will it take to metabolize half of the initial amount of caffeine ?
𝑑𝐶
∫ = −𝛼 ∫ 𝑑𝑡 ; 𝐶 𝑡 = 𝐶 0 𝑒 –𝛼𝑡 ; 𝑖𝑓 𝐶 𝑡 = 𝐶0/2, 𝑡 = 𝑙𝑛2⁄𝛼
𝐶
10
Recall: Differential equations
• Ordinary differential equation (ODE): all derivatives are with respect to single independent
variable, often representing time.
• Order of ODE is determined by highest-order derivative of state variable function appearing in
ODE.
• ODE with higher-order derivatives can be transformed into equivalent first-order system.
• Most ODE software's are designed to solve only first-order equations.
11
Higher order ODE’s
12
Inputs change with time ?
What makes a system dynamic ? Outputs change with time ?
USD Euro
$100 €85
$200 €170
Currency Exchange
System
$300 €255
13
Static vs Dynamic Systems
Static System Dynamic System
Output is determined only by the Output takes time to react
current input, reacts
instantaneously Relationship changes with time,
depends on past inputs and initial
Relationship between the inputs conditions (it is dynamic!)
and outputs does not change (it is
static!) Relationship is represented by a
differential equation
Relationship is represented by an
algebraic equation
2 10
Inputs System Outputs
2V 10 rad/sec
Motor
14
Static vs Dynamic Systems
Static System viewpoint Dynamic System viewpoint
500
6
450
400 5
350
4
300
Motor Speed
Motor Torque
250 3
200
2
150
100
1
50
0
0 0 0.5 1 1.5 2 2.5 3
0 0.5 1 1.5 2 2.5 3
Time
Time
15
Dynamical System
Inputs 𝑢(𝑡)
System Output y(t)
Initial State 𝑥0 𝑥
𝑑𝑥
= 𝑥̇ = 𝑓(𝑥 𝑡 , 𝑢 𝑡 , 𝑡)
𝑑𝑡
16
Dynamical System
Possibly a non-linear function
𝑑𝑥
= 𝑥̇ = 𝑓(𝑥 𝑡 , 𝑢 𝑡 , 𝑡)
𝑑𝑡
Rate of change
17
The state 𝑥(𝑡1) at any future time, may be determined exactly given knowledge of
the initial state, 𝑥(𝑡0) and the time history of the inputs, 𝑢(𝑡) between 𝑡0 and 𝑡1
System order: n, min number of states required for the above statement to be true.
Possibly a non-linear function
𝑑𝑥
= 𝑥˙ = 𝑓(𝑥 𝑡 , 𝑢 𝑡 , 𝑡)
𝑑𝑡
Rate of change
18
Inverted pendulum
• Inverted pendulum mounted to a motorized
cart.
• Unstable without control :
• pendulum will simply fall over if the cart isn't
moved to balance it.
Balance the inverted pendulum by applying a
force to the cart on which the pendulum is
attached.
19
Inverted pendulum
20
Inverted pendulum
21
Inverted pendulum
• Initially pendulum begins with 𝜃 = 𝜋
• Requirements:
• Settling time for 𝜃 less than 5 secs.
• Pendulum angle 𝜃 never exceeds 0.05 radians
from the vertical.
22
Inverted pendulum – ODEs
23
Inverted pendulum - – ODEs
24
Inverted pendulum
25
Inverted pendulum - Dynamics
Equations of motion are:
𝐼 + 𝑚𝑙2 ∅̈ + 𝑚𝑔𝑙∅ = 𝑚𝑙𝑥
(𝑀 + 𝑚)𝑥̈ + 𝑏𝑥̇ -𝑚𝑙∅̈ = F
̇
State Vector: X=[𝒙 𝒙̇ ∅ 𝝓]
26
Rearranging – State-Space representation
27
From State-Space to Space..and back
28
From state-space to Space
29
Dynamical System
Possibly a non-linear function
𝑑𝑥
= 𝑥̇ = 𝑓(𝑥 𝑡 , 𝑢 𝑡 , 𝑡)
𝑑𝑡
Rate of change
30
Time invariant system: Simplifying assumption #1
f does not depend on time
𝑑𝑥
= 𝑥̇ = 𝑓(𝑥, 𝑢)
𝑑𝑡
Rate of change • The underlying physical laws themselves do not typically depend on time.
• Inputs u(t) may be time dependent
• The parameters/constants which describe the function f remain the same.
31
Linearity: Simplifying assumption #2
Over a sufficiently small operating range (think tangent line near a curve),
the dynamics of most systems are approximately linear
𝑥̇ = 𝐴𝑥 + 𝐵𝑢
32
State-Space representation
A state-space model represents a system by a series of first-order differential state equations
and algebraic output equations.
Differential equations have been rearranged as a series of first order differential equations.
33
Example
Consider the following system where 𝑢 𝑡 is the input and 𝑥˙(𝑡) is the output.
𝑥⃛ + 5𝑥¨+ 3𝑥˙ + 2𝑥 = 𝑢 , y = 𝑥
Can create a state-space model by pure mathematical manipulation through changing
variables
𝑥1 = 𝑥, 𝑥2 = 𝑥˙, 𝑥3 = 𝑥¨
Resulting in the following three first order differential equations (ODEs)
𝑥1̇ = 𝑥2,
𝑥2̇ = 𝑥3,
𝑥3̇ = −5𝑥3 − 3𝑥2 − 2𝑥1 + 𝑢
34
𝑥1̇ = 𝑥2
State Equations 𝑥2̇ = 𝑥3
𝑥3̇ = −5𝑥3 − 3𝑥2 − 2𝑥1 + 𝑢
Output Equation 𝑦 = 𝑥2
System has 1 input (u), 1 output (y), and 3 state variables (x1, x2, x3)
35
In general state-space models have the following form (equations
can be nonlinear and time varying)
𝑥1̇ = 𝑓1 (𝑥1 , 𝑥2, … , 𝑥 𝑛 , 𝑢1, … , 𝑢 𝑚 )
State Equations :
𝑥𝑛˙ = 𝑓𝑛 (𝑥1 , 𝑥2, … , 𝑥𝑛 , 𝑢1, … , 𝑢 𝑚)
𝑦1 = ℎ1(𝑥1, 𝑥2, … , 𝑥𝑛 , 𝑢1, … , 𝑢 𝑚)
Output Equations :
𝑦𝑛 = ℎ𝑛(𝑥1, 𝑥2, … , 𝑥 𝑛 , 𝑢1, … , 𝑢 𝑚 )
36
State-space representation
𝑥⃑̇ = 𝐴𝑥⃑ + 𝐵𝑢
𝑦 = 𝐶𝑥⃑ + 𝐷𝑢
for linear systems
37
From our prior example
𝑥1̇ = 𝑥2 𝑥1̇ 0 1 0 𝑥1 0
𝑥2̇ = 𝑥3 𝑥2̇ = 0 0 1 𝑥2 + 0 𝑢
𝑥3̇ = −5𝑥3 − 3𝑥2 − 2𝑥1 + 𝑢 𝑥3̇ −2 −3 −5 𝑥3 1
𝑥1
𝑦 = 𝑥2 𝑦 = [0 1 0 ] 𝑥2 + 0 𝑢
𝑥3
38
The State-Space Modeling Process
1) Identify input variables (actuators and exogenous inputs).
2) Identify output variables (sensors and performance variables).
3) Identify state variables. (Hmmm…how ? – indep. energy storage)
4) Use first principles of physics to relate derivative of state variables
to the input, state, and the output variables.
39
Why use state-space representations ?
State-space models:
• are numerically efficient to solve,
• can handle complex systems,
• allow for a more geometric understanding of dynamic systems, and
• form the basis for much of modern control theory
40
Linear dynamical system
Continuous-time linear dynamical system (CT LDS) has the form
𝑥̇ = 𝐴 𝑡 𝑥(𝑡) + 𝐵(𝑡)𝑢(𝑡) 𝑦 = 𝐶 𝑡 𝑥(𝑡) + 𝐷(𝑡)𝑢(𝑡)
41
Continuous-time linear dynamical system (CT LDS)
𝑥̇ = 𝐴 𝑡 𝑥(𝑡) + 𝐵(𝑡)𝑢(𝑡) 𝑦 = 𝐶 𝑡 𝑥(𝑡) + 𝐷(𝑡)𝑢(𝑡)
42
Linear dynamical system
Some terminology
43
Linear dynamical system
Some terminology
44
Linear dynamical system
Some terminology
45
Linear dynamical system
Some terminology
46
Discrete-time linear dynamical system (DT LDS)
𝑥(𝑘 + 1) = 𝐴 𝑘 𝑥(𝑘) + 𝐵(𝑘)𝑢(𝑘)
𝑦(𝑘) = 𝐶 𝑘 𝑥(𝑘) + 𝐷(𝑘)𝑢(𝑘)
47
Many dynamical systems are nonlinear (a fascinating
topic) so why study linear systems?
• Most techniques for nonlinear systems are based on linear systems.
• Methods for linear systems often work unreasonably well, in
practice, for nonlinear systems.
• If you do not understand linear dynamical systems, you certainly
cannot understand nonlinear dynamical systems.
48
Many dynamical systems are nonlinear (a fascinating
topic) so why study linear systems?
“Finally, we make some remarks on why linear systems are so
important. The answer is simple: because we can solve them! ”
- Richard Feynman [Fey63, p. 25-4]
49
Elements of..
50
Modeling Mechanical Systems
Mechanical systems consist of three
basic types of elements:
1. Inertia elements
2. Spring elements
3. Damper elements
51
Vehicle suspension – Mass-spring-damper
52
Inertia elements
• Example: any mass in the system, or moment of
inertia.
• Each inertia element with motion needs its own
differential equation (Newton’s 2nd Law, Euler’s 2nd
law)
F = ma M = J
• Inertia elements store kinetic energy
1
𝐸 = # 𝐹𝑣 𝑑𝑡 = # 𝑚𝑣̇𝑣 𝑑𝑡 = 𝑚𝑣2
2
53
Spring elements F = k(x1 − x2 )
• Force is generated to resist deflection.
• Examples: translational and rotational springs
• Spring elements store potential energy
1 2
𝐸 = # 𝐹𝑣 𝑑𝑡 = # 𝑘𝑥𝑥̇ 𝑑𝑡 = 𝑘𝑥
2
54
Damper elements 𝐹 = 𝑏(𝑥1̇ − 𝑥2̇ )
• Force is generated to resist motion.
• Examples: dashpots, friction, wind drag
• Damper elements dissipate energy
linear damping friction drag
55
How many state variables are required ?
• There is an intuitive way to find state-space models
• What initial conditions do I need to capture the system’s state?
• Definition: the state of a dynamic system is the set of variables (called state variables)
whose knowledge at t = t0 along with knowledge of the inputs for t ≥ t0 completely
determines the behavior of the system for t ≥ t0
• # of state variables = # of independent energy storage elements
56
Example
Equations of motion Choice of state variables
𝑚1𝑦̈ + b 𝑦̇ − 𝑧̇ + k y − z = 0 𝑥1 = 𝑦, 𝑥2 = 𝑦
𝑚2𝑧̈ + b 𝑧̇ − 𝑦̇ + k z − y = u 𝑥3 = 𝑧, 𝑥4 = 𝑧̇
57
Example
Equations of motion Choice of state variables
𝑚1𝑥2̇ + b 𝑥2 − 𝑥4 + k 𝑥1 − 𝑥3 = 0 𝑥1 = 𝑦, 𝑥2 = 𝑦
𝑚2𝑥4̇ + b 𝑥4 − 𝑥2 + k 𝑥3 − 𝑥1 = u 𝑥3 = 𝑧, 𝑥4 = 𝑧˙
58
Example
𝑥˙1 = 𝑥2 0 1 0 0 0
𝑥1˙ –𝑘 –𝑏 𝑘 𝑏 𝑥1
. 𝑥2̇ 𝑥2 0
−b 𝑥2 − 𝑥4 − k 𝑥1 − 𝑥3 = 𝑚1 𝑚1 𝑚1 𝑚1
+
𝑥2 ˙
=
0 0 0 1 𝑥3 0 𝑢
𝑚1 𝑥3̇ 1
𝑥4̇ 𝑘 𝑏 –𝑘 –𝑏 𝑥4
𝑚2
𝑥˙3 = 𝑥4 𝑚2 𝑚2 𝑚2 𝑚2
. 𝑢 − b 𝑥4 − 𝑥2 − k 𝑥3 − 𝑥1
𝑥4 ˙=
𝑚2 Is this the minimum
set of states ?
59
Example
Look at where energy is stored
Energy Storage Element State Variable
spring (stores elastic PE) 𝑥1 = (𝑦 − 𝑧)
mass 1 (stores KE) 𝑥2 = 𝑦̇
mass 2 (stores KE) 𝑥3 = 𝑧̇
damper does not store energy, it dissipates energy
60
Example 𝑚1 𝑦¨+ b 𝑦˙ − 𝑧˙ + k y − z = O
𝑚2 𝑧¨+ b 𝑧˙− 𝑦˙ + k z − y = u
𝑥1̇ = 𝑥2 − 𝑥3
𝑥1 = (𝑦 − 𝑧) 1
𝑥2̇ = 𝑦¨ = −𝑏 𝑥2 − 𝑥3 − 𝑘𝑥1
𝑥2 = 𝑦˙ 𝑚1
𝑥3 = 𝑧˙ 1
Rewriting in state-space 𝑥3˙ = 𝑧¨ = −𝑏 𝑥3 − 𝑥2 + 𝑘𝑥1 + 𝑢
representation 𝑚2
61
Example
𝑥1̇ = 𝑥2 − 𝑥3
0 1 −1 0
1 𝑥1˙ –𝑘 –𝑏 𝑏 𝑥1
𝑥2̇ = 𝑦¨ = −𝑏 𝑥2 − 𝑥3 − 𝑘𝑥1 0
𝑚1 𝑥2̇ = 𝑚1 𝑚1 𝑚1 𝑥2 + 𝑢
1
1 𝑥3̇ 𝑘 𝑏 –𝑏 𝑥3
𝑚2
𝑥3̇ = 𝑧¨ = −𝑏 𝑥3 − 𝑥2 + 𝑘𝑥1 + 𝑢 𝑚2 𝑚2 𝑚2
𝑚2
62
Modeling electrical systems
Passive elements Active elements
Capacitor Inductor Resistor Voltage source
[storage] [storage] [dissipative]
Current source
63
Mechanical – Electrical equivalency
We recognize a common form to the ODE describing each system and create analogs in
the various energy domains, for example:
64
Capacitor - Mass
Describing Equation Energy
Electrical Capacitance
1
q = CV i Cd v 21 E Mv 212
dt 2
Translational Mass
1
Md v2
2
F E Mv 2
dt 2
65
Inductor - Spring
Electrical Inductance Describing Equation Energy
v21 Ld i E
1 2
Li
dt 2
Translational Spring
2
1 d 1 F
v21 F E
k dt 2 k
66
Resistor - Damper
Electrical Resistance Describing Equation Energy
1 1 2
i v 21 P v 21
R R
Translational Damper
F bv21 P bv212
67
Generalized system representation.
Effort
Flow
System
68
𝑃𝑜𝑤𝑒𝑟 = 𝑇ℎ𝑟𝑜𝑢𝑔ℎ 𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒 × 𝐴𝑐𝑟𝑜𝑠𝑠 𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒
Across variable
Through variable
System
69
𝑃𝑜𝑤𝑒𝑟 = 𝑇ℎ𝑟𝑜𝑢𝑔ℎ 𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒 × 𝐴𝑐𝑟𝑜𝑠𝑠 𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒
Power is voltage times current 𝑃 = 𝑖× 𝑉
Power is velocity times force 𝑃 = 𝐹× 𝑣
70
𝑃𝑜𝑤𝑒𝑟 = 𝑇ℎ𝑟𝑜𝑢𝑔ℎ 𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒 × 𝐴𝑐𝑟𝑜𝑠𝑠 𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒
Through variables:
• Variables that are measured through an element.
• Variables sum to zero at the nodes on a graph/circuit/free body diagram.
• Variables that are measured with a gauge connected in series to an element.
71
𝑃𝑜𝑤𝑒𝑟 = 𝑇ℎ𝑟𝑜𝑢𝑔ℎ 𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒 × 𝐴𝑐𝑟𝑜𝑠𝑠 𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒
Across variables:
• Variables that are defined by measuring a difference, or drop, across an element,
that is between nodes on a graph (across one or more branches).
• Variables sum to zero around any closed loop on the graph
• Variables that are measured with a gauge connected in parallel to an element.
72
𝑃𝑜𝑤𝑒𝑟 = 𝑇ℎ𝑟𝑜𝑢𝑔ℎ 𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒 × 𝐴𝑐𝑟𝑜𝑠𝑠 𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒
73
Energy storage : A-Type elements
Stored energy is a function of the Across-variable.
74
Generalized, Capacitance
75
Energy storage: T-Type elements
Stored energy is a function of the Through-variable.
76
Generalized inductance, L
77
Dissipative elements : D-Type
Dissipative elements (non-energy storage)
78
Generalized resistance, R
79
Cyber-Physical Energy Systems Modeling
Thermal Capacitance
q Ctd T2 E CtT2
dt
Thermal Resistance
1 1
q T 21 P T 21
Rt Rt
80