Modelica: An International Effort to Design the Next Generation

advertisement

Modelica: An International Effort to Design the Next Generation

Modelling Language

Sven Erik Mattsson

Department of Automatic Control, Lund Institute of Technology, Box 118, SE-221 00 Lund, Sweden

E-mail: SvenErik@control.LTH.se

Hilding Elmqvist

Dynasim AB, Research Park Ideon, SE-223 70 Lund, Sweden

E-mail: Elmqvist@Dynasim.se

Jan F. Broenink

Control Laboratory, EE Department, University of Twente, P.O. Box 217, 7500 AE Enschede, Netherlands

E-mail J.F.Broenink@rt.el.utwente.nl

Abstract

A new language called Modelica for physical modelling is developed in an international effort. The main objective is to make it easy to exchange models and model libraries.

The design approach builds on non-casual modelling with true ordinary differential and algebraic equations and the use of object-oriented constructs to facilitate reuse of modelling knowledge. There are already several modelling language based on these ideas available from universities and small companies. There is also significant experience of using them in various applications. The aim of the Modelica effort is to unify the concepts and design a new uniform language for model representation. The paper describes the effort and gives an overview of

Modelica.

1. Introduction

Mathematical modelling and simulation are emerging as key technologies in engineering. Relevant computerised tools, suitable for integration with traditional design methods are essential to meet future needs of efficient engineering.

In September 1996 an international effort started to design a new language for physical modelling. The language is called Modelica

. The main objective is to make it easy to exchange models and model libraries and to allow users to benefit from the advances in object-oriented modelling methodology. This paper presents the status of the Modelica design as of

June 1997.

1.1 State-of-the art

There is a large amount of simulation software on the market. Most languages and model representations are proprietary and developed for certain tools. There are general-purpose tools such as ACSL, SIMULINK,

System Build, which are based on the same modelling methodology, input– output blocks or FORTRAN–like statements, as in the previous standardisation effort, CSSL [10]. There are domain oriented packages: electronic circuits (SPICE, Saber); multibody systems (ADAMS, DADS,

SIMPACK); chemical processes (ASPEN Plus, SpeedUp) etc. With few exceptions, all simulation packages are only strong in one domain and are not capable of modelling components in other domains reasonably. This is a major disadvantage since technical systems are becoming more and more heterogeneous with components from many engineering domains.

Techniques for general-purpose physical systems modelling have been developed during the last decades, but did not receive much attention from the simulation market. The modern approaches build on non-causal modelling with true equations and the use of object-oriented constructs to facilitate reuse of modelling knowledge. There are already several modelling languages with such a support available from universities and small companies. Examples of such modelling languages are ASCEND

[8], Dymola [3], gPROMS [1], NMF [9], ObjectMath [12], Omola [7],

SIDOPS+ [2], Smile [6], U.L.M. [5] and VHDL-AMS [4]. There is also significant experience of using these languages in various applications.

The aim of the Modelica effort is to unify the concepts of these languages in order to introduce a common basic syntax and semantics and to design a new unified modelling language for model representation.

1.2 The Modelica effort

The work started in the continuous time domain since there is a common mathematical framework in the form of differential-algebraic equation

(DAE) systems as result of the modelling process, and several modelling languages based on similar ideas exist. There is also significant experience of using these languages in various applications. It was thus appropriate to collect all knowledge and experience in order to design a new unified modelling language or neutral format for model representation.

Modelica is a trademark of the Modelica Design Group

The short range goal is to design a modelling language for physical systems modelling based on DAE systems with some discrete event features to handle discontinuities and sampled systems. The design should allow an evolution to a multi-formalism, multi-domain, generalpurpose modelling language.

The members of the Modelica design group are listed in Table 1, with

Hilding Elmqvist as chairman. Information on the Modelica effort is available on http://www.Dynasim.se/Modelica/

. The activity started in

September 1996 as an effort within the ESPRIT project Simulation in

Europe Basic Research Working Group (SiE-WG) [11]. In February 1997, the Modelica design effort became Technical Committee 1 within the

Federation of European Simulation Societies, EUROSIM .

Fabrice Boudaud

Jan Broenink

Dag Brück

Hilding Elmqvist

Thilo Ernst

Peter Fritzson

Alexandre Jeandel

Kaj Juslin

Sven Erik Mattsson

Martin Otter

Per Sahlin

Hubertus Tummescheit

