25-06-2013, 03:05 PM
Modelica® - A Unified Object-Oriented Language for Physical Systems Modeling
Oriented Language.pdf (Size: 1.29 MB / Downloads: 33)
Abstract
This document defines the Modelica1 language, version 3.2, 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 physical
systems. It is suited for multi-domain modeling, for example, mechatronic models in robotics,
automotive and aerospace applications involving mechanical, electrical, hydraulic and control
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.
Introduction
Overview of Modelica
Modelica is a language for modeling of physical systems, designed to support effective library development and
model exchange. It is a modern language built on acausal modeling with mathematical equations and objectoriented
constructs to facilitate reuse of modeling knowledge.
Scope of the Specification
The semantics of the Modelica language is specified by means of a set of rules for translating any class described
in the Modelica language to a flat Modelica structure. A class must have additional properties in order that its flat
Modelica structure can be further transformed into a set of differential, algebraic and discrete equations (= flat
hybrid DAE). Such classes are called simulation models.
The flat Modelica structure is also defined for other cases than simulation models; including functions (can
be used to provide algorithmic contents), packages (used as a structuring mechanism), and partial models (used as
base-models). This allows correctness to be verified before building the simulation model.
Modelica was designed to facilitate symbolic transformations of models, especially by mapping basically
every Modelica language construct to continuous or instantaneous equations in the flat Modelica structure. Many
Modelica models, especially in the associated Modelica Standard Library, are higher index systems, and can only
be reasonably simulated if symbolic index reduction is performed, i.e., equations are differentiated and
appropriate variables are selected as states, so that the resulting system of equations can be transformed to state
space form (at least locally numerically), i.e., a hybrid DAE of index zero. The Modelica specification does not
define how to simulate a model. However, it defines a set of equations that the simulation result should satisfy as
well as possible.
Lexical Structure
This chapter describes several of the basic building blocks of Modelica such as characters and lexical units
including identifiers and literals. Without question, the smallest building blocks in Modelica are single characters
belonging to a character set. Characters are combined to form lexical units, also called tokens. These tokens are
detected by the lexical analysis part of the Modelica translator. Examples of tokens are literal constants,
identifiers, and operators. Comments are not really lexical units since they are eventually discarded. On the other
hand, comments are detected by the lexical analyzer before being thrown away.
Identifiers
Modelica identifiers, used for naming classes, variables, constants, and other items, are of two forms. The first
form always start with a letter or underscore (_), followed by any number of letters, digits, or underscores. Case is
significant, i.e., the names Inductor and inductor are different. The second form (Q-IDENT) starts with a
single quote, followed by a sequence of any printable ASCII character, where single-quote must be preceded by
backslash, and terminated by a single quote, e.g. '12H', '13\'H', '+foo'. Control characters in quoted
identifiers have to use string escapes. The single quotes are part of the identifier, i.e., 'x' and x are distinct
identifiers. The following BNF-like rules define Modelica identifiers, where curly brackets {} indicate repetition
zero or more times, and vertical bar | indicates alternatives.
Floating Point Numbers
A floating point number is expressed as a decimal number in the form of a sequence of decimal digits optionally
followed by a decimal point, optionally followed by an exponent. At least one digit must be present. The exponent
is indicated by an E or e, followed by an optional sign (+ or ) and one or more decimal digits. The minimal
recommended range is that of IEEE double precision floating point numbers.
Operators and Expressions
The lexical units are combined to form even larger building blocks such as expressions according to the rules
given by the expression part of the Modelica grammar in Appendix B.
This chapter describes the evaluation rules for expressions, the concept of expression variability, built-in
mathematical operators and functions, and the built-in special Modelica operators with function syntax.
Expressions can contain variables and constants, which have types, predefined or user defined. The predefined
built-in types of Modelica are Real, Integer, Boolean, String, and enumeration types which are presented in
more detail in Section 4.8. [The abbreviated predefined type information below is given as background
information for the rest of the presentation.]