Modelica – a General Object-Oriented Language for Continuous and Discrete-Event System Modeling and Simulation

Modelica – a General Object-Oriented Language for Continuous and Discrete-Event System Modeling and Simulation

Modelica – A General Object-Oriented Language for Continuous and Discrete-Event System Modeling and Simulation Peter Fritzson, Peter Bunus PELAB - Programming Environment Laboratory Department of Computer and Information Science, Linköping University, SE-581 83, Linköping, Sweden {petbu,petfr}@ida.liu.se Abstract of Modelica gives the user the possibility to combine electrical, mechanical, hydraulic, thermodynamic etc, Modelica is a general equation-based object-oriented model components within the same application model. language for continuous and discrete-event modeling of Compared to other equation based languages available physical systems for the purpose of efficient simulation. today. Modelica is primarily a modeling language, The language unifies and generalizes previous object- sometimes called hardware description language, that oriented modeling languages. The Modelica modeling allows the user to specify mathematical models of language and technology is being warmly received by the complex physical systems, e.g. for the purpose of world community in modeling and simulation. It is computer simulation of dynamic systems where behavior bringing about a revolution in this area, based on its ease evolves as a function of time. Modelica is also an object- of use, visual design of models with combination of lego- oriented equation based programming language, oriented like predefined model building blocks, its ability to define towards computational applications with high complexity model libraries with re-usable components and its requiring high performance. The four most important support for modeling and simulation of complex features of Modelica are: applications involving parts from several application · Modelica is primarily based on equations instead of domains. In this paper we present the Modelica language assignment statements. This permits acausal modeling with emphasis on its language features and one of the that gives better reuse of classes since equations do associated simulation environments. Simulation models not specify a certain data flow direction. Thus a can be developed in an integrated problem-solving Modelica class can adapt to more than one data flow environment by using a graphical editor for connection context. diagrams. Connections are established just by drawing · Modelica has multi-domain modeling capability, lines between objects picked from a class library. The meaning that model components corresponding to principles of object oriented physical systems modeling physical objects from several different domains such and the multi-domain capabilities of the language are as e.g. electrical, mechanical, thermodynamic, presented in the paper by several examples. hydraulic, biological and control applications can be described and connected. 1. Introduction · Modelica is an object-oriented language with a general class concept that unifies classes, generics — Modelica is a new language for hierarchical object- known as templates in C++, and general subtyping oriented physical modeling which is developed through an into a single language construct. This facilitates reuse international effort [6][3] [8][9]. The language unifies and of components and evolution of models. generalizes previous object-oriented modeling languages. · Modelica has a strong software component model, Modelica is intended to become a de facto standard. The with constructs for creating and connecting language has been designed to allow tools to generate components. Thus the language is ideally suited as an efficient simulation code automatically with the main architectural description language for complex objective to facilitate exchange of models, model libraries physical systems, and to some extent for software and simulation specifications. It allows defining systems. simulation models modularly and hierarchically and The reader of the paper is referred to [9][8] and [13] combining various formalisms expressible in the more for a complete description of the language and its general Modelica formalism. The multidomain capability functionality from the perspective of the motivations and · Object orientation is not viewed as dynamic message design goals of the researchers who developed it. passing. In the following section, the object oriented The declarative object-oriented way of describing mathematical modeling principle is briefly introduced systems and their behavior offered by Modelica is at a together some Modelica language constructs. In Section 3 higher level of abstraction than the usual object-oriented the continuous system modeling capabilities of the programming since some implementation details can be Modelica language are introduced with the help of a omitted. For example, the users do not need to write code simple simulation example. Section 4 and Section 5 to explicitly transport data between objects through present some discrete Modelica language constructs and assignment statements or message passing code. Such corresponding discrete and hybrid simple simulation code is generated automatically by the Modelica compiler examples. In Section 6 the Modelica package concept is based on the given equations. briefly introduced and a mechanical example is provided Just as in ordinary object-oriented languages classes from the Modelica Standard Multi-Body Library. Section are blueprints for creating objects. Both variables and 7 introduces MathModelica: a fully integrated program equations can be inherited between classes. Function solving environment for full system modeling and definitions can also be inherited. However, specifying simulation. Finally, future work and concluding remarks behavior is primarily done through equations instead of are given. via methods. There are also facilities for stating algorithmic code including functions in Modelica, but this 2. Object-Oriented Mathematical Modeling is an exception rather than the rule. As briefly mentioned before, acausal modeling is a Traditional object-oriented programming languages declarative modeling style meaning modeling based on like Simula, C++, Java, and Smalltalk, as well as equations instead of assignment statements. The main procedural languages such as Fortran or C, support advantage is that the solution direction of equations will programming with operations on stored data. The stored adapt to the data flow context in which the solution is data of the program includes variable values and object computed. The data flow context is defined by stating data. The number of objects often changes dynamically. which variables are needed as outputs, and which are The Smalltalk view of object-orientation emphasizes external inputs to the simulated system. The acausality of sending messages between (dynamically) created objects. Modelica library classes makes these more reusable than The Modelica view on object-orientation is different traditional classes containing assignment statements where since the Modelica language emphasizes structured the input-output causality is fixed. mathematical modeling. Object-orientation is viewed as a To illustrate the idea of acausal physical modeling we structuring concept that is used to handle the complexity give an example of a simple electrical circuit, see Figure of large system descriptions. A Modelica model is 1. The connection diagram of the electrical circuit shows primarily a declarative mathematical description, which how the components are connected and roughly simplifies further analysis. Dynamic system properties are corresponds to the physical layout of the electrical circuit expressed in a declarative way through equations. on a printed circuit board. The physical connections in the The concept of declarative programming is inspired by real circuit correspond to the logical connections in the mathematics where it is common to state or declare what diagram. Therefore the term physical modeling is quite holds, rather than giving a detailed stepwise algorithm on appropriate. how to achieve the desired goal as is required when using procedural languages. This relieves the programmer from R1=10 R2=100 the burden of keeping track of such details. Furthermore, the code becomes more concise and easier to change AC=220 without introducing errors. Thus, the Modelica view of object-orientation, from C=0.01 L=0.1 the point of view of object-oriented mathematical modeling, can be summarized as follows: · Object-orientation is primarily used as a structuring G concept, emphasizing the declarative structure and Figure 1. Connection diagram of the acausal simple reuse of mathematical models. circuit model. · Dynamic model properties are expressed in a The Modelica SimpleCircuit class below directly declarative way through equations. corresponds to the circuit depicted in the connection · An object is a collection of instance variables and diagram of Figure 1. Each graphic object in the diagram equations that share a set of stored data. corresponds to a declared instance in the simple circuit model. The model is acausal since no signal flow, i.e cause-and-effect flow, is specified. Connections between caused by solving the equations of a class together objects are specified using the connect statement, which is with equations from other classes. a special syntactic form of equation that we will tell more · Equations specify the behavior of a class. The way in about later. which the equations interact with equations from other classes determines the solution process, i.e. model SimpleCircuit program execution. Resistor

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    16 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us