ENGI9496 Lecture Notes State-Space Equation Generation. State Equations and Variables - Definitions The end goal of model formulation is to simulate a system s behaviour on a computer. A set of coherent mathematical equations must be written for the computer to solve. These equations are called state equations. The state equations are written in terms of state variables, defined as [A] minimum set of [variables] which contain enough information about a system's history to enable computation of its future behavior. www.answers.com The state variables must completely describe the effect of the past history of the system on its response in the future. are, ideally, independent (so that you can t express one as a combination of the others). are usually associated with energy storage elements, since energy stored in these elements at t = t o is transferred to other elements and affects future response. To predict future system response for time t t o, you need knowledge of inputs for time t t o initial values of a suitable set of state variables at time t = t o. Consider mass-spring system. How many state variables are required? What are they?
Numerical integration example, showing how to proceed when you can plug the current value of the state variables into the right-hand side, along with the value of the input, and calculate the derivatives of the state variables. This is Euler integration.
For greatest ease of computation, state equations should: be first order differential equations have left-hand side equal to the derivative of one of the state variables have right-hand side containing only state variables and input variables ideally be explicit (the state variable derivative appears only on the left-hand side) Given an nth-order system, with r input variables, the most general (non-linear) form of explicit state equations is (Karnopp et al. Eq n 5.0) x x x 3 φ φ φ 3 n n n r r x,x,,x ;u,u,,u x,x,,x ;u,u,,u x,x,,x ;u,u,,u r For linear systems, explicit state equations can be written in matrix-vector form: x Ax Bu where dim(a) = n x n, dim(b) = n x r. As you may have guessed, system order is the number of first-order state variables required. It can also be defined as the number of independent energy storage elements in a system. If you have an nth order system, then you can express the system dynamics as a single nth order differential equation in one unknown variable n first-order equations some combination of first and higher-order equations Go back to mechanical (or electrical) system example from Lecture handout. Write state equations in matrix-vector form.. Demonstrate that state variables are not unique. The following scans are the closest you ll ever find to a procedure for writing governing equations for electrical and mechanical systems, in a typical system dynamics textbook. From Close, Frederick and Newell: 3
Mechanical Electrical 4
. Implicit and Differential-Algebraic Equations Possible forms of the governing equations (state equations): A. Explicit Ordinary Differential Equations each equation expresses derivative of a state variable as an algebraic function of other state variables, inputs, and system parameters Sometimes additional state variables may be required beyond the typical variables associated with energy storage elements Equations will be of the form x f x, u, t which can be written in matrix-vector form as above, for linear systems. x is vector of state variables u is vector in inputs This is the easiest form for computer simulation, as any explicit integration scheme can be used (e.g., Euler, Vode-Adams, Runge-Kutta, Runge-Kutta Fehlberg in 0SIM). Given initial values of the state variables, along with inputs, then the state derivatives can be easily calculated. A numerical integration time step then gives new values of the state variables and the process is repeated. B. Differential-Algebraic Equations (DAE s) Caused by Algebraic Loops algebraic equations exist among variables, which show up in the governing equations the algebraic variables do not have associated differential equations theoretically, the algebraic variables can be substituted out symbolically to create ODE s, but this is sometimes impractical Equations will be of the form x f x, u, z, t z g x, u, z, t z is vector of algebraic variables The algebraic variables in the vector z are not governed by differential equations. Numerical integration is more difficult, and 0SIM s implicit integrators (BDF Method, Modified BDF Method) are required. Such integrators use a predictorcorrector scheme. Given initial values for x and u, the algebraic equations must be solved numerically (for example, with a Newton-Raphson routine). Values of z must be found that make the right and left-hand sides of the algebraic equations equal to within some tolerance. These values for z are then plugged into the differential equations to calculate the derivatives. 5
C. Implicit Equations Algebraic constraints among state variables (dependency among state variables) Energy storage element initial states cannot be specified independently May have state variable derivatives on left and right-hand sides of governing equations, and it may be hard to solve for the derivatives explicitly. Equations may be of the form x f x, x, u, t The state variable vector x may consist of independent states x i and dependent states x d which depend on x i. x = x i x d. Again, implicit integration schemes are required. Given x and u, state derivatives cannot be calculated from the right-hand side of the equations. Given the independent state variables x i, the dependent states x d must be calculated so that the left and righthand sides of the above equation are equal. Many software packages such as 0SIM can symbolically solve the algebraic loops or derivative causalities and create explicit equations for simple systems. Examples: A. Explicit Equations with Additional State Variables B. DAE s / Algebraic Loop 6
Example B. Cont d Eq ns -4 are DAE s:. Start with state variable values x, v, x. Solve algebraic equation for v 3. Compute 4. Integrate 5. Repeat To convert to ODE s (explicit), substitute Eq n 4 into Eq ns and 3. What if we substitute Eq n 3 into Eq ns and 4? This will result in implicit ODE s. 7
Example B Cont d Taking the implicit equations, could we just substitute Eq n 3A into A? No, because we would still be left with x, and would need an equation for. To make the implicit equations explicit, write in matrix-vector form and use matrix inversion. 8
C. Implicit Equations (Dependent States) 9
Example C Cont d 0