MUS420 Introduction to Linear State Space Models
Total Page:16
File Type:pdf, Size:1020Kb
State Space Models MUS420 Equations of motion for any physical system may be Introduction to Linear State Space Models conveniently formulated in terms of its state x(t): Julius O. Smith III ([email protected]) Center for Computer Research in Music and Acoustics (CCRMA) Input Forces u(t) Department of Music, Stanford University Stanford, California 94305 ft Model State x(t) x˙(t) February 5, 2019 Outline R State Space Models x˙(t)= ft[x(t),u(t)] • where Linear State Space Formulation • x(t) = state of the system at time t Markov Parameters (Impulse Response) • u(t) = vector of external inputs (typically driving forces) Transfer Function • ft = general function mapping the current state x(t) and Difference Equations to State Space Models inputs u(t) to the state time-derivative x˙(t) • Similarity Transformations The function f may be time-varying, in general • • t Modal Representation (Diagonalization) This potentially nonlinear time-varying model is • • Matlab Examples extremely general (but causal) • Even the human brain can be modeled in this form • 1 2 State-Space History Key Property of State Vector The key property of the state vector x(t) in the state 1. Classic phase-space in physics (Gibbs 1901) space formulation is that it completely determines the System state = point in position-momentum space system at time t 2. Digital computer (1950s) 3. Finite State Machines (Mealy and Moore, 1960s) Future states depend only on the current state x(t) • and on any inputs u(t) at time t and beyond 4. Finite Automata All past states and the entire input history are 5. State-Space Models of Linear Systems • “summarized” by the current state x(t) 6. Reference: State x(t) includes all “memory” of the system Linear system theory: The state space • approach L.A. Zadeh and C.A. Desoer Krieger, 1979 3 4 Force-Driven Mass Example Forming Outputs Consider f = ma for the force-driven mass: Any system output is some function of the state, and possibly the input (directly): Since the mass m is constant, we can use momentum • ∆ p(t)= mv(t) in place of velocity (more fundamental, y(t) = ot[x(t),u(t)] since momentum is conserved) y(t) x(t ) and p(t ) (or v(t )) define the state of the mass ot • 0 0 0 m at time t0 In the absence of external forces f(t), all future states Input Forces u(t) • are predictable from the state at time t0: ft x˙(t) Model State x(t) p(t) = p(t0) (conservation of momentum) 1 t x(t) = x(t )+ p(τ) dτ, t t 0 m ≥ 0 Zt0 External forces f(t) drive the state to arbitrary points R • Usually the output is a linear combination of state in state space: variables and possibly the current input: t ∆ ∆ p(t) = p(t0)+ f(τ) dτ, t t0, p(t) = mv(t) y(t) = Cx(t)+ Du(t) ≥ Zt0 where C and D are constant matrices of 1 t x(t) = x(t )+ p(τ) dτ, t t linear-combination coefficients 0 m ≥ 0 Zt0 5 6 Numerical Integration State Definition We need a state variable for the amplitude of each Recall the general state-space model in continuous time: physical degree of freedom x˙(t)= ft[x(t),u(t)] Examples: An approximate discrete-time numerical solution is x(t + T ) = x(t )+ T f [x(t ),u(t )] Ideal Mass: n n n n tn n n • 1 for n =0, 1, 2,... (Forward Euler) Energy = mv2 state variable = v(t) ∆ 2 ⇒ Let gtn[x(tn),u(tn)] = x(tn)+ Tn ftn[x(tn),u(tn)]: Note that in 3D we get three state variables (vx,vy,vz) u(tn) Ideal Spring: • gt 1 Energy = kx2 state variable = x(t) x(tn) x(tn + Tn) 2 ⇒ Inductor: Analogous to mass, so current • Capacitor: Analogous to spring, so charge • T (or voltage = charge/capacitance) z− n Resistors and dashpots need no state variables • This is a simple example of numerical integration for assigned—they are stateless (no “memory”) • solving the ODE ODE can be nonlinear and/or time-varying • The sampling interval T may be fixed or adaptive • n 7 8 State-Space Model of a Force-Driven Mass Force-Driven Mass Reconsidered For the simple example of a mass m driven by external Why not include position x(t) as well as velocity v(t) in force f along the x axis: the state-space model for the force-driven mass? v(t) x˙(t) 0 1 x(t) 0 = + f(t) x =0 v˙(t) 0 0 v(t) 1/m f(t) m We might expect this because we know from before that the complete physical state of a mass consists of its velocity v and position x! There is only one energy-storage element (the mass), • and it stores energy in the form of kinetic energy Therefore, we should choose the state variable to be • velocity v =x ˙ (or momentum p = mv = mx˙) Newton’s f = ma readily gives the state-space • formulation: 1 v˙ = f m or p˙ = f This is a first-order system (no vector needed) • 9 10 Force-Driven Mass Reconsidered and Dismissed State Variable Summary Position x does not affect stored energy State variable = physical amplitude for some • • energy-storing degree of freedom 1 2 Em = mv 2 Mechanical Systems: • Velocity v(t) is the only energy-storing degree of State variable for each • freedom – ideal spring (linear or rotational) Only velocity v(t) is needed as a state variable – point mass (or moment of inertia) • The initial position x(0) can be kept “on the side” to times the number of dimensions in which it can move • enable computation of the complete state in RLC Electric Circuits: position-momentum space: • State variable for each capacitor and inductor t In Discrete-Time: x(t) = x(0) + v(τ) dτ • Z0 State variable for each unit-sample delay In other words, the position can be derived from the Continuous- or Discrete-Time: • velocity history without knowing the force history • Dimensionality of state-space = order of the system Note that the external force f(t) can only drive v˙(t). (LTI systems) • It cannot drive x˙(t) directly: x˙(t) 0 1 x(t) 0 = + f(t) v˙(t) 0 0 v(t) 1/m 11 12 Discrete-Time Linear State Space Zero-State Impulse Response Models (Markov Parameters) For linear, time-invariant systems, a discrete-time state-space model looks like a vector first-order Linear State-Space Model: finite-difference model: y(n) = Cx(n)+ Du(n) x(n +1) = A x(n)+ B u(n) x(n +1) = Ax(n)+ Bu(n) y(n) = C x(n)+ D u(n) The zero-state impulse response of a state-space model is where ∆ easily found by direct calculation: Let x(0) =0 and N x(n) R = state vector at time n u = Ipδ(n)= diag(δ(n),...,δ(n)). Then • ∈ u(n)= p 1 vector of inputs h(0) = Cx(0)B + DI δ(0) = D • × p y(n)= q 1 output vector x(1) = A x(0) + BIpδ(0) = B • × A = N N state transition matrix h(1) = CB • × B = N p input coefficient matrix x(2) = A x(1) + B δ(1) = AB • × h(2) = CAB C = q N output coefficient matrix • × x(3) = A x(1) + B δ(1) = A2B D = q p direct path coefficient matrix • × h(3) = CA2B The state-space representation is especially powerful for . n 1 multi-input, multi-output (MIMO) linear systems h(n) = CA − B , n> 0 • time-varying linear systems • (every matrix can have a time subscript n) 13 14 Zero-State Impulse Response (Markov Linear State-Space Model Parameters) Transfer Function Thus, the “impulse response” of the state-space model Recall the linear state-space model: can be summarized as • y(n) = C x(n)+ D u(n) D, n =0 h (n)= n 1 x(n +1) = A x(n)+ B u(n) ( CA − B, n> 0 and its “impulse response” Initial state x(0) assumed to be 0 • D, n =0 h Input “impulse” is u = I δ(n)= diag(δ(n),...,δ(n)) (n) = n 1 • p ( CA − B, n> 0 Each “impulse-response sample” h(n) is a p q • matrix, in general × The transfer function is the z transform of the • impulse response: The impulse-response terms CAnB for n 0 are • ≥ called Markov parameters ∆ ∞ n ∞ n 1 n H(z) = h(n)z− = D + CA − B z− n=0 n=1 X X 1 ∞ 1 n = D + z− C z− A B "n=0 # X The closed-form sum of a matrix geometric series gives 1 H(z)= D + C (zI A)− B − (a p q matrix of rational polynomials in z) × 15 16 If there are p inputs and q outputs, then H(z) is a System Poles • p q transfer-function matrix (or× “matrix transfer function”) Above, we found the transfer function to be Given transfer-function coefficients, many digital filter 1 • H(z)= D + C (zI A)− B realizations are possible (different computing − structures) The poles of H(z) are the same as those of ∆ 1 H (z) =(zI A)− Example: (p =3, q =2) p − By Cramer’s rule for matrix inversion, the denominator 1 polynomial for (zI A)− is given by the determinant: − 1 ∆ 1 1 z− 1 d(z) = zI A z − 1+ z− − 1 0.5z 1 | − | H − Q determinant (z)= 1 − 1 1 2 where denotes the of the square matrix 2+3z− 1+ z− (1 z− ) | | − Q (also written as det(Q).) 1 0.1z 1 1 z 1 (1 0.1z 1)(1 0.2z 1) − − − − − − − − In linear algebra, the polynomial d(z)= zI A is • called the characteristic polynomial for the| matrix− | A The roots of the characteristic polynomial are called • the eigenvalues of A Thus, the eigenvalues of the state transition matrix • A are the system poles Each mode of vibration gives rise to a pole pair • 17 18 Initial-Condition Response Difference Equation to State Space Form Going back to the time domain, we have the linear A digital filter is often specified by its difference equation discrete-time state-space model (Direct Form I).