Aspects on simulation of switched bond graphs
Krister Edstrom
(edstrom@isy.liu.se) Dept. of Electrical Engineering
Linkoping University S-581 83 Linkoping, Sweden
Jan-Erik Stromberg
(janerik@s3.kth.se)
Dept. of Sensors, Signals and Systems Royal Institute of Technology
S-100 44 Stockholm, Sweden
Jan Top
(j.l.top@ato.dlo.nl)
Agrotechnological Research Institute ATO-DLO, P.O. Box 17
NL-6700 AA Wageningen, The Netherlands Abstract
By mode-switching systems we mean physical systems characterized by transitions which are at least an order of magnitude faster than the overall time-scale. There are essentially two dierent ways to model such systems for simulation. One is to employ continuous models and sti solvers. This approach is becoming more feasible as more sophisticated sti solvers become available, but still suers from poor performance for larger models.
An alternative approach is to employ hybrid mod- els with instantaneous transitions between continuous mode-models. In this case solvers capable of detecting zero-crossings are required. The advantage of this ap- proach is an improved simulation performance but the disadvantage is that one has to deal with more com- plex models. To handle the model complexity matter we have previously proposed switched bond graphs as a solution. Employing switched bond graphs, the prob- lem of complex models is modied to the problem of translating the bond graph to a computational model.
This is the problem addressed here.
1 Introduction
By a mode-switching system we mean a dynamic sys- tem undergoing fast transitions between continuous modes of operation. To simulate such systems, there are essentially two fundamental approaches. One is to handle the fast transitions by means of sti solvers.
This approach is becoming more feasible as more pow- erful sti solvers are developed 8, 9, 4]. The advantage of this approach is that the modelling process is not further complicated.
The other fundamental approach is to approximate the fast transitions by ideal instantaneous mode-
transitions. By using modern solvers capable of de- termining the zero-crossing of transition conditions, such simulations have the potential of becoming highly ecient. The disadvantage though, is a more com- plex modelling process. On the other hand, once such a mode-switching model has been successfully con- structed, that same model is much more clear from a conceptual point of view than its continuous counter- part. In other words, assumptions made by the mod- eller, often left implicit, now become much more clear from the model itself.
In this paper we will brie y review the diculties as- sociated with the second approach above. We will also review some potential solutions as provided by switched bond graphs earlier presented in 18, 14, 17]. Finally, for a specic subset of switched bond graphs, we elab- orate on the automated compilation of executable code to be linked with a specic numerical solver capable of detecting zero-crossings. Hence this paper contributes to the overall goal of providing more powerful tools for the ecient modelling and simulation of physical sys- tems undergoing abrupt mode-transitions.
2 Idealisation in terms of instantaneous mode-transitions
Consider a system where fast (with respect to the over- all time-scale) transitions are approximation by means of ideal instantaneous mode-transitions. This is mod- elled by a set of continuous dynamic mode-models and a set of discrete mode-transitions. Each mode- transition is further associated with a transition condi- tion. A transition condition is a Boolean combination of relations over variables in continuous mode-models.
A transition condition species when a specic mode-
transition is to take place.
The most fundamental problem with this approach is that of complexity. The number of mode-models grows very quickly with the number of switching mechanisms in the system. Making sure that all mode-models have been covered, quickly becomes an overwhelming prob- lem. Not the least, we also have the non-trivial prob- lem on how to correctly specify the mode-transitions to ensure proper switching behaviour over all input tra- jectories. Furthermore, once a model has proved to be correct, the same problem occurs when the physical system itself or the model requirements changes.
Following the traditions of bond graphs 12, 11], we have proposed an approach 18, 13, 16, 20] to handle these problems by making a clear distinction between 'low-level' computational matters and 'high-level' phys- ical concepts. In this view, mode-models and mode- transitions are considered as low-level computational details. By introducing proper high-level physical con- cepts, we hope to reduce the complexity of the mod- elling process. In other words, we aim at reducing the complexity as seen by the modeller, while maintain- ing the computational complexity, as dealt with by the numerical solver.
Adopting this approach, the original problem of the modelling process is shifted to that of properly trans- lating a conceptual model into a computational one.
Preliminary results obtained using switched bond graphs 20, 16, 13], and similar approaches using, e.g. , object-oriented modelling 7, 5, 1, 19, 2, 6], indicate that this process can be automated in many cases of practical interest.
3 Switched bond graphs
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 on the theory of 'classical' bond graphs as developed by numerous researchers 3] since their introduction in 1958 by H.M. Paynter. In a sense, switched bond graphs can be seen as an extension of classical bond graphs. For instance, switched bond graphs only add one more physical concept to the clas- sical list of nine elements, namely the primitive ideal switch concept, denoted Sw .
On the other hand, the role of causality plays a sig- nicantly dierent role in switched bond graphs. For instance, while causality is a xed property in classi- cal bond graphs, it is a time-varying property in the switched counterpart. In addition, the notion of a con- stitutive relation associated with each primitive physi- cal element, is extended by the notion of a switch con- trol structure associated with the primitive switch con- cept. Both these important aspects of switched bond
^
=
E]
!^
=
F]
!Sw :
Se : 0
Sf : 0
f e
e = 0 f
f = 0 e
Figure 1: Denition of the Sw -element.
graphs are clear from the following denition of the primitive ideal switch concept.
Denition 1 The (primitive) switch element is a bond graph element, i.e. a node in the graph, dened by Fig. 1, where
2fEFgis a Boolean state vari- able and an arbitrary label both associated with the switch. State =
F( =
E) is referred to as the ow (eort) state.
The state of the Sw -element is governed by a switch control structure (SCS) associated with each
Sw -element. The SCS is, in its simplest case, a state- transition system with two states only. This particular instance of SCS is referred to as a switch transition system (STS).
As for all other primitive elements of the bond graph language, the switch element is used in combination with the other elements to form models of mechanisms found in physical systems. For instance, to model the electrical mechanism illustrated in Fig. 2, we employ rules from classical bond graph theory to end up with
+ U
- C
Sw
1R
1Sw
2R
2e + -
1e +
2-
u
1u
2Figure 2: A simple electric mechanism.
the switched bond graph in Fig. 3. Switch Sw
1is dier-
ent from Sw
2in the sense that it is not only controlled
by the external signal u
1, but also by e
1, as will be
claried later.
0 1
1
u
2Se
C
R
1Sw
1R
2u
1e
1f
1Sw
2f
2e
2Figure 3: The switched bond graph for the electric mech- anism above.
To simulate a system by means of a switched bond graph we will have to translate it to a form accept- able for a numerical solver. Once again, following the traditions of classical bond graphs, this translation is divided into two steps. First the bond graph is trans- lated to a solver-independent mathematical represen- tation, and secondly, this intermediate representation is translated into solver-specic executable code. For strictly continuous systems and classical bond graphs, the intermediate form is a dierential (and algebraic) equation (DAE) system.
In the classical bond graph literature, the DAE form it- self as well as the process of automatically deriving the DAE from a bond graph, are both thoroughly stud- ied 21]. However, for switched bond graphs there is neither a corresponding form, which is generally ac- cepted, nor a good understanding of the automated derivation of such a form. In what follows we will therefore present an intermediate form and also look into some aspects of the derivation of the same from switched bond graphs. The nal step to produce the executable solver-specic code, will then be fairly straightforward, provided the intermediate form is cho- sen carefully enough.
4 Mode transition systems
It is clear that the intermediate solver-independent structure, underlying a switched bond graph, must be a hybrid system in the sense that it combines contin- uous dynamics with discrete mode-transitions. More precisely, the formal structure proposed here, consists of the following sets of objects:
L
is a non-empty set of mode labels
Z is a non-empty set of real-valued model vari- ables (power and energy variables)
U
Z is a non-empty set of real valued (inde- pendent) input variables
M
is a (possibly empty) set of continuous mode- models over the variables in Z , such that vari- ables in U appear only as independent variables
G
is a non-empty set of binary decisions over the variables in Z
A
is a (possibly empty) set of initialisation rules of the form x := ( z
1z
2::: ) where x
2Z
;U z
i2Z and :
Rn !Ris any (static) map.
From these sets we then form a composite hybrid model structure
Q =
hLZU
MGAiThe hybrid model structure can be viewed as a 'library' containing the necessary components for describing the hybrid system. In order to describe an instance of a hybrid system we need to combine the el- ements in the 'library' in a suitable manner. This leads us to the denition of a mode transition system (MTS).
Denition 2 Let Q be a properly dened hybrid model structure. Then a mode transition system (MTS) is a three-tuple
hMTQ
iwhere M is a non-empty set of modes m and T a non-empty set of transitions . A mode m is a pair ( l ) where l is a discrete state, i.e., an assignment of the state variables in
Land
2Mis a continuous mode-model.
A transition is a three-tuple
hega
iwhere e
2M
M is an ordered pair ( mm
0) of modes mm
0 2M , g
2G
is a Boolean transition condition and a
2 Ais an initialisation rule.
In addition we require that there is only one transition
for each distinct pair ( mm
0) of modes and that there are no self-loops, i.e., reexive transitions of the type
h
( mm ) ga
i.
The MTS is hence the intermediate solver-independent form proposed for mode-switching physical systems. In order to discuss the translation of a switched bond graph to an MTS we now need a formal specication of individual switches. To simplify and clarify the transla- tion problem, we will restrict ourself to switched bond graphs with only one-port switches that have 'simple' transition conditions of a particular kind. This partic- ular sub-class of switches are called primitive switches.
We will also restrict ourselves to a procedure where no
simplication of the generated MTS is done. Our last
assumption is that there does not exist any causal con- icts in any mode. This is the most restrictive assump- tion since it is very common to have causal con icts in some modes, and it is made to avoid a too detailed discussion.
For the specication of individual primitive switches, from which the composed MTS is to be derived, we now formalise the concept of a primitive switch transition system.
Denition 3 A primitive switch transition sys- tem (PSTS) is a three-tuple
hMTQ
iwhere
Q is a hybrid model structure
hLZU
MGiwhere
{
L=
fl
El
Fg{ U is a set of external real-valued (indepen- dent) input variables
{ Z =
fe f
gU , where the variables e and f are the port variables of the primitive switch itself
{
M=
ffe := 0
gf
f := 0
gg{
G=
fg
EF( z ) g
FE( z
0)
g, where
z = ( z
1:::z
k)
Tand z
0= ( z
10:::z
k00)
Tare vectors composed by the variables z
1:::z
kz
10:::z
k00 2Z
M =
fm
Em
Fgwhere
m
E= ( l
E fe := 0
g) m
F= ( l
F ff := 0
g)
T =
fEFFEgwhere
EF=
h( m
Em
F) g
EF( z )
i EF=
h( m
Fm
E) g
FE( z
0)
iNote that the PSTS is in fact an MTS, and further- more, the most simple MTS (with more than one mode) which one can derive from a switched bond graph.
To exemplify the PSTS, reconsider the example pre- sented in Fig. 2 and Fig. 3. Let the transition condi- tions for Sw
1be
fg
EF= u
1> 0 g
FE= e
1< 0
^u
1<
0
gand for Sw
2 fg
EF= u
2> 0 g
FE= u
2< 0
g, where
u
1and u
2are external control variables. The PSTS for
Sw
1is hence a three-tuple
hM
1T
1Q
1iwhere
Q
1is a hybrid model structure
hL
1
Z
1U
1M1G1iwhere
{
L1=
fl
El
Fg{ U
1= u
1{ Z
1=
fe
1f
1u
1g{
M1=
ffe
1:= 0
gf
f
1:= 0
gg{
G1=
fg
EF= u
1> 0
g
FE= e
1< 0
^u
1< 0
g
M
1=
fm
Em
Fgwhere
m
E= ( l
E fe
1:= 0
g) m
F= ( l
F ff
1:= 0
g)
T
1=
fEFFEgwhere
EF=
h( m
Em
F) g
EF( e
1f
1u
1)
i EF=
h( m
Fm
E) g
FE( e
1f
1u
1)
iThe PSTS of Sw
2will essentially be the same as the PSTS for Sw
1. Simply remove the condition e
1< 0 and change the indices from 1 to 2.
5 Composition of MTS
The interesting problem is how to compose an MTS from individual STS's in such a way that the semantics of the switched bond graph is preserved. The problem is interesting partly because there is no single answer to the question. One of the rst questions needed to be answered is whether two or more switch elements are allowed (or are able) to switch at the same time. As for every model, the answer to such a question depends on the purpose of the model, as well as on assumptions made by the modeller. The answer also depends on whether memory or computational speed is important.
The important thing is that the assumptions about the simultaneous switching is not encoded in the switched bond graph itself. Following the traditions of classi- cal bond graphs, this type of 'computational' issue has been postponed to the composition phase of the mod- elling process. Therefore we need to provide two dif- ferent composition operators depending on the prefer- ences of the modeller. Here we will only present one of these two operators, namely the interleaved compo- sition operator. The operator corresponds to the case in which only one switch is allowed to switch at a time.
This will increase the execution time, but decrease the size of the generated code for the model. The motiva- tion for this operator, the problems associated with it as well as the alternative composition operator can be found in 16, 13].
Denition 4 Let S
1=
hM
1T
1Q
1iand S
2=
h
M
2T
2Q
2ibe two MTS. The interleaved compo-
sition between the two systems S
1and S
2, denoted
S
1ji
jS
2, is an MTS, S =
hMTQ
iwhere:
Q is a hybrid model structure
hLZU
MGiwhere
{
L=
L1L2{ Z = Z
1Z
2{ U = U
1U
2{
M=
f12j12=
12 12M1and
22M2g{
G=
G1G2
M =
fm
12jm
12= (( l
1l
2)
12) ( l
11)
2M
1and ( l
22)
2M
2g
T = T
10T `
2where
h
(( l
1l
2)
12) (( l
01l
2)
012) g
1i2T
10i
h
( l
11) ( l
0101) g
1i2T
1and ( l
22)
2M
2h
(( l
1l
2)
12) (( l
1l
02)
102) g
2i2T
20i
h
( l
22) ( l
0202) g
2i2T
2and ( l
11)
2M
1Since the PSTS is a special case of MTS, the composi- tion operator dened holds for PSTS as well. From the construction of the interleaved composition operator it also follows that the composition of two arbitrary MTS becomes an MTS.
6 Simulation of switched bond graphs
Once the overall MTS for a given switched bond graph has been generated, the generation of executable solver- specic code is fairly straightforward. Typically the input to a solver, capable of detecting zero-crossings, is a set of equations dening the continuous dynamics in a given mode, and a set of equations dening the Boolean condition for exiting the given mode. These two data structures can now be directly derived from the MTS.
From a practical point of view, however, this approach may be problematic due to the exponential growth in complexity. Therefore the practical solution must typ- ically be a modication of the ideal approach outlined above. Nevertheless, the MTS still plays an important role in theoretical studies and formal analysis of hybrid systems 10, 15].
Returning to our example circuit in Fig. 2 and employ- ing the strategy outlined above, we end up in the MTS S =
hMTQ
i, where
Q is the hybrid model structure
hLZU
MGiwhere
{
L=
fl
EEl
EFl
FEl
FFg{ U =
fu
1u
2g{ Z =
fe
1f
1u
1e
2f
2u
2g{
M=
ffe
1:= 0 e
2:= 0
gf
e
1:= 0 f
2:= 0
gf
f
1:= 0 e
2:= 0
gf
f
1:= 0 f
2:= 0
gg{
G=
fg
EEjEF= u
2> 0 g
EEjFE= u
1> 0 g
EFjEE= u
2< 0 g
EFjFF= u
1> 0 g
FEjFF= u
2> 0
g
FEjEE= e < 0
^u
1< 0 g
FFjFE= u
2< 0
g
FFjEF= e < 0
^u
1< 0
g
M =
fm
Em
Fgwhere
m
EE= ( l
EE fe
1:= 0 e
2:= 0
g) m
EF= ( l
EF fe
1:= 0 f
2:= 0
g) m
FE= ( l
FE ff
1:= 0 e
2:= 0
g) m
FF= ( l
FF ff
1:= 0 f
2:= 0
g)
T =
fEFFEgwhere
EEjEF=
h( m
EEm
EF) g
EEjEFi EEjFE=
h( m
EEm
FE) g
EEjFEi EFjEE=
h( m
EFm
EE) g
EFjEEi EFjFF=
h( m
EFm
FF) g
EFjFFi FEjFF=
h( m
FEm
FF) g
FEjFFi FEjEE=
h( m
FEm
EE) g
FEjEEi FFjFE=
h( m
FFm
FE) g
FFjFEi FFjEF=
h( m
FFm
EF) g
FFjEFiNote that this MTS does not contain any explicit refer- ence to mode-models. Rather the reference is implicit in the
Land
Mstructures. To derive the mode-models we simply substitute the Sw -elements by appropriate zero-sources see Fig. 4.
0 1 1