• No results found

Mode Initialization when Simulating Switched Bond Graphs

N/A
N/A
Protected

Academic year: 2021

Share "Mode Initialization when Simulating Switched Bond Graphs"

Copied!
7
0
0

Loading.... (view fulltext now)

Full text

(1)

Mode Initialization when Simulating Switched Bond Graphs

Krister Edstrom

(edstrom@isy.liu.se) Dept. of Electrical Engineering

Linkoping University S-581 83 Linkoping, Sweden

Abstract

When simulating hybrid systems using switched bond graphs, the initialization of new modes is made by using a generalization of the principle of momentum conservation. This information is eas- ily found from the bond graph. Furthermore, im- pulses due to structural changes in the system can be found with a correct initialization and with a correct treatment of sources with causal conicts.

Keywords: Modeling, simulation, hybrid systems, bond graphs, initialization, structural changes

1 Introduction

This paper deals with the problem of simulating hy- brid systems. More particularly, it deals with initial- izations of new modes and detection of discontinu- ities that appear due to changes in the structure of the model when changing modes.

The tool used for describing the hybrid system is the switched bond graphs. It is a tool for making graphical physical models of hybrid systems.

In addition to the principle of energy conservation used when describing a system with a bond graph, a generalization of the principle of momentum con- servation is used to nd the correct initialization of a new mode and detect some of the discontinuities appearing when changing modes.

Example 1 Consider the two capacitors in Figure 1.

If the switch is closed their behavior is determined by the principle of electric charge conservation. Hence this principle can be used to initialize the new mode.

How is this initialization procedure generalized in a bond graph framework?

i1 i2

Figure 1: A simple electrical example.

First a very brief description of the switched bond graph language is made. This description presup- poses that the reader is familiar with (classical) bond graphs. Then the generalization of the principle of momentum conservation is discussed and put in a bond graph framework.

The algorithms for propagating causality and gen- erate equations are discussed and related to the gen- eralized momentum.

Then the main ideas are presented: A method for initializing new modes using the generalized momen- tum, and a method for detection of discontinuities.

2 Switched Bond Graphs

Switched bond graphs 7, 3] are an extension of clas-

sical bond graphs 5, 2] in the sense that they also

(2)

allow modeling of instant changes. Using switched bond graphs, the bond graph language is extended with a new element, a switch 8]. This switch cap- tures the mode switching behavior with its two dier- ent states,

E

and

F

. Fixed in the

E

-state the switch is replaced with a zero eort source, Se :0, and in the

F

-state the switch is replaced with a zero ow source,

Sf :0, see Figure 2. The causal assignment rules for the zero eort and ow sources are the same as for the ordinary sources.

Sw

Se:0

Sf:0

g

EF g

FE E

F

Figure 2: The two states of a switch element. Causal strokes are shown for the two states.

Note that a switched bond graph can be viewed as a collection of classical bond graphs, each one de- scribing a certain mode. To nd such a classical bond graph, all switches have to be xed in one of the two states, i.e. replaced with sources. There is one classi- cal bond graph for each combination of states for the switches.

Note also that the causality is dierent in the dif- ferent modes, since the causality of a switch changes between its states.

To complete the description of a switch, two transi- tion conditions, g

EF

and g

FE

, have to be added, g

EF

and g

FE

. g

EF

gives the condition for switching from state

E

to

F

, and g

FE

the condition for switching the other way.

3 Generalized momentum

The principle of momentum conservation and the principle of electric charge conservation are two prin- ciples of physics. Seen from a bond graph perspec- tive they are dual descriptions of the same phe- nomena, generalized momentum. The principle of momentum conservation states that the momentum, G =

P

m v =

PR

F , is always preserved when

the structure of the system changes. The sum is over all masses in the system. In bond graph terms the sum of integrals of eort variables is preserved. The principle of electric charge conservation states that the charge, Q =

P

c

k

u

k

=

PR

i

k

, is always pre- served after structural changes. Here the sum is over all capacitors in the system. In bond graph terms, the sum of integrals of ow variables is preserved.

This gives the following denition of conservation of generalized momentum:

The generalized momentum is conserved through- out structural changes in a switched bond graph model:

X Z

f dt +

X

Z

e dt = M

g

This rst sum is over all C -elements in the bond graph, and the second over all I -elements.

The generalized momenta are straightforwardly in- troduced in a bond graph. Using the constitutive re- lations in Table 1 for the storage elements, the general momenta are the states, x .

C : _ x = f e = g

e

( x ) I : _ x = e e = g

f

( x ),

Table 1: Constitutive relations for storage elements

4 Causality Propagation and Equation Generation

The next issue is how to include the generalized mo- menta in the equations derived from the bond graph.

To examine this we rst take a look at the algorithms for propagating causality and generating equations.