Hans Vangheluwe

Gaz de France, Paris, France

Univ. of Twente, Enschede, Netherlands

Dynasim AB, Lund, Sweden

Dynasim AB, Lund, Sweden

GMD-FIRST, Berlin, Germany

Linköping University, Sweden

Gaz de France, Paris, France

VTT, Espoo, Finland

Lund University, Sweden

DLR Oberpfaffenhofen, Germany

BrisData AB, Stockholm, Sweden

GMD-FIRST, Berlin, Germany

University of Gent, Belgium

Table 1: The active members of the Modelica design group

2. An Introduction to Modelica

As introduction to Modelica, we will consider modelling of a simple electrical circuit as defined in Figure 1. The system can be broken up into a set of connected electrical standard components: a voltage source, two resistors, an inductor, a capacitor and a ground point. Models of these components are typically available in model libraries . Using a graphical model editor, we can define a model by drawing an object diagram as shown in Figure 1, by positioning icons that represent the models of the components and drawing connections. This composite model specifies the topology of the system to be modelled: components and their connections. The corresponding Modelica model looks like:

Figure 1 Electrical Circuit model circuit

Resistor R1 (R=10);

VsourceAC AC;

Capacitor C (C=0.01);

Ground G;

Resistor R2 (R=100);

Inductor L (L=0.1); equation connect (AC.n, C.n);

connect (G.p, AC.n); connect (R1.n, C.p); connect (AC.p, R1.p); connect (L.p, R2.n); connect (R1.p, R2.p); connect (C.n, L.n); end circuit;

The statement

Resistor R1 (R=10); declares a component

R1

of class

Resistor

and sets the default value of the resistance

R

to 10.

Connections specify interactions between components. In other modelling languages connectors are referred as cuts, ports or terminals. Defining a set of connector classes is a good start, when developing model libraries for a new application domain. It promotes compatibility of the component models. A connector must contain all quantities needed to describe the interaction. For electrical components we need the quantities voltage and current. Their types are declared as type Voltage = Real( Unit=”V”); type Current = Real( Unit=”A”); where

Real

is the name of a predefined class or type. A real variable has in addition to its value, a set of attributes such as unit of measure, initial value, minimum and maximum value. A connector class is defined as connector Pin

Voltage v; flow Current i; end Pin;

A connection connect (Pin1, Pin2),

with

Pin1

and

Pin2

of connector class

Pin

, connects the two pins such that they form one node. This implies two equations, namely

Pin1.v = Pin2.v

and

Pin1.i + Pin2.i = 0

.

The first equation indicates that the voltages on both branches connected together are the same, and the second corresponds to Kirchhoff's current law saying that the current sums to zero at a node (assuming positive value while flowing towards the component). The sum–to–zero equations are generated when the prefix flow

is used in the connector definition.

Similar laws apply to flow rates in a piping network and to forces and torques in a mechanical system.

A common property of many electrical components is that they have two pins. It means that it is useful to define a “shell'' model class: partial model TwoPin

"Shell model with two electrical pins"

Pin p, n;

Voltage v;

Current i; equation

v = p.v - n.v;

p.i + n.i = 0;

i = p.i; end TwoPin; that has two pins, p

and n

, a quantity, v

, that defines the voltage drop across the component and a quantity, i

, that defines the current into the pin p

, through the component and out from the pin n.

The equations define common relations between quantities of a simple electrical component. In order to be useful, a constitutive equation must be added. The keyword partial

indicates that this model class is incomplete. After the name of a class, a one–line comment can be given serving as documentation. Tools may display this documentation in special ways.

To define a model for a resistor we exploit

TwoPin

and add a definition of parameter for the resistance and Ohm's law to define the behaviour: model Resistor "Ideal resistor" extends TwoPin; parameter Real R(Unit = "Ohm") "Resistance"; equation

R*i = v; end Resistor;

The keyword parameter

specifies that the quantity is constant during a simulation experiment, but can change values between experiments.

Models for electrical capacitors, inductors and other elements are defined in a similar way. We only give the capacitor model for space reasons

( der(v) means the time derivative of v

): model Capacitor "Ideal capacitor" extends TwoPin; parameter Real C(Unit="F") "Capacitance"; equation

C*der(v) = i; end Capacitor;

