-
Notifications
You must be signed in to change notification settings - Fork 41
/
introduction.tex
112 lines (90 loc) · 6.27 KB
/
introduction.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
\chapter{Introduction}\label{introduction1}
\section{Overview of Modelica}\label{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
object-oriented constructs to facilitate reuse of modeling knowledge.
\section{Scope of the Specification}\label{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 (of specialized class \lstinline!model!, \lstinline!class! or \lstinline!block!) intended to be simulated on its own is called a \firstuse{simulation model}\index{simulation model}.
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 for those classes, before using them to build the simulation
model.
There are specific semantic restrictions for a simulation model to
ensure that the model is complete; they allow its flat Modelica
structure to be further transformed into a set of differential,
algebraic and discrete equations (= flat hybrid DAE). Note that
satisfying the semantic restrictions does not guarantee that the model
can be initialized from the initial conditions and simulated.
Modelica was designed to facilitate symbolic transformations of models, especially by mapping basically every Modelica language construct to 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.
In order to allow this structural analysis, a tool may reject simulating a model if parameters cannot be evaluated during translation -- due to calls of external functions or initial equations/initial algorithms for \lstinline!fixed = false! parameters.
Accepting such models is a quality of implementation issue.
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.
The key issues of the translation (or flattening) are:
\begin{itemize}
\item
Expansion of inherited base classes
\item
Parameterization of base classes, local classes and components
\item
Generation of connection equations from \lstinline!connect!-equations
\end{itemize}
The flat hybrid DAE form consists of:
\begin{itemize}
\item
Declarations of variables with the appropriate basic types, prefixes
and attributes, such as \lstinline!parameter Real v=5!.
\item
Equations from equation sections.
\item
Function invocations where an invocation is treated as a set of
equations which involves all input and all result variables (number of
equations = number of basic result variables).
\item
Algorithm sections where every section is treated as a set of
equations which involves the variables occurring in the algorithm
section (number of equations = number of different assigned
variables).
\item
\lstinline!when!-clauses where every \lstinline!when!-clause is treated as a set of conditionally evaluated equations, which are functions of the variables occurring in the clause (number of equations = number of different assigned variables).
\end{itemize}
Therefore, a flat hybrid DAE is seen as a set of equations where some of the equations are only conditionally evaluated.
Initial setup of the model is specified using \lstinline!start!-attributes and equations that hold only during initialization.
A Modelica class may also contain annotations, i.e.\ formal comments,
which specify graphical representations of the class (icon and diagram),
documentation text for the class, and version information.
\section{Some Definitions}\label{some-definitions}
The semantic specification should be read together with the Modelica grammar.
Non-normative text, i.e., examples and comments, are enclosed in {[}\ldots{]} and set in italics.
Explanations of many terms can be found using the document index in \cref{document-index}.
Some important terms are defined below.
\begin{definition}[Component]\index{component}
An element defined by the production \lstinline[language=grammar]!component-clause! in the Modelica grammar (basically a variable or an instance of a class)
\end{definition}
\begin{definition}[Element]\index{element}
Class definition, \lstinline!extends!-clause, or \lstinline[language=grammar]!component-clause! declared in a class (basically a class reference or a component in a declaration).
\end{definition}
\begin{definition}[Flattening]\index{flattening}
The translation of a model described in Modelica to the corresponding model described as a hybrid DAE, involving expansion of inherited base classes, parameterization of base classes, local classes
and components, and generation of connection equations from \lstinline!connect!-equations (basically, mapping the hierarchical structure of a model into a set of differential, algebraic and discrete equations together with the corresponding variable declarations and function definitions from the model).
\end{definition}
% More terms that would be useful to define here:
% - translation (for phrases such as "during translation")
% - deprecated
% - quality of implementation
% - simulator
\section{Notation and Grammar}\label{notation-and-grammar}
The meta symbols (of the extended BNF-grammar) are defined in~\cref{lexical-conventions}.
Boldface denotes keywords of the Modelica language. Keywords are
reserved words and shall not be used as identifiers, with the exception of
\lstinline!initial! which is a keyword in section headings, and \lstinline!der! which is a
keyword for declaration functions, but it is also possible to call the
functions \lstinline!initial! and \lstinline!der!.
See \cref{modelica-concrete-syntax} for a full lexical specification and grammar.