• No results found

Physically based initialization of modes when simulating hybrid systems.

N/A
N/A
Protected

Academic year: 2021

Share "Physically based initialization of modes when simulating hybrid systems."

Copied!
6
0
0

Loading.... (view fulltext now)

Full text

(1)

Physically based initialization of modes when simulating hybrid systems.

Krister Edstrom

Department of Electrical Engineering Linkoping University, S-581 83 Linkoping, Sweden

WWW: http://www.control.isy.liu.se

Email: edstrom@isy.liu.se

August 20, 1998

REGLERTEKNIK

AUTOMATIC CONTROL LINKÖPING

Report no.: LiTH-ISY-R-2028 Submitted to Reglermote '98

Technical reports from the Automatic Control group in Linkoping are available by anonymous ftp at the address

ftp.control.isy.liu.se

. This report is contained in the compressed postscript

le .

(2)

Physically based initialization of modes when simulating hybrid systems.

Krister Edstrom

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

Linkoping University S-581 83 Linkoping, Sweden

1 Introduction

Hybrid system is a term used in many dier- ent areas to describe system combining dierent properties. In this context, hybrid systems are systems that are both continuous and discrete to their nature 3].

This paper deals with the problem of mod- eling and simulating hybrid systems 2, 6, 4].

More particularly, it deals with initializations of the continuous state variables after a discrete state change.

The tool used for describing the hybrid sys- tems is switched bond graphs. It is a tool for making graphical physical models of hybrid sys- tems.

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

i1 i2

Figure 1: A simple electrical example.

Example 1 Consider the two capacitors in Figure 1. When the switch is closed, their be- havior is determined by the principle of electric charge conservation, stating that the amount of charge over the two capacitors is kept constant.

This principle should be used to initialize the new mode. In this paper the charge conserva- tion is generalized in a bond graph framework.

When making a physical model of systems, the standard modeling procedure is to repeat- edly divide the system into subsystems, until each subsystem easily is described mathemat- ically. The models of the subsystem are then composed to a model describing the complete system.

The initialization procedure should also sup- port this structured way of making models.

No information should have to be added non- locally in order to generate correct initialization values.

2 Hybrid systems

The hybrid systems considered in this paper are continuous systems that are extended with dis- crete behavior. They arise from the natural pro- cess of model simplication. When making a model of a system, details that are considered to be unnecessary are left out in order to achieve a model that describes the interesting behavior of the system, without being to complex. Ex- amples of mechanisms and phenomena that can be modeled with instant changes when their be- havior is simplied are valves, diodes, mechan- ical collisions etc. If, e.g., a valve is placed in a systems where other parts are modeled with with continuous relations, the system is hybrid.

A mathematical description of such a hybrid

systems is the hybrid automaton 1], see Fig-

ure 2. In a hybrid automaton there is a set of

discrete states, sometimes called modes, each

containing a continuous description. There are

(3)

transitions that describe when a change of mode should occur, and to which mode the change is made. There is also a set of initialization rules, telling what values the state variables should have when starting simulation of a mode.

conditions continuous descriptions and initialization rules

mode1 mode 2

mode 3 mode 4

Figure 2: A simplied version of a hybrid au- tomata

3 Switched bond graphs

The bond graph language 7, 8] is a tool for physical modeling of systems following the law of energy conservation. For electrical systems the bond graphs have similarities with electri- cal circuit schemes, but bond graphs can also be used to model other types of systems like mechanical and hydraulic, and combinations of these.

The language contains a few elements, each describing how the energy in the system be- haves. There are sources where the energy is entered, storage elements where energy can be stored, resistive elements where energy is dis- sipated, and transforming elements where the energy is transformed and a possible domain change i made.

To make the description complete, relations describing the behavior in detail have to be added to each of the elements. In a bond graph, a pair of variables is used to describe these mathematical relations eort and ow vari- ables. The product of the two variables is of the quantity power. In the mechanical domain, force is the eort variable and velocity the ow variable. In the electrical domain eort is volt- age and ow is current.