A model for the voltage source can be defined as: model VsourceAC "Sine-wave voltage source" extends TwoPin; parameter Real VA = 220 "Amplitude [V]"; parameter Real f = 50 "Frequency [Hz]"; private constant Real PI=3.141592653589793; equation

v = VA*sin(2*PI*f*Time); end VsourceAC;

Finally, we must not forget the ground point: model Ground "Ground"

Pin: p; equation

p.v = 0; end Ground;

The purpose of the ground model is twofold. First, it defines a reference value for the voltage levels. Secondly, the connections will generate one

Kirchhoff's current law too many. The ground model handles this by introducing an extra current quantity p.i,

which implicitly is defined to be zero by the equations.

3. More Advanced Modelling Features

The Modelica language has been introduced by giving an elementary example. Model classes and their instantiation form the basis for hierarchical modelling . Connectors and connections correspond to physical connections of components. At the lowest level, equations are used to describe the relation between the quantities of the model. The expressive modelling power of Modelica is large. The more powerful constructs are summarised below.

Modelling of, for example, multi-body systems, control systems and approximations to partial differential equations is done conveniently by utilising matrix equations . Multi-dimensional matrices and the usual matrix operators and matrix functions are thus supported in Modelica. It is also possible to have arrays of components and to define regular connection patterns. A typical usage is the modelling of a distillation column which consists of a set of trays connected in series.

Reuse of model library components is supported by allowing also model classes to be parameterised. An example is a controlled plant where some

PID controllers are replaced with auto–tuning controllers. It is of course possible to just replace those controllers in a graphical user environment, i.e. to create a new model. The problem with this solution is that two models must be maintained. Modelica has the capability to instead just substitute the model class of certain components using a language construct at the highest hierarchical level, so only one version of the rest of the model is needed.

Realistic physical models often contain discontinuities , events or changes of structure . Examples of such phenomena are relays, switches, friction, impact, sampled data systems etc. Modelica supports such models by allowing the use of finite state machines and petri nets in a way that a simulator can introduce efficient handling of such events. Special design emphasis is given to synchronisation and propagation of events and the possibility to find consistent restarting conditions after an event.

4. Non-Causal Modelling

Graphical system input tools are an important part of simulationist’s toolkit.

However, graphical system input on its own is not sufficient to solve all problems. It is important to have an appropriate framework for model representation. Most of the general-purpose simulation software on the market such as ACSL, SIMULINK and SystemBuild assume that a system can be decomposed into block diagram structures with causal interactions.

This means that models are expressed as an interconnection of submodels having their inputs and outputs explicitly stated. The connections of outputs to inputs must not lead to algebraic loops. It is rare that a natural decomposition into subsystems lead to such a model. Often a significant effort in terms of analysis and analytical transformations is needed to obtain a problem in this form. It requires a lot of engineering skills and manpower and it is error-prone. To illustrate this, a block diagram description of the system in Figure 1 is shown in Figure 2.

The topology of the circuit is not preserved in the block diagram.

Furthermore, different types of blocks are needed for the two resistors.

The block

Res2

, which represents the resistor

R2

has the current as input and calculates the voltage drop as output, while the block

Res1

, which

Figure 2 Block diagram of the circuit of Figure 1 represents the resistor

R1

has reversed computational causality with the voltage drop as input and the current as output. This means that we need to have two different blocks for resistors and it is the user's task to find out which to use. Furthermore, in most cases this is not sufficient, because despite how the blocks are selected there is an inherent algebraic loop. A very simple example is two resistors in series connected to a voltage source.

Modelica supports object-oriented modelling , where behaviour on the lowest level may be expressed in terms of ordinary differential equations and algebraic equations, so called differential-algebraic equation (DAE) systems, which is the natural mathematical framework for continuous time models.

The Modelica language has been carefully designed in such a way that computer algebra can be utilised to achieve as efficient simulation code as if the model would be converted to ODE form manually.

5. Conclusions

The Modelica effort has been described and an overview of Modelica has been given. A first version of the language definition is scheduled to be available in September 1997. More information, including modelling requirements, rationale and definition of the Modelica language is available on WWW at http://www.Dynasim.se/Modelica /.

Acknowledgements

The authors would like to thank the other members of the Modelica Design

Group for inspiring discussions and their contributions to the Modelica design.

References

1 Barton, P.I. and Pantelides, C.C., "Modeling of Combined Discrete/Continuous

Processes", AIChE J., vol. 40, 966-979, (1994).

