State-space modeling using first -principles · 2 days ago · State-space modeling using first...

83
State-space modeling using first-principles Lecture 2 Principles of Modeling for Cyber-Physical Systems Instructor: Madhur Behl Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 1

Transcript of State-space modeling using first -principles · 2 days ago · State-space modeling using first...

Page 1: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

State-space modeling using first-principles

Lecture 2

Principles of Modeling for Cyber-Physical Systems

Instructor: Madhur Behl

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 1

Page 2: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Download Matlab

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 2

Campus-wide license for MATLAB, Simulink, and companion toolboxes

https://www.mathworks.com/academia/tah-portal/university-of-virginia-40704757.html(or search for UVA Matlab portal)

Contact [email protected] for questions regarding access to Matlab licenses.

Page 3: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

In today’s lecture we will learn about…

How to predict the future !

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 4

Page 4: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

In today’s lecture we will learn about…

How to predict the future states and outputs of systems using physics based mathematical modeling

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 5

Page 5: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

In today’s lecture we will learn about…

• Ordinary differential equations (ODEs).• Linear dynamical systems• State-space representation• Elements of first-principles based modeling:

• Mechanical and electrical modeling

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 6

Page 6: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

What is a System ?

Cruise control systemAutopilot system

Taxation system

Cardio-pulmonary system

Economic system

Communication system

Governance system

Healthcare system

Tropical storm systemGrading system

Complex system

System of systems

Cyber-Physical systems

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 7

Page 7: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

What is a System ? Intuitive defintion

Non-trivial interactions

Collection of components

Well defined boundary with the environment

Inputs u(t) Outputs y(t)

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 8

Page 8: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

What is a System ?

Mapping from time dependent inputs to time dependent outputs

Inputs u(t) Outputs y(t)

(causal definition)

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 9

Page 9: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Differential equationsMany 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

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 10

Page 10: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

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.

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 11

Page 11: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Differential equationsThe 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

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 12

Page 12: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

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, 𝑑𝑑 = ⁄𝑙𝑙𝑙𝑙𝑙 𝛼𝛼

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 13

Page 13: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 14

Differential equations –example

Page 14: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

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.

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 15

Page 15: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Higher order ODE’s

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 16

Page 16: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

What makes a system dynamic ?

Currency ExchangeSystem

USD Euro

$100 €85

$200 €170

$300 €255

Inputs change with time ?

Outputs change with time ?

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 17

Page 17: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Static vs Dynamic Systems

Output is determined only by the current input, reacts instantaneously

Relationship between the inputs and outputs does not change (it is static!)

Relationship is represented by an algebraic equation

Output takes time to react

Relationship changes with time, depends on past inputs and initial conditions (it is dynamic!)

Relationship is represented by a differential equation

Static System Dynamic System

SystemInputs Outputs2 10

2V 10 rad/sec

Motor

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 18

Page 18: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Static vs Dynamic Systems

Static System viewpoint Dynamic System viewpoint

0 0.5 1 1.5 2 2.5 30

50

100

150

200

250

300

350

400

450

500

Mot

or S

peed

Time

0 0.5 1 1.5 2 2.5 30

1

2

3

4

5

6

Mot

or T

orqu

e

Time

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 19

Page 19: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Dynamical System

SystemInputs

Output y(t)Initial State

𝑑𝑑𝑥𝑥𝑑𝑑𝑑𝑑

= ��𝑥 = 𝑖𝑖(𝑥𝑥 𝑑𝑑 ,𝑢𝑢 𝑑𝑑 , 𝑑𝑑)

𝑥𝑥𝑥𝑥0

𝑢𝑢(𝑑𝑑)

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 20

Page 20: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Dynamical System

𝑑𝑑𝑥𝑥𝑑𝑑𝑑𝑑

= ��𝑥 = 𝑖𝑖(𝑥𝑥 𝑑𝑑 ,𝑢𝑢 𝑑𝑑 , 𝑑𝑑)

Rate of change

Possibly a non-linear function

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 21

Page 21: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

𝑑𝑑𝑥𝑥𝑑𝑑𝑑𝑑