There are two types of junctions that describe how the elements are connected. They corre- spond to series and parallel connection in elec- trical circuits.

Example 2 There is a bond graph model of an electrical circuit in Figure 3. The C - and I -

elements are storage elements, the Se -element is a source, the R -element is a dissipative el- ement and the 1 -junction is a series junction.

V

Se

R I

C 1

Figure 3: A bond graph model of an electrical circuit.

An advantage with bond graphs is the possi- bility to algorithmically, and graphically, deter- mine the causality, i.e., in what order to calcu- late the variables to get as close to a state space description as possible.

Switched bond graphs 10, 4] are an exten- sion of classical bond graphs in the sense that classical bond graphs support modeling of con- tinuous systems, while switched bond graphs also allow modeling of hybrid systems. When using switched bond graphs, the bond graph language is extended with a new element, a switch 11, 10]. The switch captures the discrete behavior with its two dierent states, denoted

E

and

F

. Fixed in the

E

-state the switch is re- placed 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 4. The causal assign- ment rules for the zero eort and ow sources are the same as for the ordinary sources.

Sw

Se:0

Sf:0

g

FE g

EF

E

F

Figure 4: The two states of a switch element.

Note that a switched bond graph can be viewed as a collection of classical bond graphs, each describing 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 classical bond graph for

each combination of switch states.

(4)

To complete the description of a switch, two transition conditions, g

EF

and g

FE

, have to be added. g

EF

gives the condition for switching from state

E

to

F

, and g

FE

the condition for switching the other way.

Since the bond graph language is build up by a few standard elements, there is a lot of struc- ture in the models. In the next section, Sec- tion 4, it is argued that this structure is crucial for the re-initializations after instant changes in a system during a simulation run. The struc- ture in the graph is also very helpful when an- alyzing the model, e.g., when tracing errors in the model after an erroneous simulation run. It is the graphical causality algorithm that allows this analysis.

On the other hand will the structure in the bond graph limit the expressibility. Bond graphs does not have the same expressive power as e.g., object orientation.

Another important aspect of switched bond graphs is that they allow a structural change in the mathematical description when changing modes. The order in which the variables are calculated may change, and even the number of states can dier between the modes. This is due to the causal rules of the switch. For simulation purposes this means that a switched bond graph simulation tool allows simulation of a larger class of systems than tools that do not allow structural changes.

4 Generalized momentum

The principle of momentum conservation and the principle of electric charge conservation are two principles of physics. We here argue that, seen from a bond graph perspective, they are dual descriptions of the same phenomena, gen- eralized momentum 5]. In 9] the phenomena is referred to as conservation of states.

The principle of momentum conservation states that the momentum

G =

X

m

k

v

k

=

X

Z

F

k

(1)

is always preserved when there are instant changes in a mechanical system, e.g., when masses collide. The sum is over the colliding masses. The principle of electric charge conser-

vation states that the charge

Q =

X

c

k

u

k

=

XZ

i

k

(2) is always preserved after instant changes in an electrical system, e.g., when connecting capac- itors in parallel. Here the sum is over the ca- pacitors in the parallel connection.

In a bond graph framework, a mass is mod- eled with an I -element. The mathematical re- lation corresponding to the I -element is:

x _ = e (3)

f = 1 I x (4)

In a mechanical system the e variable is the force F , and the f variable is the velocity v . The parameter I is the mass m . There is also a state variable x introduced as the integral of the force according to Equation (3). When rewrit- ing Equations (3) and (4) in the domain specic variables, the following equations are obtained:

x _ = F v = 1 m x

When comparing with Equation (1), we see that the state variable in the bond graph is the mo- mentum of the mass.

A capacitor is modeled with a bond graph C - element. The mathematical relation describing a C -element is the following:

x _ = f e = 1 C x