2 Breunese, A.P.J. and Broenink J.F., "Modeling mechatronic systems using the SIDOPS+ language", Proceedings of ICBGM'97, 3rd International

Conference on Bond Graph Modeling and Simulation", Simulation Series,

The Society for Computer Simulation International, vol. 29, (1), 301-306,

(1997).

3 Elmqvist, H., Brück D. and Otter M., "Dymola – User's Manual", Dynasim AB,

Lund, Sweden, (1996).

4 IEEE, "Standard VHDL Analog and Mixed-Signal Extensions", IEEE , 1076.1,

(1997).

5 Jeandel, A., Boudaud, F., Ravier, Ph. and Buhsing, A.", "U.L.M: Un Langage de Modélisation, a modelling language", Proceedings of the CESA'96 IMACS

Multiconference, Lille, France, IMACS, (1996).

6 Kloas M., Friesen V. and Simons M., "Smile – A Simulation Environment for

Energy Systems", Proceedings of the 5th International IMACS-Symposium on

Systems Analysis and Simulation, Sydow, A. (ed.), System Analysis

Modelling Simulation series, Gordon and Breach Publishers, vol. 18–19,

503–506 (1995).

7 Mattsson, S.E., Andersson M. and Å strö m K.J., "Object–Oriented Modelling and Simulation", CAD for Control Systems, E.D. Linkens (ed.) Marcel Dekker

Inc, New York, ISDN 9203500, Chapter 2, 31-69, (1993).

8 Piela, P.C., Epperly, T.G., Westerberg, K.M. and Westerberg, .W., “ASCEND:

An Object-Oriented Computer Environment for Modeling and Analysis: the

Modeling Language", Computers and Chemical Engineering, vol. 15 (1), 53-

72 (1991).

9 Sahlin P., Bring A. and Sowell E.F., "The Neutral Model Format for Building

Simulation, Version 3.02", Department of Building Sciences, The Royal

Institute of Technology, Stockholm, Sweden", (1996).

10 Strauss, J.C., Augustin, D.C., Fineberg, M.S., Johnson, B.B., Linebarger,

R.N., Samsom, F.J. "The SCi continuous system simulation language

(CSSL), Simulation", vol. 9 (12), 281-303, Sept 1967.

11 Vangheluwe, H.L., Kerckhoffs, E.J.H. and Vansteenkiste, G.C., “Simulation for the Future: Progress of the ESPRIT Basic Research Working Group 8467,

Proceedings of the 1996 European Simulation Symposium (Genoa), A.

Bruzzone and E. Kerckhoffs (eds), Society for Computer Simulation

International, ISBN 1-56555-099-4, pp XXIX – XXXIV, October 1996; See also http://hobbes.rug.ac.be/SiE/

12 Viklund, L. and Fritzson, P., "ObjectMath – An Object-Oriented

Language and Environment for Symbolic and Numerical Processing in

Scientific Computing", Scientific Programming, vol. 4, 229–250, (1995)

Bibliography

Sven Erik Mattsson attained his Ph.D. degree in automatic control at

Lund Institute of Technology in 1985. The thesis was on modelling and control of large horizontal axis wind power plants. Currently, he leads the development of object-oriented modelling in computer aided control engineering (CACE). He was co-designer of the language Omola. His research interests include development of modelling and simulation tools and their use on real complex applications. He is currently focusing on symbolic analysis and manipulation of models and modelling and simulation of hybrid systems

Hilding Elmqvist attained his Ph.D. at the Department of Automatic

Control, Lund Institute of Technology in 1978. His Ph.D. thesis describes the design of a novel object-oriented modelling language, called Dymola, and algorithms for symbolic model manipulation. In 1972-1975, he had developed the simulation program Simnon which is sold world wide. In

1992, Elmqvist founded the company Dynasim AB which develops and markets the software tool Dymola for modelling and simulation of large dynamic systems. Elmqvist took the initiative in 1996 to organise an international effort to design the next generation object-oriented language for physical modelling, Modelica .

Jan F. Broenink received his Ph.D. in Electrical Engineering in 1990 from the University of Twente. His Ph.D. research was in the design of computer facilities for modelling and simulation of physical systems using bond graphs. He is presently Assistant Professor at the Control Laboratory of the Department of Electrical Engineering of the University of Twente, where he the project leader software tools development . His research interests include development of computer tools for modelling, simulation and implementation of embedded control systems; and robotics.

Download