= ��𝑥 = 𝑖𝑖(𝑥𝑥 𝑑𝑑 ,𝑢𝑢 𝑑𝑑 , 𝑑𝑑)

Rate of change

Possibly a non-linear function

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.

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 22

Page 22: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

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.

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 23

Page 23: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Inverted pendulum

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 24

Page 24: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Inverted pendulum

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 25

Page 25: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

• Initially pendulum begins with 𝜃𝜃 = 𝜋𝜋• Requirements:

• Settling time for 𝜃𝜃 less than 5 secs.• Pendulum angle 𝜃𝜃 never exceeds 0.05 radians

from the vertical.

.

Inverted pendulum

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 26

Page 26: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

𝑀𝑀��𝑥 + 𝑏𝑏��𝑥 + N = FForces in the horizontal direction

𝑁𝑁 = 𝑚𝑚��𝑥 + 𝑚𝑚𝑙𝑙��𝜃 cos 𝜃𝜃 −𝑚𝑚𝑙𝑙2��𝜃2 sin𝜃𝜃Reaction force N:

Governing equation (1) of this system: Horizontal

(𝑀𝑀 + 𝑚𝑚)��𝑥 + 𝑏𝑏��𝑥 + 𝑚𝑚𝑙𝑙��𝜃 cos 𝜃𝜃 −𝑚𝑚𝑙𝑙2��𝜃2 sin𝜃𝜃 = F

Inverted pendulum – ODEs

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 27

Page 27: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

−𝑃𝑃𝑙𝑙 sin𝜃𝜃 − 𝑁𝑁𝑙𝑙 cos 𝜃𝜃 = 𝐼𝐼��𝜃Get rid of the P and the N terms:(moment balance equation)

Governing equation (2) of this system: Vertical

𝐼𝐼 + 𝑚𝑚𝑙𝑙2 ��𝜃 + 𝑚𝑚𝑚𝑚𝑙𝑙 sin𝜃𝜃 = −𝑚𝑚𝑙𝑙��𝑥 cos 𝜃𝜃

𝑃𝑃 sin𝜃𝜃 + Ncos 𝜃𝜃 −𝑚𝑚𝑚𝑚 sin𝜃𝜃 = ml��𝜃 + 𝑚𝑚��𝑥 cos 𝜃𝜃

Forces in the vertical direction:

Inverted pendulum - – ODEs

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 28

Page 28: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

cos 𝜋𝜋 + ∅ ≈ −1

Assuming that the system remains within a small neighborhood of the equilibrium𝜃𝜃 = 𝜋𝜋For small deviations ∅:

sin 𝜋𝜋 + ∅ ≈ −∅

��𝜃2 = ∅2 ≈ 0

Inverted pendulum

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 29

Page 29: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Equations of motion are:

𝐼𝐼 + 𝑚𝑚𝑙𝑙2 ∅ + 𝑚𝑚𝑚𝑚𝑙𝑙∅ = 𝑚𝑚𝑙𝑙��𝑥

(𝑀𝑀 + 𝑚𝑚)��𝑥 + 𝑏𝑏��𝑥 -𝑚𝑚𝑙𝑙∅ = F

Inverted pendulum - Dynamics

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 30

Page 30: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Rearranging – State-Space representation

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 31

Page 31: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

From State-Space to Space..and back

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 32

Page 32: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

From state-space to Space

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 33

Page 33: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Dynamical System

𝑑𝑑𝑥𝑥𝑑𝑑𝑑𝑑

= ��𝑥 = 𝑖𝑖(𝑥𝑥 𝑑𝑑 ,𝑢𝑢 𝑑𝑑 , 𝑑𝑑)

Rate of change

Possibly a non-linear function

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 34

Page 34: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Time invariant system: Simplifying assumption #1

𝑑𝑑𝑥𝑥𝑑𝑑𝑑𝑑

= ��𝑥 = 𝑖𝑖(𝑥𝑥,𝑢𝑢)

Rate of change

f does not depend on time

• 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.

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 35

Page 35: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Linearity: Simplifying assumption #2