In an electrical system the e variable is voltage u , the f variable current i , and the parameter C is the capacitance C . The corresponding equa- tions using domain dependent notation are:

x _ = i u = 1 C x

Here the state is the integral of the current, i.e., the charge.

We see that the entities that are preserved

at instant changes in a system, e.g., electrical

charge and momentum, appear as state vari-

ables in a bond graph framework. We therefore

(5)

call a state variable in a bond graph generalized momentum.

The laws of charge conservation and momen- tum conservation can therefore be generalized in a bond graph frame work.

Denition 1 The generalized momentum for a storage element in a bond graph is described by its state variable.

The generalized momentum can be used in exactly the same way as momentum or charge when instant changes take place in a system.

Postulate 1 For instant changes in a bond graph the generalized momentum is kept con- stant.

When two masses collide, the total momen- tum for these two masses are kept constant, but the momentum for each mass may change. In a simulation run, the state variables for these two masses have to be initialized simultaneously af- ter the collision. In a switched bond graph it is algorithmic to nd the generalized momenta that have to be initialized simultaneously when performing a simulation run 5] by using causal analysis.

5 An example

Consider the electrical example in Figure 5.

The bond graph model of the circuit is depicted in Figure 6. Assume that we want to simulate the model, starting with the switch open, and at a certain point of time close the switch.

V1 C1 C2 V2

R1 R2

I

Figure 5: An electrical example.

To get a complete model, relations have to be added locally at each bond graph element. As- suming that all relations are linear, i.e., that we have linear electrical components, we only have to add the resistances, capacitances, etc. The switch conditions have to be added, e.g., that

the switch closes at t = 5. Initial conditions for the continuous state variables also have to be added.

Se1

Se2 R

1

R

2 C

1

C

2

I Sw

0 0

0 1 1

1

Figure 6: A switched bond graph model of the electrical example.

With this information the simulation is al- gorithmic from the bond graph 4, 5]. First equations describing the system with the switch open are generated by a standard bond graph equation generation algorithm:

x _

1

= 1 R

1

V

1;

R

1

1 C

1

x

1

x _

2

= 1 R

2

V

2;

R

2

1 C

2

x

2

x _

3

= V

2

These equations are sent to a solver, together with the transition conditions. There is a zero- crossing detector in the numerical solver, de- tecting when a transition condition is met, in this case when t = 5. When this happens, the simulation stops and the new mode is entered.

The new mode has to be initialized. One initialization equation is achieved by the gen- eralized momentum, stating that the electrical charge over the two capacitors should be kept constant. In this case the transition take place at time t = 5. The value at time t = 5 before initialization is denoted by x (5) and after by x (5

+

).

x

1

(5

+

) + x

2

(5

+

) = x

1

(5) + x

2

(5) (5) To be able to initialize x

1

and x

2

, one more equation is needed. This equation is found by deriving the equations for the second mode where the switch is closed:

x _

1

= 1 R

1

V

1

+ 1 R

2

V

2;

( 1 R

1

C

1

+ 1 R

2

C

1

) x

1;

x _

2

x

2

= C

2

C

1

x

1

(6)

x _

3

= V

2

Among these equations there is a static equa-

tion between x and x stating that the voltages

(6)

over the two conductors should be the same.

This equation has to hold initially.

Equations (5) and (6) are two equations in two unknowns that can be solved in order to initialize the second mode:

x

1

(5

+

) + x

2

(5

+

) = x

1

(5) + x

2

(5) x

2

(5

+

)

;

C

2

C

1

x

1

(5

+

) = 0

These equations can be generated and solved automatically from a switched bond graph 5].

When the second mode is properly initialized, the simulation continues, using the equations describing the second mode.

It can be noted that the equations describing mode two are not in state space form. The rea- son for this is that two storage elements are de- pendent in that mode. When closing the switch, the number of states is reduced. The reason for using three equations, when only two are needed for a state space description is to get a description where the generalized momenta are easy to nd.

