Modelica® - a Unified Object-Oriented Language for Systems Modeling
Total Page:16
File Type:pdf, Size:1020Kb
Modelica® - A Unified Object-Oriented Language for Systems Modeling Language Specification Version 3.3 Revision 1 July 11, 2014 Abstract This document defines the Modelica1 language, version 3.3, which is developed by the Modelica Association, a non-profit organization with seat in Linköping, Sweden. Modelica is a freely available, object-oriented language for modeling of large, complex, and heterogeneous systems. It is suited for multi-domain modeling, for example, mechatronic models in robotics, automotive and aerospace applications involving mechanical, electrical, hydraulic control and state machine subsystems, process oriented applications and generation and distribution of electric power. Models in Modelica are mathematically described by differential, algebraic and discrete equations. No particular variable needs to be solved for manually. A Modelica tool will have enough information to decide that automatically. Modelica is designed such that available, specialized algorithms can be utilized to enable efficient handling of large models having more than one hundred thousand equations. Modelica is suited and used for hardware-in-the-loop simulations and for embedded control systems. More information is available at http://www.Modelica.org/ Version 3.3 Revision 1 clarifies and fixes issues of the specification text. In particular it includes all updates made in Version 3.2 Revision 2. 1 Modelica is a registered trademark of the Modelica Association Copyright © 1998-2014, Modelica Association (https://www.modelica.org) All rights reserved. Reproduction or use of editorial or pictorial content is permitted, i.e., this document can be freely distributed especially electronically, provided the copyright notice and these conditions are retained. No patent liability is assumed with respect to the use of information contained herein. While every precaution has been taken in the preparation of this document no responsibility for errors or omissions is assumed. The contributors to this and to previous versions of this document are listed in Appendix E. All contributors worked voluntarily and without compensation. Table of Contents Preface ................................................................................................................................................. 7 Chapter 1 Introduction ................................................................................................................ 9 1.1 Overview of Modelica...................................................................................................................... 9 1.2 Scope of the Specification ................................................................................................................ 9 1.3 Some Definitions ............................................................................................................................ 10 1.4 Notation and Grammar ................................................................................................................... 10 Chapter 2 Lexical Structure ...................................................................................................... 11 2.1 Character Set .................................................................................................................................. 11 2.2 Comments ...................................................................................................................................... 11 2.3 Identifiers, Names, and Keywords ................................................................................................. 12 2.4 Literal Constants ............................................................................................................................ 13 2.5 Operator Symbols .......................................................................................................................... 14 Chapter 3 Operators and Expressions ..................................................................................... 15 3.1 Expressions .................................................................................................................................... 15 3.2 Operator Precedence and Associativity ......................................................................................... 15 3.3 Evaluation Order ............................................................................................................................ 16 3.4 Arithmetic Operators ...................................................................................................................... 17 3.5 Equality, Relational, and Logical Operators .................................................................................. 17 3.6 Miscellaneous Operators and Variables ......................................................................................... 18 3.7 Built-in Intrinsic Operators with Function Syntax ......................................................................... 19 3.8 Variability of Expressions .............................................................................................................. 31 Chapter 4 Classes, Predefined Types, and Declarations ........................................................ 33 4.1 Access Control – Public and Protected Elements .......................................................................... 33 4.2 Double Declaration not Allowed ................................................................................................... 34 4.3 Declaration Order and Usage before Declaration .......................................................................... 34 4.4 Component Declarations ................................................................................................................ 34 4.5 Class Declarations .......................................................................................................................... 39 4.6 Specialized Classes ........................................................................................................................ 42 4.7 Balanced Models ............................................................................................................................ 44 4.8 Predefined Types ............................................................................................................................ 50 Chapter 5 Scoping, Name Lookup, and Flattening ................................................................. 55 5.1 Flattening Context .......................................................................................................................... 55 5.2 Enclosing Classes ........................................................................................................................... 55 5.3 Static Name Lookup ....................................................................................................................... 55 5.4 Instance Hierarchy Name Lookup of Inner Declarations ............................................................... 57 5.5 Simultaneous Inner/Outer Declarations ......................................................................................... 59 5.6 Flattening Process .......................................................................................................................... 59 Chapter 6 Interface or Type Relationships.............................................................................. 61 6.1 The Concepts of Type, Interface and Subtype ............................................................................... 62 6.2 Interface or Type ............................................................................................................................ 63 6.3 Interface Compatibility or Subtyping ............................................................................................. 64 6.4 Plug-Compatibility or Restricted Subtyping .................................................................................. 66 6.5 Function-Compatibility or Function-Subtyping for Functions ...................................................... 67 6.6 Type Compatible Expressions ........................................................................................................ 68 Chapter 7 Inheritance, Modification, and Redeclaration ...................................................... 71 7.1 Inheritance—Extends Clause ......................................................................................................... 71 7.2 Modifications ................................................................................................................................. 74 7.3 Redeclaration ................................................................................................................................. 77 Chapter 8 Equations .................................................................................................................. 85 8.1 Equation Categories ....................................................................................................................... 85 8.2 Flattening and Lookup in Equations .............................................................................................. 85 8.3 Equations in Equation Sections ...................................................................................................... 85 8.4 Synchronous Data-flow Principle and Single Assignment Rule .................................................... 92 8.5 Events and Synchronization ..........................................................................................................