��𝑥 = 𝐴𝐴𝑥𝑥 + 𝐵𝐵𝑢𝑢

Over a sufficiently small operating range (think tangent line near a curve), the dynamics of most systems are approximately linear

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 36

Page 36: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

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.

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 37

Page 37: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

ExampleConsider the following system where 𝑢𝑢 𝑑𝑑 is the input and ��𝑥(𝑑𝑑) is the output.

𝑥𝑥 + 5��𝑥 + 3��𝑥 + 𝑙𝑥𝑥 = 𝑢𝑢 , 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 + 𝑢𝑢

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 38

Page 38: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

𝑥𝑥1 = 𝑥𝑥2𝑥𝑥2 = 𝑥𝑥3

��𝑥3 = −5𝑥𝑥3 − 3𝑥𝑥2 − 2𝑥𝑥1 + 𝑢𝑢State Equations

𝑦𝑦 = 𝑥𝑥2Output Equation

System has 1 input (u), 1 output (y), and 3 state variables (x1, x2, x3)

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 39

Page 39: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

State-space representation

𝑥𝑥 = 𝐴𝐴��𝑥 + 𝐵𝐵𝑢𝑢

𝑦𝑦 = 𝛼𝛼��𝑥 + 𝐷𝐷𝑢𝑢

for linear systems

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 40

Page 40: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

From our prior example

𝑥𝑥1 = 𝑥𝑥2𝑥𝑥2 = 𝑥𝑥3𝑥𝑥3 = −5𝑥𝑥3 − 3𝑥𝑥2 − 2𝑥𝑥1 + 𝑢𝑢

𝑦𝑦 = 𝑥𝑥2 𝑦𝑦 = [ 0 1 0 ]𝑥𝑥1𝑥𝑥2𝑥𝑥3

+ 0 𝑢𝑢

𝑥𝑥1𝑥𝑥2𝑥𝑥3

=0 1 00 0 1−2 −3 −5

𝑥𝑥1𝑥𝑥2𝑥𝑥3

+001

𝑢𝑢

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 41

Page 41: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

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.

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 42

Page 42: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

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

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 43

Page 43: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Linear dynamical system Continuous-time linear dynamical system (CT LDS) has the form

��𝑥 = 𝐴𝐴 𝑑𝑑 𝑥𝑥(𝑑𝑑) + 𝐵𝐵(𝑑𝑑)𝑢𝑢(𝑑𝑑) 𝑦𝑦(𝑑𝑑) = 𝛼𝛼 𝑑𝑑 𝑥𝑥(𝑑𝑑) + 𝐷𝐷(𝑑𝑑)𝑢𝑢(𝑑𝑑)

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 44

Page 44: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Continuous-time linear dynamical system (CT LDS)

��𝑥 = 𝐴𝐴 𝑑𝑑 𝑥𝑥(𝑑𝑑) + 𝐵𝐵(𝑑𝑑)𝑢𝑢(𝑑𝑑) 𝑦𝑦(𝑑𝑑) = 𝛼𝛼 𝑑𝑑 𝑥𝑥(𝑑𝑑) + 𝐷𝐷(𝑑𝑑)𝑢𝑢(𝑑𝑑)

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 45

Page 45: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Linear dynamical system Some terminology

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 46

Page 46: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Linear dynamical system Some terminology

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 47

Page 47: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Linear dynamical system Some terminology

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 48

Page 48: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Linear dynamical system Some terminology

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 49

Page 49: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Discrete-time linear dynamical system (DT LDS)

𝑥𝑥(𝑘𝑘 + 1) = 𝐴𝐴 𝑘𝑘 𝑥𝑥(𝑘𝑘) + 𝐵𝐵(𝑘𝑘)𝑢𝑢(𝑘𝑘)

𝑦𝑦(𝑘𝑘) = 𝛼𝛼 𝑘𝑘 𝑥𝑥(𝑘𝑘) + 𝐷𝐷(𝑘𝑘)𝑢𝑢(𝑘𝑘)

𝑘𝑘

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 50

