Lecture 1: Introduction to Dynamical Systems • General introduction • Modeling by differential equations (inputs, states, outputs) • Simulation of dynamical systems • Equilibria and linearization • System interconnections and block diagrams Related Reading [KK]: 2.1-2.4 and [AM]: 2.1-2.3, 4.1-4.2, 5.4 1/45 Dynamical Systems In a dynamical system the effects of action do not occur immediately. This phenomenon can be observed in all systems surrounding us: • Mechatronic systems Pushing gas pedal in car does only gradually increase the velocity • Heating systems Temperature does not rise immediately when a heater is switched on • Biological systems A headache disappears slowly when medicine is taken • Business systems: An investment leads to future gains or losses Variables in a dynamical systems evolve in time. The time evolution depends on the external excitation, which itself changes over time. 2/45 Mathematical Models One way to analyze the behavior of a dynamical system is by means of a mathematical model. Such models are often described by (ordinary or partial) differential equations. Example: Mass-Spring-Damper System Newton’s second law leads to mq̈ + c(q̇) + kq = 0. • q denotes the position of the mass (in a chosen coordinate system) and varies with time. q̇ and q̈ are the velocity and the acceleration. • kq is the spring restoring force (assumed to satisfy Hooke’s law) and c(q̇) is the friction force which can depend nonlinearly on the velocity. 3/45 Inputs The previous system is said to be autonomous since it is not exposed to external influences. Non-autonomous systems do have external inputs. Example: Mass-Spring-Damper System With an external force u(.) acting on the mass, we obtain mq̈ + c(q̇) + kq = u(t). The external force u(.) typically varies with time. Depending on the circumstances it can be interpreted as follows: • If we are allowed to manipulate u(.) then it is called a control input. • If u(.) is generated by nature and cannot be influenced/changed by us then it is called a disturbance input. 4/45 Outputs Often not all variables that appear in a model are of interest. We choose outputs in order to describe those quantities that get focus. Example: Mass-Spring-Damper System If we are only interested in the position of the mass, the output y is mq̈ + c(q̇) + kq = u, y = q. For some control input y(.) and along a system trajectory, the output y(.) will be a function of time. Interpretations of outputs: • y is a variable that can be measured (through sensors). • y indicate a variable which we would like to monitor in order to investigate/analyze the properties of the system (in simulation). 5/45 Interpretation of the Model Let u(t) be an input signal defined for t ≥ 0 and let an initial position q0 as well as an initial velocity v0 be given. Solve the differential equation mq̈(t) + c(q̇(t)) + kq(t) = u(t) with q(0) = q0 , q̇(0) = v0 . If u(.) is continuous and c(·) is C 1 , we know that this initial value problem has a unique solution q(t) and q̇(t) that is defined for t ∈ [0, t1 ) with some t1 > 0. Warning and Reminder: Solutions might not exist for all t ≥ 0. Since the values for q(0) and q̇(0) specify the solution of the differential equation (for a fixed input) uniquely, we call x1 q x1 (t) q(t) x= = and x(t) = = x2 q̇ x2 (t) q̇(t) the state-vector and state-response of the system. The system’s output (response) is then just given by y(t) = q(t). 6/45 Demo: Free and Driven Response u(t) q(t) (full) and v(t) (dotted) 1 6 4 0.5 2 0 0 −0.5 −1 0 −2 10 20 30 40 −4 0 10 20 30 40 q (horizontal) versus v (vertical) Graph of function c(.) 2 4 1 2 0 0 −1 −2 −2 −5 0 5 −4 −5 0 5 7/45 Demo: Effect of Nonlinearity u q (blue) and v (green) 2 20 1 10 0 0 −1 −10 −2 0 50 100 150 Graph of function c(.) 200 2 −20 0 50 100 150 200 q (horizontal) versus v (vertical) 20 1 10 0 0 −1 −10 −2 −5 0 5 −20 −20 −10 0 10 20 8/45 Demo: Finite Escape Time u(t) q(t) (full) and v(t) (dotted) 1 15 0.5 10 0 5 −0.5 0 −1 0 5 10 Graph of function c(.) 15 0 −5 0 5 10 15 q (horizontal) versus v (vertical) 10 −5 5 −10 −15 0 −20 −25 −5 0 5 −5 −5 0 5 10 15 9/45 Demo: Stability and Instability u(t) q(t) (full) and v(t) (dotted) 1 10 0.5 5 0 0 −0.5 −5 −1 0 5 Graph of function c(.) 10 2 1 −10 0 5 10 q (horizontal) versus v (vertical) 5 0 0 −5 −1 −2 −5 0 5 −10 −10 −5 0 5 10 10/45 Demo: Stable Limit Cycle u(t) q(t) (full) and v(t) (dotted) 1 10 0.5 5 0 0 −0.5 −5 −1 0 5 10 15 Graph of function c(.) 20 10 −10 0 5 10 15 20 q (horizontal) versus v (vertical) 10 5 5 0 0 −5 −5 −10 −5 0 5 −10 −10 −5 0 5 10 11/45 Interpretation of the Model If we write down a system like mq̈ + c(q̇) + kq = u, y = q, we are actually interested in its behavior, the set of all input-, stateand output-signals u(.), (q(.), q̇(.)) and y(.) that satisfy these laws. • Signals are vector-valued functions of time, also called trajectories. Tacitly assumed to be piece-wise continuous. • The laws to-be-satisfied are often described by differential equations. Impose hypothesis that guarantee existence/uniqueness of i.v.p. • Different system descriptions (laws) can lead to the same behavior. We then call the system (descriptions) equivalent. In the so-called behavioral approach to dynamical systems all this is developed in a mathematically precise fashion. 12/45 Sample Questions in Control For a system like mq̈ + c(q̇) + kq = u, y = q we are e.g. interested in the following issues: • If there is no external excitation how does the state/output behave? • Can we steer the system from one position to another? • Is it possible to determine the input from knowledge of the output? • Can we modify the system in order to create a desired behavior? Some of these (yet rough) questions are related to analyzing the system for its properties, while others involve synthesizing control inputs or modify the system laws in order to change the system’s behavior. Control is the field to answer such questions systematically. 13/45 From Second-Order to First-Order Models The system description mq̈ + c(q̇) + kq = u involves the first and second derivative of q. If m 6= 0 it is called a second order differential equation. If we introduce the state-variables x1 = q and x2 = q̇ we conclude ẋ1 = q̇ = x2 , c(q̇) 1 k 1 1 k q− + u = − x1 − c(x2 ) + u. m m m m m m This can be written more compactly as x2 ẋ1 = = f (x1 , x2 , u). k ẋ2 −m x1 − m1 c(x2 ) + m1 u ẋ2 = q̈ = − This is a first-order and two-dimensional vector differential equation. 14/45 From High-Order to First-Order Models Suppose r is a general real-valued nonlinear function of n+1 arguments. Lemma 1 The system q (n) + r(q (n−1) , q (n−2) , . . . , q̇, q, u) = 0 is equivalent to ẋ1 x2 ẋ2 x3 . .. . ẋ = . = . ẋ xn n−1 ẋn −r(xn , xn−1 , . . . , x2 , x1 , u) =: f (x, u). Proof. Introduce x1 = q, x2 = q̇, . . . , xn−1 = q (n−2) , xn = q (n−1) , substitute the variables and write down the resulting vector equation. 15/45 Non-Uniqueness It is important to note that there is no unique way to do this. Understanding this issue will be an essential topic later. Lemma 2 The system q (n) + r(q (n−1) , q (n−2) , . . . , q̇, q, u) = 0 is equivalent to ż1 ż2 . ż = .. ż n−1 żn = −r(z1 , z2 , . . . , zn−1 , zn , u) z1 z2 .. . zn−1 = fˆ(z, u). Proof. Introduce z1 = q (n−1) , z2 = q (n−2) , . . . , zn−1 = q̇, zn = q and proceed as before. 16/45 Generic System Description in Control Physical modeling often leads to a system of higher-order differential equations. As seen above, these can typically (though not always!) be equivalently written as a first-order vector differential equation ẋ = f (x, u) and y = h(x, u). with maps f : X × U → Rn and h : X × U → Rk (X ⊂ Rn , U ⊂ Rm ). This compact system description forms the starting point of control. More explicitly these equations read as ẋ1 = f1 (x1 , . . . , xn , u1 , . . . , um ) .. . ẋn = fn (x1 , . . . , xn , u1 , . . . , um ) y1 = h1 (x1 , . . . , xn , u1 , . . . , um ) .. . yk = hk (x1 , . . . , xn , u1 , . . . , um ) Note that these functions could as well depend explicitly on time! 17/45 System Response and Differential Equations For f : X × U → Rn , h : X × U → Rk with open X ⊂ Rn , U ⊂ Rm consider ẋ = f (x, u) and y = h(x, u). If u(.) : I → U is an input function on an open interval I ⊂ R containing 0 and if ξ ∈ Rn is an initial condition for the state, then the stateresponse x(.) is obtained by solving the initial value problem ẋ = f (x, u(t)) with initial condition x(0) = ξ. The output response is just defined by y(t) := h(x(t), u(t)) for t ∈ I. • Existence and uniqueness of the state-response on some open subinterval of I is guaranteed if f is continuous and Lipschitz continuous in x and if u(.) is continuous. • This also holds for inputs u(.) that are only piece-wise continuous. 18/45 Recap: Global Existence and Uniqueness Theorem Consider the initial value problem (ivp) ẋ = g(t, x), x(τ ) = ξ for g : D → Rn with D ⊂ R × Rn . Assumptions. Suppose D ⊂ R × Rn is open and g : D → Rn , (t, x) → g(t, x) is continuous and Lipschitz-continuous in x: For each (τ, ξ) ∈ D there exists a neighborhood U ⊂ D of (τ, ξ) and some L > 0 with kg(t, x) − g(t, y)k ≤ Lkx − yk for all (t, x), (t, y) ∈ U. • Is satisfied if both g and ∂x g are continuous on D. • It suffices that g ∈ C 1 (D, Rn ). 19/45 Recap: Global Existence and Uniqueness Theorem Theorem 3 Under the above assumptions and for every (τ, ξ) ∈ D there exists a maximal interval of existence I(τ,ξ) = (t− , t+ ) 3 τ and a unique C 1 -solution x(., τ, ξ) : I(τ,ξ) → Rn of the ivp ẋ = g(t, x), x(τ ) = ξ. (1) Maximality of I(τ,ξ) means: If the initial value problem has a C 1 -solution xJ : J → Rn on the interval J 3 τ , then J ⊂ I(τ,ξ) and xJ is the restriction of x onto J. Moreover, for t+ < ∞ exactly one of the following properties holds: • The solution “escapes”: limt→t+ , t<t+ kx(t)k = ∞. • There solution “approaches the boundary of D”: For all sequences tν ∈ (t− , t+ ) with tν → t+ and limν→∞ x(tν ) = x+ , the point (t+ , x+ ) is contained in the boundary of D. 20/45 Generic Description of Linear Systems If f and h are linear they can be represented as f (x, u) = Ax + Bu and h(x, u) = Cx + Du with matrices A ∈ Rn×n , B ∈ Rn×m , C ∈ Rk×n , D ∈ Rk×m . Hence a generic linear (time-invariant) system is described as ẋ = Ax + Bu and y = Cx + Du. This is the system description mostly considered in this course. The behavior of many dynamical systems in engineering can often be (approximately) modeled by linear systems. On the other hand, physical modeling often results in descriptions with nonlinear dynamics. How can we justify that this course discusses mainly linear systems? 21/45 Simulation A system description in terms of the differential and output equation ẋ(t) = f (x(t), u(t)), x(0) = ξ, y(t) = h(x(t), u(t)) allows the numerical computation of the response (to an input and an initial condition) by ode-solvers (such as ode45 or ode15s in Matlab). By integrating over time, the description is equivalent to Z t x(t) = ξ + f (x(τ ), u(τ )) dτ, y(t) = h(x(t), u(t)). 0 This leads to the general diagram for a Simulink simulation: x 1 s Integrator with initial condition x0 u Signal Generator f(x,u) h(x,u) Right-hand side of differential equation Output function Scope 22/45 Example: Segway (Cart-Pendulum) Modeling with the Lagrange technique ([F] p.30-31) leads to (M + m)p̈ − ml cos(θ)θ̈ + cṗ + ml sin(θ)θ̇2 = F −ml cos(θ)p̈ + ml2 θ̈ + γ θ̇ − mgl sin(θ) = 0 where, next to the parameters defined in the figure, c and γ are the coefficients describing the viscous friction of the cart and the pendulum. 23/45 Example: First-Order System Description More insightful and compact description: p̈ (M + m) −ml cos(θ) cṗ + ml sin(θ)θ̇2 F + = . −ml cos(θ) ml2 0 θ̈ γ θ̇ − mgl sin(θ) Introduce the abbreviations (M + m) −ml cos(θ) cṗ + ml sin(θ)θ̇2 U (θ) = , v(θ, ṗ, θ̇) = . −ml cos(θ) ml2 γ θ̇ − mgl sin(θ) Then the system can be described as p̈ F + v(θ, ṗ, θ̇) = . U (θ) 0 θ̈ Since the matrix U (θ) is always invertible (why?) this is the same as p̈ F w1 (p, θ, ṗ, θ̇, F ) −1 −1 = −U (θ) v(θ, ṗ, θ̇) + U (θ) = 0 θ̈ w2 (p, θ, ṗ, θ̇, F ) with yet another abbreviation of the right-hand side. 24/45 Example: First-Order System Description Finally introduce the states and the input ṗ x1 p x3 = , = and u = F. x2 θ x4 θ̇ The system is then described as ẋ1 x3 ẋ2 x4 ẋ3 = w1 (x1 , x2 , x3 , x4 , u) ẋ4 w2 (x1 , x2 , x3 , x4 , u) f1 (x1 , x2 , x3 , x4 , u) f2 (x1 , x2 , x3 , x4 , u) = f3 (x1 , x2 , x3 , x4 , u) . f4 (x1 , x2 , x3 , x4 , u) The given representation of f (x, u) can be coded exactly as described. This is much less error-prone than explicit computations as e.g. given in [AM] p.37, in particular for more complicated situations. However, let us stress again we just obtained another representation of the very same system as defined by the equations on slide 23. 25/45 Equilibria Definition 4 All pairs of vectors (xe , ue ) ∈ X × U which satisfy 0 = f (xe , ue ) are called equilibria of the system ẋ = f (x, u). If the system is driven with the constant control input u(t) = ue and if the state is initialized as xe (0) = xe , then the state-response is given by x(t) = xe and thus ẋe (t) = 0 for all t ≥ t0 . If starting at an equilibrium the state-trajectory stays there. Equilibria are in general not unique. Not even for linear systems. Often (but by no means always!) our interest is in trajectories that “do not deviate too much” from equilibria. 26/45 Example: Segway The equilibria of the system on slide 23 are determined by 0 = F and mgl sin(θ) = 0. Solutions are θe = 0 (upright position) and θe = π (downright position), while pe is arbitrary. Four simulations, including perturbation of initial condition (dash-dotted): p 1 0 −1 0 1 2 3 4 5 3 4 5 θ 5 0 0 1 2 27/45 Linearization If f and h are C 1 , their first-order Taylor expansions around (xe , ue ) are f (x, u) ≈ f (xe , ue ) + ∂x f (xe , ue )(x − xe ) + ∂u f (xe , ue )(u − ue ) | {z } | {z } A B h(x, u) ≈ h(xe , ue ) + ∂x h(xe , ue )(x − xe ) + ∂u h(xe , ue )(u − ue ). | {z } | {z } | {z } ye C D The approximation is good if x ≈ xe and u ≈ ue . Definition 5 Suppose that f (xe , ue ) = 0. If f and h are C 1 , the linearization of ẋ = f (x, u), y = h(x, u) at (xe , ue ) is ẋ∆ = Ax∆ + Bu∆ , y∆ = Cx∆ + Du∆ . Let u(t) ≈ ue and x(0) ≈ xe lead to the nonlinear response y(t) ≈ ye . If one drives the linearization with u∆ (t) := u(t) − ue and for the initial value x∆ (0) := x(0) − xe , we hope that y∆ (t) + ye approximates y(t). 28/45 Example: Segway Nonlinear (blue) versus linearized (green) simulation at (pe , θe ) = (0, π): F 1 0.5 0 0 2 4 6 8 10 6 8 10 6 8 10 p 1 0.5 0 0 2 4 θ 3.4 3.2 3 0 2 4 Good match. 29/45 Example: Segway Nonlinear (blue) versus linearized (green) simulation at (pe , θe ) = (0, 0): F 1 0.5 0 0 0.5 1 1.5 1 1.5 1 1.5 p 4 2 0 0 0.5 θ 20 10 0 0 0.5 Huge deviation in the long run. 30/45 System Interconnections and Modularity One of the most important concepts in modeling dynamical systems is modularity. Complex models are built by interconnecting simple system components in a hierarchical manner. Dynamical systems are interconnected by equating signals. • Allows to use software libraries with standard system components and interfaces between different physical domains. • Many concrete modeling packages are available (Matlab, Modelica). • Even for complex models, the hierarchical (nested) structure renders bookkeeping manageable. • Individual components can be adapted while preserving the overall interconnection structure. 31/45 Example: Mass-Spring-Damper System The simple mass-spring-damper system mq̈+c(q̇)+kq = u does actually result from Newton’s laws as follows: F = ṗ with p = mv. The total force acting on the mass (assumed to be constant) is F = F1 + F2 + F3 with the externally exerted force F1 = u, the friction force (assumed to depend on velocity) F2 = c(v), and the spring restoring force (assumed to depend linearly on elongation) F3 = −kq. 32/45 Example: Pendulum on Cart Suppose the cart force is generated by an electric DC motor attached to a one wheel of radius r. If the voltage V is applied to the motor, the winding current I generates a torque; with the load torque T the motor dynamics is described by J φ̈ + bφ̇ = km I − T, LI˙ + RI = V − ke φ̇ with positive constants J, b, km , L, R, ke . The load torque and the motor shaft-angle are assumed to be related to F and p by T = Fr and p = rφ. φ r 0 p All this has to be combined with the previous dynamics. 33/45 Example: Pendulum on Cart We obtain the following description of the interconnection: ke ṗ = V r J b km (M + m + 2 )p̈ − ml cos(θ)θ̈ + (c + 2 )ṗ + ml sin(θ)θ̇2 − I = 0 r r r −ml cos(θ)p̈ + ml2 θ̈ + γ θ̇ − mgl sin(θ) = 0. LI˙ + RI + Note that the coupling is often called two-sided, since the dynamics of the interconnected systems influence each other. If ke = 0 then the coupling is one-sided. It is not straightforward to predict the impact of the motor dynamics onto the overall dynamic response of the model. Let us hence only analyze, by simulation, the influence of “large” and “small” values of L. 34/45 Example: Pendulum on Cart Small L leads to fast motor dynamics: F 1 0.5 0 0 1 2 3 4 5 3 4 5 3 4 5 p 2 1 0 0 1 2 θ 3.4 3.2 3 0 1 2 Green response: Original. Blue response: With motor. 35/45 Example: Pendulum on Cart Larger L slows the motor dynamics down: F 1 0.5 0 0 1 2 3 4 5 3 4 5 3 4 5 p 2 1 0 0 1 2 θ 3.4 3.2 3 0 1 2 Green response: Original. Blue response: With motor. 36/45 Series Interconnection Definition 6 The series interconnection of the systems ẋ1 = f1 (x1 , u1 ), y1 = h1 (x1 , u1 ), ẋ2 = f2 (x2 , u2 ), y2 = h2 (x2 , u2 ) is obtained if the output of the first system enters the second system as an input: u2 = y1 . (The vector dimensions must be equal.) The series interconnection is then described by ẋ1 f1 (x1 , u1 ) = , y2 = h2 (x2 , h1 (x1 , u1 )). ẋ2 f2 (x2 , h1 (x1 , u1 )) Linear systems: ẋ1 = A1 x1 + B1 u1 , y1 = C1 x1 + D1 u1 η̇ = A1 0 B2 C1 A2 ẋ2 = A2 x2 + B2 u2 , η= y2 = C2 x2 + D2 u2 B1 η+ u1 , y2 = B2 D1 x1 x2 D2 C1 C2 η+D2 D1 u1 37/45 Parallel Interconnection Definition 7 The parallel interconnection of the systems ẋ1 = f1 (x1 , u1 ), y1 = h1 (x1 , u1 ), ẋ2 = f2 (x2 , u2 ), y2 = h2 (x2 , u2 ) is obtained by having them enter a common input and summing the outputs: u1 = u2 = u and y = y1 + y2 . (Dimensions must fit.) The parallel interconnection is then described by ẋ1 f1 (x1 , u) = , y = h1 (x1 , u) + h2 (x2 , u). ẋ2 f2 (x2 , u) Linear systems: ẋ1 = A1 x1 + B1 u1 , y1 = C1 x1 + D1 u1 η̇ = A1 0 0 A2 η+ ẋ2 = A2 x2 + B2 u2 , η= y2 = C2 x2 + D2 u2 B1 B2 u, y = x1 x2 C1 C2 η + (D1 + D2 )u 38/45 Matlab’s Control System Toolbox Matlab’s Control System Toolbox has so-called ss objects which are used to work with linear state-space systems as follows: • System definition: sys1=ss(A1,B1,C1,D1), sys2=ss(A2,B2,C2,D2) • Series interconnection: ser=sys1*sys2 • Parallel interconnection: par=sys1+sys2 • Simulation: y=lsim(sys,u,T,x0) • Extraction of defining matrices: [A,B,C,D]=ssdata(sys) Note that the (overloaded) operations for the series and parallel interconnections remind us about the way how matrices act as mappings. Internally these operations are based on the above derived formulas. You should be actively exploring the possibilities of the toolbox. 39/45 Block-Diagrams Like in Simulink, block-diagrams as generally used for the visualization of systems interconnections in control. Generically an individual block is indicated as Input Operation to be performed on input Output Static blocks are maps from R into R or from Rp into Rq . Dynamic blocks map an input signal into an output signal. Examples: 40/45 Block-Diagrams Dynamic blocks described by differential equations require the specification of an initial condition such that the output is uniquely defined by the input. Such an initial condition can be viewed as an extra input. That’s why, for an integrator, one sometimes uses the notation x0 u Z y or, for a general system, the block description x0 u ẋ = f (x, u) y = h(x, u) y 41/45 Block-Diagrams A block-diagram is obtained by interconnecting individual blocks (by equating signals). Hence such diagrams (should) always correspond in a precise fashion to algebraic equations. Generic examples Series interconnection: u1 ẋ1 = f (x1 , u1 ) y1 = h(x1 , u1 ) y2 ẋ2 = f (x2 , u2 ) y2 = h(x2 , u2 ) Parallel interconnection: ẋ1 = f (x1 , u) y1 = h(x1 , u) u + y ẋ2 = f (x2 , u) y2 = h(x2 , u) 42/45 Example: Mass-Spring-Damper System Differential equation and output equation: 1 k 1 q̈ = u − c(q̇) − q, y = q m m m Start from chain of integrators q̇(0) q̈ Z q(0) q̇ Z q and obtain block-diagram with equations of motion: q̇(0) u 1 m q̈ + − Z q(0) q̇ 1 c(.) m Z q y k m + 43/45 Example: State-Space System The standard linear state-space system can be depicted as x0 u(t) R ? - B - j 6 x(t) y(t) - C - j - 6 A - D However, there is no need for such an explicit implementation in e.g. Simulink, since one can just use either a State-Space block (defined by A, B, C, D) or an LTI Systems block (defined by an ss-object). 44/45 Covered in Lecture 1 • Models of dynamical systems differential equations, inputs, outputs, state, reduction to first order, linear systems, compact notation, Simulink simulation • Linearization • System interconnections modularity in modeling, interconnection=equating signals feedback equations, relation to block diagrams • Aspects of qualitative analysis of dynamic responses nonzero initial condition, external input signal, equilibria, stability, limit cycles, finite escape time 45/45