We note that due to the variable causality we need a causality propagation algorithm that allows dier- ential causality at storage elements. Otherwise every mode has to be checked so it does not include any dif- ferential causality. And even if this work is done, the achieved model will be no good, since it most likely includes algebraic connections between R -elements.

The mscap algorithm, described in 9] will serve

our purposes.

(3)

The next step is to determine an algorithm for generating equations. This algorithm has to gener- ate equations where the generalized momenta are ex- plicit. This is easily done by expressing the equa- tions using all independent and dependent state vari- ables, x

i

and x

d

. The independent state variables are the state variables at the storage elements with preferred causality and the dependent states are the state variables at the storage elements with non- preferred causality. Since the generalized momenta are the states in the storage elements the equation generation algorithm in 3] generates equations in the desired form.

The algorithm starts with deriving expressions for x _

i

in x

i

and _ x

d

. Then x

d

are expressed in x

i

. The generated dierential algebraic equation (DAE) will have the following structure:

x _

i

= f

1

( x

i

 x _

d

) x

d

= f

2

( x

i

)

where x

i

are the independent states and x

d

the de- pendent.

5 Initialization of a Mode

The simulation procedure for a switched bond graph, found, e.g. , in 3], can roughly be described as an iteration of three steps:

1. Simulation of a mode

2. Detection of a violated transition condition 3. Initialization of a new mode

The rst step is similar to simulation of classical bond graphs 2, 5] and hence well known. The second step is a part of the numerical integration 1] when sim- ulating a hybrid system. Here the third step will be examined.

Our aim is to nd as small sets of storage ele- ments as possible for which the sum of generalized momenta is kept constant. These sets can be found using causality propagation. Therefore the causality is propagated in the mode specic bond graph de- scribing the new mode.

First of all we note that in storage elements with preferred causality the value of the state is calculated using integration. Such state will be continuous if the rate variable does not contain impulses of innite magnitude. Assuming that the input signals to all modulated sources are continuous, the discontinuities can only appear at a storage element with preferred causality if it is in the same causal path as a storage element with non-preferred causality 4].

We can now roughly divide the storage elements into two sets. The rst containing storage elements with preferred causality that are not included in any causal path containing storage elements with non- preferred causality. The second set contains storage elements with non-preferred causality, and storage el- ements connected to such storage elements by causal paths.

From the discussion above the state variables in the

rst set are easily initialized. Since they are continu- ous throughout the mode change they are initialized with the values they had when leaving the previous mode. If t is the time when changing modes, this means that x ( t ) = x ( t

;

).

For the other set of state variables, generalized mo- mentum has to be used. To further simplify the prob- lem, this set is divided into subsets. To construct such a set, start with a storage element with non- preferred causality. Include all storage elements that are connected to this element through a causal path.

Continue to extend the set with storage elements con- nected to elements in the set through causal paths.

The constructed set is the smallest set containing the initial storage element where the conservation of gen- eralized momentum can be used 4].

Derive the equations for the storage elements in

the constructed set. These equations will be of the

(4)

following form:

x _

1

=

Xn

i=k +1



x _

i

+ f

1

( x

o

) 

...

x _

k

=

Xn

i=k +1



x _

i

+ f

k

( x

o

)  (1)

x

k +1

= f

k +1

( x

1

::: x

k

)  x

n

= f

n

( x

1

::: x ...

k

)

x

1

::: x

n

are the states corresponding to the stor- age elements in the set. x

o

are the states correspond- ing to all other storage elements. k is the number of storage element in the set with preferred causality.

By integrating the rst k equations and moving all the rates to the left hand side, k equations with the following structure are found:

x

l

+

Xn

i=k +1



x

i

=

Z

f

l

( x

o

) (2) The integrand in right hand side is continuous across the mode change, hence the value of the integral does not change:

x

l

( t ) +

Xn

i=k +1



x

i

( t ) = x

l

( t

;

) +

Xn

i=k +1



x _

i

( t

;

) (3) These equations describe the conservation of gener- alized momentum.

By using the k equations like equation (3) that are achieved by integration, and the last n

;

k equa- tions in the system of equations (1) a solvable sys- tem of equations with n equations and n variables is achieved. The solution of this system determines the initial values of the states.

By the use of Pantelides algorithm 6] it is clear that extra constraints are added to the rates if the last n

;

k equations are dierentiated. These equa- tions together with the rst k equations in (1) give another solvable system of equations. This system is solved to initialize the rates.

6 Detection of impulses

When the initialization is completed, discontinu- ities have to be found. The initialization procedure catches the steps in states and rates, but impulses are not detected. A simple method for nding im- pulses in the rate variables is to detect steps in the state variables. If there is a step in the state variable, there is a impulse in the rate variable.