Page 50: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

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.

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 51

Page 51: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

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]

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 52

Page 52: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Elements of..

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 53

Page 53: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Modeling Mechanical Systems

Mechanical systems consist of three basic types of elements:

1. Inertia elements2. Spring elements3. Damper elements

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 54

Page 54: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Vehicle suspension – Mass-spring-damper

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 55

Page 55: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

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)

• Inertia elements store kinetic energy

𝐸𝐸 = �𝐹𝐹𝐹𝐹 𝑑𝑑𝑑𝑑 = �𝑚𝑚��𝐹𝐹𝐹 𝑑𝑑𝑑𝑑 =12𝑚𝑚𝐹𝐹2

F ma=∑ M Jα=∑

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 56

Page 56: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Spring elements

• Force is generated to resist deflection.

• Examples: translational and rotational springs

• Spring elements store potential energy

𝐸𝐸 = �𝐹𝐹𝐹𝐹 𝑑𝑑𝑑𝑑 = �𝑘𝑘𝑥𝑥��𝑥 𝑑𝑑𝑑𝑑 =12𝑘𝑘𝑥𝑥2

1 2( )F k x x= −

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 57

Page 57: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Damper elements

• Force is generated to resist motion.• Examples: dashpots, friction, wind drag• Damper elements dissipate energy

𝐹𝐹 = 𝑏𝑏( 𝑥𝑥1 − 𝑥𝑥2)

linear damping friction drag

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 58

Page 58: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

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

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 59

Page 59: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Example

𝑚𝑚1��𝑦 + b ��𝑦 − ��𝑧 + k y − z = 0

𝑚𝑚2��𝑧 + b ��𝑧 − ��𝑦 + k z − y = u

Equations of motion

𝑥𝑥1 = 𝑦𝑦, 𝑥𝑥2 = ��𝑦

𝑥𝑥3 = 𝑧𝑧, 𝑥𝑥4 = ��𝑧

Choice of state variables

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 60

Page 60: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Example

𝑚𝑚1 𝑥𝑥2 + b 𝑥𝑥2 − 𝑥𝑥4 + k 𝑥𝑥1 − 𝑥𝑥3 = 0

𝑚𝑚2 𝑥𝑥4 + b 𝑥𝑥4 − 𝑥𝑥2 + k 𝑥𝑥3 − 𝑥𝑥1 = u

Equations of motion

𝑥𝑥1 = 𝑦𝑦, 𝑥𝑥2 = ��𝑦

𝑥𝑥3 = 𝑧𝑧, 𝑥𝑥4 = ��𝑧

Choice of state variables

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 61

Page 61: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Example

𝑥𝑥2 =−b 𝑥𝑥2 − 𝑥𝑥4 − k 𝑥𝑥1 − 𝑥𝑥3

𝑚𝑚1

��𝑥1 = 𝑥𝑥2

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 62

��𝑥3 = 𝑥𝑥4

𝑥𝑥4 =𝑢𝑢 − b 𝑥𝑥4 − 𝑥𝑥2 − k 𝑥𝑥3 − 𝑥𝑥1

𝑚𝑚2

𝑥𝑥1𝑥𝑥2𝑥𝑥3𝑥𝑥4

=

0 1 0 0−𝑘𝑘𝑚𝑚1

−𝑏𝑏𝑚𝑚1

𝑘𝑘𝑚𝑚1

𝑏𝑏𝑚𝑚1

0𝑘𝑘𝑚𝑚2

0𝑏𝑏𝑚𝑚2

0 1−𝑘𝑘𝑚𝑚2

−𝑏𝑏𝑚𝑚2

𝑥𝑥1𝑥𝑥2𝑥𝑥3𝑥𝑥4

+

0001𝑚𝑚2

𝑢𝑢

Is this the minimum set of states ?

Page 62: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Example

Look at where energy is stored

Energy Storage Element State Variablespring (stores elastic PE)

mass 1 (stores KE)

mass 2 (stores KE)

𝑥𝑥1 = (𝑦𝑦 − 𝑧𝑧)

𝑥𝑥2 = ��𝑦

