engi9496 modelling and simulation of dynamic …grideout/engi9496_files/engi9496_f13...engi9496...

15
ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms 1 ENGI9496 Lecture Notes State-Space Equation Generation 1. 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?

Upload: vuhanh

Post on 28-Apr-2018

239 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: ENGI9496 Modelling and Simulation of Dynamic …grideout/ENGI9496_files/ENGI9496_F13...ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms 5 2. Implicit

ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms

1

ENGI9496 Lecture Notes – State-Space Equation Generation 1. 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 = to is transferred to other elements and affects future response.

To predict future system response for time t ≥ to, you need

knowledge of inputs for time t ≥ to initial values of a suitable set of state variables at time t = to.

Consider mass-spring system. How many state variables are required? What are they?

Page 2: ENGI9496 Modelling and Simulation of Dynamic …grideout/ENGI9496_files/ENGI9496_F13...ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms 5 2. Implicit

ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms

2

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.

Page 3: ENGI9496 Modelling and Simulation of Dynamic …grideout/ENGI9496_files/ENGI9496_F13...ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms 5 2. Implicit

ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms

3

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.10)

rn

rn

rn

u,,u,u;x,,x,xφx

u,,u,u;x,,x,xφx

u,,u,u;x,,x,xφx

212133

212122

212111

For linear systems, explicit state equations can be written in matrix-vector form:

uBxAx

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 1 handout

1. Write state equations in matrix-vector form. 2. 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:

Page 4: ENGI9496 Modelling and Simulation of Dynamic …grideout/ENGI9496_files/ENGI9496_F13...ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms 5 2. Implicit

ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms

4

Mechanical

Electrical

Page 5: ENGI9496 Modelling and Simulation of Dynamic …grideout/ENGI9496_files/ENGI9496_F13...ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms 5 2. Implicit

ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms

5

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

tuxfx ,,

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 20SIM). 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

tzuxgz

tzuxfx

,,,

,,,

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 20SIM’s “implicit” integrators (BDF Method, Modified BDF Method) are required. Such integrators use a “predictor-corrector” 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.

Page 6: ENGI9496 Modelling and Simulation of Dynamic …grideout/ENGI9496_files/ENGI9496_F13...ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms 5 2. Implicit

ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms

6

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

tuxxfx ,,,

The state variable vector x may consist of independent states xi and dependent states xd which depend on xi. x = xi xd. 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 xi, the dependent states xd must be calculated so that the left and right-hand sides of the above equation are equal. Many software packages such as 20SIM 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

Page 7: ENGI9496 Modelling and Simulation of Dynamic …grideout/ENGI9496_files/ENGI9496_F13...ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms 5 2. Implicit

ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms

7

Example B. Cont’d Eq’ns 1-4 are DAE’s:

1. Start with state variable values x1, v1, x2 2. Solve algebraic equation for v2 3. Compute 4. Integrate 5. Repeat

To convert to ODE’s (explicit), substitute Eq’n 4 into Eq’ns 1 and 3. What if we substitute Eq’n 3 into Eq’ns 1 and 4? This will result in implicit ODE’s.

Page 8: ENGI9496 Modelling and Simulation of Dynamic …grideout/ENGI9496_files/ENGI9496_F13...ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms 5 2. Implicit

ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms

8

Example B Cont’d Taking the implicit equations, could we just substitute Eq’n 3A into 1A? No, because we would still be left with x2, and would need an equation for . To make the implicit equations explicit, write in matrix-vector form and use matrix inversion.

Page 9: ENGI9496 Modelling and Simulation of Dynamic …grideout/ENGI9496_files/ENGI9496_F13...ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms 5 2. Implicit

ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms

9

C. Implicit Equations (Dependent States)

Page 10: ENGI9496 Modelling and Simulation of Dynamic …grideout/ENGI9496_files/ENGI9496_F13...ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms 5 2. Implicit

ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms

10

Example C Cont’d

Page 11: ENGI9496 Modelling and Simulation of Dynamic …grideout/ENGI9496_files/ENGI9496_F13...ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms 5 2. Implicit
Page 12: ENGI9496 Modelling and Simulation of Dynamic …grideout/ENGI9496_files/ENGI9496_F13...ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms 5 2. Implicit
Page 13: ENGI9496 Modelling and Simulation of Dynamic …grideout/ENGI9496_files/ENGI9496_F13...ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms 5 2. Implicit
Page 14: ENGI9496 Modelling and Simulation of Dynamic …grideout/ENGI9496_files/ENGI9496_F13...ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms 5 2. Implicit
Page 15: ENGI9496 Modelling and Simulation of Dynamic …grideout/ENGI9496_files/ENGI9496_F13...ENGI9496 Modelling and Simulation of Dynamic Systems - Standard Equation Forms 5 2. Implicit