If a conict mode is entered during simulation ei- ther the mode is left immediately or there is a prob- lem with the system or the model. If the mode is left immediately it is often due to a impulse occur- ing when entering the mode. This pulse can be de- tected with by replacing the source having conicting causality with a dual, innity valued source as shown in Figure 3.

Sf : f

1

Se : e

2

Se : e

1

Sf : f

2

e

b

f

b

Figure 3: Replacement of sources.

The value of f

1

is put to sign ( e

1;

e

b

)

1

and the value of e

2

is put to sign ( f

2;

f

b

)

1

.

7 Complete Initialization Algo- rithm

With these method for initialization and impulse detection, the complete algorithm for initializing a mode is the following:

Algorithm 1

1. Save the state values of both dependent and in- dependent states when leaving the old mode.

2. Find the new mode. This is easily done when knowing what transition condition is met.

3. Find the new initial state.

(5)

(a) Solve a system of equations to determine the states. The system of equation is found using equations generated from the mode speci c bond graph and equations describ- ing conservation of generalized momentum.

(b) Solve another system of equations to de- termine the rates. These equations are found using equations generated from the mode speci c bond graph and by di eren- tiating other equations generated from the bond graph.

4. Find discontinuities.

(a) Find impulses in the rates by detecting steps in the states.

(b) Find impulses due to a causal conict by replacing sources.

5. Find a violated switch conditions. If no condi- tion is violated, simulate the mode, else goto 1.

8 An Example

The example in this section is academic, but it serves it purpose to show the use of generalized momentum.

The example is depicted in Figure 4. All wheels are assumed to roll without friction, and the two small wagons are assumed to be weightless. To simplify things all constitutive relations are assumed to be linear with the constants given in the gure.

The switched bond graph describing the example system is shown in Figure 5.

F

k1 k2

k3

k4 k5 s1 d1 m1

Figure 4: An academic mechanical example.

Assume that the initial state in the system is such that the plates in the end-stop s

1

are in contact, and

Se:F 0

I:m1 C1:k11 C

2 :

1

k

2

C3:

1

k

3 C

4 :

1

k

4

C

5 :

1

k

5 R:d1

Sw

1 0 1

1 1

Figure 5: The switched bond graph model of the ex- ample.

that they do not immediately loose contact. Then the switch is initialized in mode

F

, xing the veloc- ity dierence between the plates to zero. The ini- tial mode with propagated causality is shown in Fig- ure 6. From the gure it is clear that all storage elements have preferred causality. This leads to six independent state variables: x

1

::: x

5

belonging to

C -element C

1

:::  C

5

respectively and x

6

belonging to the I -element. Assume also that the force F acts

Se:F 0

I:m1 C1:k11 C

2 :

1

k

2

C

3 :

1

k

3 C

4 :

1

k

4

C5:

1

k

5 R:d1

Sf:0 1

0 1

1 1

Figure 6: The rst mode with propagated causality.

on the system in such a way that eventually the con- tact will be lost at the end-stop. When the contact is lost, the switch changes states and a new mode is entered. The mode specic bond graph for this mode is shown in Figure 7. We see that the causality has changed at the switch and at the C -element that models spring k

5

. In this mode there are only 5 in- dependent states. The state belonging to C -element

number 5 is dependent.

During a simulation run, when a transition condi-

tion is met, the values of the states, both dependent

and independent, will be returned. Let t be the time

when the mode change takes place. The returned val-

(6)

ues are the values of X = ( x

1

::: x

6

)

T

at time t

;

, X ( t

;

). With these values given, the initial state of the new mode, X ( t ), can be derived.

State x

1

and x

6

are easily initialized since both are connected to elements with preferred causality that does not have any causal paths to elements with non-preferred causality. These two states are con- tinuous, and therefore x

1

( t ) = x

1

( t

;

) and x

6

( t ) = x

6

( t

;

).

Se:F 0

I:m1 C1:k11 C

2 :

1

k2

C3:

1

k

3 C4:

1

k

4

C

5 :

1

k

5 R:d1

Se:0

1 0

1

1 1

Figure 7: The second mode with propagated causality.

The dashed lines show causal paths between storage elements.

In Figure 7 we can se that there are causal paths connecting the other four storage elements, and that one of them has non-preferred causality. Hence the corresponding set of states is a smallest possible set that can be initialized independently of other states using generalized momentum.

To examine this in detail we start at C

5

and

express its state variable by using the propagated causality:

x

5

= 1 k

5

(

;

k

4

x

4

+ k

2

x

2

+ k

3

x

3

) (4) Then start at C

2

, C

3

, and C

4

and express their rate variables by using the propagated causality:

x _

2

=

;

x _

5

+ k

1

d

1

x

1

(5)

x _

3

=

;

x _

5

+ k

1

d

1

x

1

(6)

x _

4

= _ x

5

(7)