𝑥𝑥3 = ��𝑧

damper does not store energy, it dissipates energy

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 63

Page 63: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Example

𝑥𝑥1 = (𝑦𝑦 − 𝑧𝑧)

𝑥𝑥2 = ��𝑦

𝑥𝑥3 = ��𝑧

𝑚𝑚1��𝑦 + b ��𝑦 − ��𝑧 + k y − z = 0

𝑚𝑚2��𝑧 + b ��𝑧 − ��𝑦 + k z − y = u

𝑥𝑥1 = 𝑥𝑥2 − 𝑥𝑥3

𝑥𝑥2 = ��𝑦 =1𝑚𝑚1

−𝑏𝑏 𝑥𝑥2 − 𝑥𝑥3 − 𝑘𝑘𝑥𝑥1

𝑥𝑥3 = ��𝑧 =1𝑚𝑚2

−𝑏𝑏 𝑥𝑥3 − 𝑥𝑥2 + 𝑘𝑘𝑥𝑥1 + 𝑢𝑢Rewriting in state-space representation

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 64

Page 64: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Example

𝑥𝑥1 = 𝑥𝑥2 − 𝑥𝑥3

𝑥𝑥2 = ��𝑦 =1𝑚𝑚1

−𝑏𝑏 𝑥𝑥2 − 𝑥𝑥3 − 𝑘𝑘𝑥𝑥1

𝑥𝑥3 = ��𝑧 =1𝑚𝑚2

−𝑏𝑏 𝑥𝑥3 − 𝑥𝑥2 + 𝑘𝑘𝑥𝑥1 + 𝑢𝑢

𝑥𝑥1𝑥𝑥2𝑥𝑥3

=

0 1 −1−𝑘𝑘𝑚𝑚1

−𝑏𝑏𝑚𝑚1

𝑏𝑏𝑚𝑚1

𝑘𝑘𝑚𝑚2

𝑏𝑏𝑚𝑚2

−𝑏𝑏𝑚𝑚2

𝑥𝑥1𝑥𝑥2𝑥𝑥3

+001𝑚𝑚2

𝑢𝑢

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 65

Page 65: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Modeling electrical systems

Capacitor[storage]

Inductor[storage]

Resistor[dissipative]

Voltage source

Current source

Passive elements Active elements

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 66

Page 66: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Mechanical – Electrical equivalency

We recognize a common form to the ODE describing each system and create analogs in the various energy domains, for example:

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 67

Page 67: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Capacitor - Mass

Electrical Capacitance

Translational Mass

i Ctv21

dd⋅ E

12

M⋅ v212⋅

F Mtv2

dd⋅ E

12

M⋅ v22⋅

Describing Equation Energy

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 68

q = CV

Page 68: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Inductor - Spring

v21 Ltid

d⋅ E

12

L⋅ i2⋅

v211k t

Fdd⋅ E

12

F2

k⋅

Electrical Inductance

Translational Spring

Describing Equation Energy

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 69

Page 69: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Resistor - Damper

Electrical Resistance

Translational Damper

F b v21⋅ P b v212⋅

i1R

v21⋅ P1R

v212⋅

Describing Equation Energy

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 70

Page 70: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

System

Flow

Effort

Generalized system representation.

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 71

Page 71: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

𝑃𝑃𝑃𝑃𝑃𝑃𝑒𝑒𝑃𝑃 = 𝑇𝑇𝑇𝑃𝑃𝑃𝑃𝑢𝑢𝑚𝑚𝑇 𝐹𝐹𝑣𝑣𝑃𝑃𝑖𝑖𝑣𝑣𝑏𝑏𝑙𝑙𝑒𝑒 × 𝐴𝐴𝐴𝐴𝑃𝑃𝑃𝑃𝐴𝐴𝐴𝐴 𝐹𝐹𝑣𝑣𝑃𝑃𝑖𝑖𝑣𝑣𝑏𝑏𝑙𝑙𝑒𝑒

System

Through variable

Across variable

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 72

Page 72: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