We can also see that the information that is added locally at the dierent elements in the switched bond graph model, together with the description of how the elements are connected, is enough to derive the initial values of a new mode. No additional, global information has to be added to complete the model.

6 Conclusions

Switched bond graphs are natural extensions of classical bond graphs and they allow mod- eling of hybrid systems. If using switched bond graphs, there is an extension to the mechanical momentum. This extension, called generalized momentum, includes, e.g., charge in electrical circuits and volume in hydraulical systems.

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 bond graphs to determine initial conditions af- ter changing modes. Furthermore, the mode initialization procedure is algorithmic from a switched bond graph.

References

1] R. Alur, C. Courcoubetis, T.A. Henzinger, and Pei-Hsin Ho. Hybrid automata: An algorithmic approach to the specication and verication of hybrid systems. In Lec- ture Notes in Computer Science 736, pages 209{229. Springer-Verlag, 1993.

2] M. Andersson. Object-Oriented modeling and simulation of hybrid systems. PhD thesis, Lund Institute of Technology, 1995.

3] M.S. Branicky. Studies in hybrid systems:

modeling, analysis, and control. PhD the- sis, MIT, 1995.

4] K. Edstrom. Simulation of mode switch- ing systems using switched bond graphs.

Linkopings Universitet, December 1996.

Lic. thesis.

5] K. Edstrom. Mode initialization when sim- ulating switched bond graphs. In Proc.

of 2nd IMACS International Multiconfer- ence: CESA'98, Computational Engineer- ing in Systems Applications, 1998.

6] H. Elmqvist, F.E. Cellier, and M. Otter.

Object-oriented modeling of hybrid sys- tems. pages xxxi{xli. SCS, 1993.

7] D.C. Karnopp, D.L. Margolis, and R.C.

Rosenberg. System dynamics, A unied approach. Wiley Interscience, 1990.

8] L. Ljung and T. Glad. Modeling of dy- namic systems. Prentice-Hall, rst edition, 1994.

9] P.J. Mosterman and G. Biswas. For- mal specications from hybrid bond graph models. In Qualitative Reasoning Work- shop, Italy, June 1997.

10] J.-E. Stromberg. A mode switching mod- elling philosophy. PhD thesis, Linkopings Universitet, 1994.

11] J.-E. Stromberg, J. Top, and U. Soderman.

Variable causality in bond graphs caused by discrete eects. In Proc. First Int. Conf.

on Bond Graph Modeling and Simulation

(ICBGM'93), volume 25 of SCS Simula-

tion Series, pages 115{119, 1993.

References

Related documents

– In a MathScript node which appears as a frame  inside the Block diagram of a VI (available on the  Functions / Mathematics / Scripts & Formulas 

46 Konkreta exempel skulle kunna vara främjandeinsatser för affärsänglar/affärsängelnätverk, skapa arenor där aktörer från utbuds- och efterfrågesidan kan mötas eller

För att uppskatta den totala effekten av reformerna måste dock hänsyn tas till såväl samt- liga priseffekter som sammansättningseffekter, till följd av ökad försäljningsandel

Tillväxtanalys har haft i uppdrag av rege- ringen att under år 2013 göra en fortsatt och fördjupad analys av följande index: Ekono- miskt frihetsindex (EFW), som

Regioner med en omfattande varuproduktion hade också en tydlig tendens att ha den starkaste nedgången i bruttoregionproduktionen (BRP) under krisåret 2009. De

Den förbättrade tillgängligheten berör framför allt boende i områden med en mycket hög eller hög tillgänglighet till tätorter, men även antalet personer med längre än

Against this difficult background characterised by serious crop damage, livestock injury and death, human injury and death, the threat to wildlife from indiscriminate killing

Output data recorded into the project database are coordinates of facilities, real material flows (coordinates of definition points) and also changes raised during the layout design