To initialize the states, use equation (4) and the generalization of momentum conservation. Integrate

equations (5), (6), and (7) and rearrange them:

x

2

+ x

5

= k

1

d

1

Z

x

1

+ C

1

(8) x

3

+ x

5

= k

1

d

1

Z

x

1

+ C

2

(9)

x

4;

x

5

= C

3

(10)

This tells us that the variables, the generalized mo- menta, have certain values at time t . Since the inte- grands in the right hand side are continuous during the change of mode, the follow equations have to hold:

x

2

( t ) + x

5

( t ) = x

2

( t

;

) + x

5

( t

;

) (11) x

3

( t ) + x

5

( t ) = x

3

( t

;

) + x

5

( t

;

) (12) x

4

( t )

;

x

5

( t ) = x

4

( t

;

)

;

x

5

( t

;

) (13) Equation (4) together with equations (11), (12), and (13) will together determine x

2

 x

3

 x

4

, and x

5

at time t .

By using Pantelides algorithm one can see that there is more information about the derivatives to be found there is another equation with a non- trivial relation between the rates equation including the derivatives. Also according to Pantelides algo- rithm, this equation is obtained by dierentiating equation (4):

x _

5

= 1 k

5

(

;

k

4

x _

4

+ k

2

x _

2

+ k

3

x _

3

) (14) This leads to an equation system with four equa- tions, (5), (6), (7), and (14) and four unknowns, x _

2

 x _

3

 x _

4

 x _

5

(since x

1

is known).

We can conclude that by solving two sets of alge- braic equations all initial conditions for the new mode are determined.

9 Summary

Two problems appearing when simulating a switched bond graph is the initialization of a new mode, and the detection of impulses that appear due to the ideal behavior of the switch.

The initialization procedure relies on a generaliza-

tion of the principle of conservation of momentum.

(7)

Using this generalization, together with Pantelides algorithm, systems of equations can be derived. The solutions to these systems will give the initial values for states and rates.

Impulses are not detected in this way, but a step in a state variable leads to an impulse in a rate variable.

Impulses can also be detected by a proper treatment of conicting sources. By replacing a source that has a causal conict with a dual source with innite mag- nitude, impulses are detected.

References

1] K.E. Brenan, S.L. Campbell, and L.R. Petzold.

Numerical Solution of Initial-Value Problems in Di erential-Algebraic Equations. North-Holland, 2 edition, 1989.

2] F.E. Cellier. Continuous System Modeling.

Springer-Verlag, rst edition, 1991.

3] K. Edstrom. Simulation of mode switching sys- tems using switcehd bond graphs. Linkoping Uni- versity, December 1996. Lic. thesis.

4] K. Edstrom. Yet to be written. Technical report, Automatic Control, Linkoping University, 1997.

5] D.C. Karnopp, D.L. Margolis, and R.C. Rosen- berg. System Dynamics, A Uni ed Approach. Wi- ley Interscience, 1990.

6] C. Pantelides. The consistent initialization of dierential-algebraic systems. SIAM J. Sci. Stat.

Comput., 9(2):213{231, March 1988.

7] J.-E. Stromberg. A Mode Switching Modeling Philosophy. PhD thesis, Linkoping University, 1994.

8] J.-E. Stromberg, J. Top, and U. Soderman. Vari- able causality in bond graphs caused by dis- crete eects. In Proc. First Int. Conf. on Bond Graph Modeling and Simulation (ICBGM'93), volume 25 of SCS Simulation Series, pages 115{

119, 1993.

9] J. van Dijk. On the Role of Bond Graph Causality

in modelling mechatronic systems. PhD thesis,

University of Twente, 1994.

References

Related documents

Stability results for limit cycles with a first- order sliding mode as well as fast switchings close to a second-order sliding mode were de- rived in Johansson et al.. (

De anhörigas ekonomi kunde även påverka omvårdnaden av den med Alzheimers sjukdom då alla barn inte fick betald ledighet, de kunde därför inte finnas tillgängliga för

Hence we can con- clude that the value of the state variable at a storage element with prefered causality that has no causal path to a storage element with non-prefered causal- ity

In the same way as the principle of momen- tum conservation is used in mechanical systems to describe instant changes, generalized mo- mentum conservation can be used in switched

EFEEE. The initialization rule for this mode will give a value of the relative velocity of the masses that contradicts the constitutive relation of the switch. Hence the mode is

In this paper a physically based initialization algorithm for a system modeled with switched bond graphs 6] is analyzed using singular perturbation theory.. All proofs have

The conceptual modelling language proposed for mode- switching physical systems is referred to as switched bond graphs.. One reason for the name is that the lan- guage heavily relies

While the specialization of prison officer work is a techni- cal means to manage the dilemma, the occupational culture and identities are collective, social and individual ways