𝑃𝑃𝑃𝑃𝑃𝑃𝑒𝑒𝑃𝑃 = 𝑇𝑇𝑇𝑃𝑃𝑃𝑃𝑢𝑢𝑚𝑚𝑇 𝐹𝐹𝑣𝑣𝑃𝑃𝑖𝑖𝑣𝑣𝑏𝑏𝑙𝑙𝑒𝑒 × 𝐴𝐴𝐴𝐴𝑃𝑃𝑃𝑃𝐴𝐴𝐴𝐴 𝐹𝐹𝑣𝑣𝑃𝑃𝑖𝑖𝑣𝑣𝑏𝑏𝑙𝑙𝑒𝑒

𝑃𝑃 = 𝑖𝑖 × 𝑉𝑉Power is voltage times current

𝑃𝑃 = 𝐹𝐹 × 𝐹𝐹Power is velocity times force

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 73

Page 73: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

𝑃𝑃𝑃𝑃𝑃𝑃𝑒𝑒𝑃𝑃 = 𝑇𝑇𝑇𝑃𝑃𝑃𝑃𝑢𝑢𝑚𝑚𝑇 𝐹𝐹𝑣𝑣𝑃𝑃𝑖𝑖𝑣𝑣𝑏𝑏𝑙𝑙𝑒𝑒 × 𝐴𝐴𝐴𝐴𝑃𝑃𝑃𝑃𝐴𝐴𝐴𝐴 𝐹𝐹𝑣𝑣𝑃𝑃𝑖𝑖𝑣𝑣𝑏𝑏𝑙𝑙𝑒𝑒

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.

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 74

Page 74: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

𝑃𝑃𝑃𝑃𝑃𝑃𝑒𝑒𝑃𝑃 = 𝑇𝑇𝑇𝑃𝑃𝑃𝑃𝑢𝑢𝑚𝑚𝑇 𝐹𝐹𝑣𝑣𝑃𝑃𝑖𝑖𝑣𝑣𝑏𝑏𝑙𝑙𝑒𝑒 × 𝐴𝐴𝐴𝐴𝑃𝑃𝑃𝑃𝐴𝐴𝐴𝐴 𝐹𝐹𝑣𝑣𝑃𝑃𝑖𝑖𝑣𝑣𝑏𝑏𝑙𝑙𝑒𝑒

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.

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 75

Page 75: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

𝑃𝑃𝑃𝑃𝑃𝑃𝑒𝑒𝑃𝑃 = 𝑇𝑇𝑇𝑃𝑃𝑃𝑃𝑢𝑢𝑚𝑚𝑇 𝐹𝐹𝑣𝑣𝑃𝑃𝑖𝑖𝑣𝑣𝑏𝑏𝑙𝑙𝑒𝑒 × 𝐴𝐴𝐴𝐴𝑃𝑃𝑃𝑃𝐴𝐴𝐴𝐴 𝐹𝐹𝑣𝑣𝑃𝑃𝑖𝑖𝑣𝑣𝑏𝑏𝑙𝑙𝑒𝑒

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 76

Page 76: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Energy storage : A-Type elements

Stored energy is a function of the Across-variable.

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 77

Page 77: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Generalized, Capacitance

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 78

Page 78: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Energy storage: T-Type elements

Stored energy is a function of the Through-variable.

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 79

Page 79: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Generalized inductance, L

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 80

Page 80: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Dissipative elements : D-Type

Dissipative elements (non-energy storage)

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 81

Page 81: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Generalized resistance, R

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 82

Page 82: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Cyber-Physical Energy Systems Modeling

Thermal Capacitance

q CttT2

dd⋅ E Ct T2⋅

Thermal Resistance

q1Rt

T21⋅ P1Rt

T21⋅

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 83

Page 83: State-space modeling using first -principles · 2 days ago · State-space modeling using first -principles Lecture 2. Principles of Modeling for Cyber-Physical Systems. Instructor:

Next lecture..

Learn how to get paid for doing nothing while saving the environment !

….the answer might have to do with drinking tea.

Principles of modeling for CPS – Fall 2020 Madhur Behl - [email protected] 84