Skip to content

Commit

Permalink
Use correct variants of "clause"
Browse files Browse the repository at this point in the history
By accident, this commit also includes added empty lines around sectioning commands, which should have been committed separately.
  • Loading branch information
henrikt-ma committed Apr 14, 2021
1 parent c5caa1f commit a21efbe
Show file tree
Hide file tree
Showing 20 changed files with 258 additions and 247 deletions.
26 changes: 13 additions & 13 deletions chapters/annotations.tex
Expand Up @@ -5,7 +5,7 @@ \chapter{Annotations}\label{annotations}

Annotations are optional in the Modelica grammar, and when present, indicated using the \lstinline!annotation!\indexinline{annotation} keyword, see \lstinline[language=grammar]!annotation-clause! in the grammar (\cref{expressions1}).
The structure of the annotation content is the same as a class modification (\lstinline[language=grammar]!class-modification! in the grammar).
(For replaceable class declarations with a constraining-clause also refer to \cref{constraining-clause-annotations}.)
(For replaceable class declarations with a \lstinline[language=grammar]!constraining-clause! also refer to \cref{constraining-clause-annotations}.)
The specification in this document defines the semantic meaning if a tool implements any of these annotations.

\section{Vendor-Specific Annotations}\label{vendor-specific-annotations}
Expand Down Expand Up @@ -570,15 +570,15 @@ \section{Annotations for Graphical Objects}\label{annotations-for-graphical-obje
\end{example}

The graphics is specified as an ordered sequence of graphical primitives, which are described below.
First base class contents is drawn according to the order of the extends-clauses, and then graphical primitives are drawn according to the order such that later objects can cover earlier ones.
First base class contents is drawn according to the order of the \lstinline!extends!-clauses, and then graphical primitives are drawn according to the order such that later objects can cover earlier ones.

\begin{nonnormative}
Note that the ordered sequence is syntactically a valid Modelica annotation, although there
is no mechanism for defining an array of heterogeneous objects in Modelica.
\end{nonnormative}

These \lstinline!Icon!, \lstinline!Diagram!, and \lstinline!Documentation! annotations are only allowed directly in classes (e.g.\ not on components or connections).
The allowed annotations for a short class definition is the union of the allowed annotations in classes and on extends-clauses.
The allowed annotations for a short class definition is the union of the allowed annotations in classes and on \lstinline!extends!-clauses.

\subsection{Common Definitions}\label{common-definitions}

Expand Down Expand Up @@ -663,7 +663,7 @@ \subsubsection{Coordinate Systems}\label{coordinate-systems}
\item
The coordinate system annotation given in the class (if specified).
\item
The coordinate systems of the first base class where the extent on the extends-clause specifies a null-region (if any).
The coordinate systems of the first base class where the extent on the \lstinline!extends!-clause specifies a null-region (if any).
Note that null-region is the default for base classes, see \cref{extends-clause}.
\item
The default coordinate system \lstinline!CoordinateSystem(extent = {{-100, -100}, {100, 100}})!.
Expand Down Expand Up @@ -792,9 +792,9 @@ \subsection{Component Instance}\label{component-instance}
icon layer. Non-connector components are only shown in the diagram
layer.

\subsection{Extends clause}\label{extends-clause}
\subsection{Extends-clause}\label{extends-clause}

Each \lstinline[language=grammar]!extends-clause! (and \lstinline[language=grammar]!short-class-definition!, as stated in \cref{annotations-for-graphical-objects}) may have layer specific annotations which describe the rendering of the base class' icon and diagram layers in the derived class.
Each \lstinline!extends!-clause (and short class definition, as stated in \cref{annotations-for-graphical-objects}) may have layer specific annotations which describe the rendering of the base class' icon and diagram layers in the derived class.

\begin{lstlisting}[language=modelica]
record IconMap
Expand All @@ -813,9 +813,10 @@ \subsection{Extends clause}\label{extends-clause}

\begin{itemize}
\item
If the extent of the extends-clause defines a null region (the default), the base class contents is mapped to the same coordinates in the derived class, and the coordinate system (including \lstinline!preserveAspectRatio!) can be inherited as described in \cref{coordinate-systems}.
If the extent of the \lstinline!extends!-clause defines a null region (the default), the base class contents is mapped to the same coordinates in the derived class, and the coordinate system (including \lstinline!preserveAspectRatio!) can be inherited as described in \cref{coordinate-systems}.
\item
If the extent of the extends-clause defines a non-null region, the base class coordinate system is mapped to the region specified by the attribute extent, if \lstinline!preserveAspectRatio! is true for the base class the mapping shall preserve the aspect ratio. The base class coordinate system (and \lstinline!preserveAspectRatio!) is not inherited.
If the extent of the \lstinline!extends!-clause defines a non-null region, the base class coordinate system is mapped to the region specified by the attribute extent, if \lstinline!preserveAspectRatio! is true for the base class the mapping shall preserve the aspect ratio.
The base class coordinate system (and \lstinline!preserveAspectRatio!) is not inherited.
\end{itemize}

\begin{example}
Expand Down Expand Up @@ -1955,11 +1956,9 @@ \subsection{Version Date and Build Information}\label{version-date-and-build-inf
library. There are no conversions between the same versions with
different build numbers.

Two releases of a library with the same \lstinline!version! but different
\lstinline!versionBuild! are in general assumed to be compatible. In special
cases, the \lstinline!uses! clause of a model may specify \lstinline!versionBuild! and/or
\lstinline!dateModified!. In such a case the tool is expected to give
a warning if there is a mismatch between library and model.
Two releases of a library with the same \lstinline!version! but different \lstinline!versionBuild! are in general assumed to be compatible.
In special cases, the \lstinline!uses!-clause of a model may specify \lstinline!versionBuild! and/or \lstinline!dateModified!.
In such a case the tool is expected to give a warning if there is a mismatch between library and model.
\item
\lstinline!dateModified! is the UTC date and time (according to ISO
8601) of the last modification of the package.
Expand Down Expand Up @@ -2264,5 +2263,6 @@ \section{Annotation Choices for Modifications and Redeclarations}\label{annotati
See \cref{annotation-choices-for-suggested-redeclarations-and-modifications}.

\section{Annotation for External Libraries and Include Files}\label{annotation-for-external-libraries-and-include-files}

% Isn't this section silly considering that the same link was given above under "External Function Annotations"?
See \cref{annotations-for-external-libraries-and-include-files}.
31 changes: 14 additions & 17 deletions chapters/arrays.tex
Expand Up @@ -586,20 +586,12 @@ \subsubsection{Reduction Expressions}\label{reduction-expressions}
IDENT in expression2
\end{lstlisting}%
\index{in@\robustinline{in}!reduction expression}

the loop-variable, \lstinline!IDENT!, is in scope inside \lstinline!expression1!. The
loop-variable may hide other variables, as in for-clauses. The result
depends on the \lstinline!function-name!, and currently the only legal
function-names are the built-in operators \lstinline!array!, \lstinline!sum!,
\lstinline!product!, \lstinline!min!, and
\lstinline!max!. For array, see \cref{vector-matrix-and-array-constructors}. If \lstinline!function-name! is
\lstinline!sum!, \lstinline!product!, \lstinline!min!,
or \lstinline!max! the result is of the same type as \lstinline!expression1! and is constructed
by evaluating \lstinline!expression1! for each value of the loop-variable and
computing the \lstinline!sum!, \lstinline!product!, \lstinline!min!, or
\lstinline!max! of the computed elements. For
deduction of ranges, see \cref{implicit-iteration-ranges}; and for using types as ranges
see \cref{types-as-iteration-ranges}.
the loop-variable, \lstinline!IDENT!, is in scope inside \lstinline!expression1!.
The loop-variable may hide other variables, as in \lstinline!for!-loops.
The result depends on the \lstinline!function-name!, and currently the only legal function-names are the built-in operators \lstinline!array!, \lstinline!sum!, \lstinline!product!, \lstinline!min!, and \lstinline!max!.
For array, see \cref{vector-matrix-and-array-constructors}.
If \lstinline!function-name! is \lstinline!sum!, \lstinline!product!, \lstinline!min!, or \lstinline!max! the result is of the same type as \lstinline!expression1! and is constructed by evaluating \lstinline!expression1! for each value of the loop-variable and computing the \lstinline!sum!, \lstinline!product!, \lstinline!min!, or \lstinline!max! of the computed elements.
For deduction of ranges, see \cref{implicit-iteration-ranges}; and for using types as ranges see \cref{types-as-iteration-ranges}.

\begin{table}[H]
\caption{Reduction expressions with iterators. (The least and greatest values of \lstinline!Real! are available as \lstinline!-Modelica.Constants.inf! and \lstinline!Modelica.Constants.inf!, respectively.)}
Expand Down Expand Up @@ -767,9 +759,13 @@ \subsection{Array Constructor with Iterators}\label{array-constructor-with-itera
\begin{lstlisting}[language=modelica]
IDENT in array_expression
\end{lstlisting}
the loop-variable, \lstinline!IDENT!, is in scope inside expression in the array construction. The loop-variable may hide other variables, as in for-clauses. The loop-variable has the same type as
the type of the elements of \lstinline!array_expression!; and can be simple type as well as a record type. The loop-variable will have the same type for the entire loop -- i.e., for an
\lstinline!array_expression! \lstinline!{1, 3.2}! the iterator will have the type of the type-compatible expression (\lstinline!Real!) for all iterations. For deduction of ranges, see
the loop-variable, \lstinline!IDENT!, is in scope inside expression in the array construction.
The loop-variable may hide other variables, as in \lstinline!for!-loops.
The loop-variable has the same type as
the type of the elements of \lstinline!array_expression!; and can be simple type as well as a record type.
The loop-variable will have the same type for the entire loop -- i.e., for an
\lstinline!array_expression! \lstinline!{1, 3.2}! the iterator will have the type of the type-compatible expression (\lstinline!Real!) for all iterations.
For deduction of ranges, see
\cref{implicit-iteration-ranges}; and for using types as range see \cref{types-as-iteration-ranges}.

\subsubsection{Array Constructor with One Iterator}\label{array-constructor-with-one-iterator}
Expand Down Expand Up @@ -1390,6 +1386,7 @@ \subsection{Vectorized Calls of Functions}\label{vectorized-calls-of-functions}
See \cref{scalar-functions-applied-to-array-arguments}.

\subsection{Standard Type Coercion}\label{standard-type-coercion}

In all contexts that require an expression which is a subtype of \lstinline!Real!, an expression which is a subtype of \lstinline!Integer! can also be used;
the \lstinline!Integer! expression is automatically converted to \lstinline!Real!.

Expand Down
27 changes: 16 additions & 11 deletions chapters/classes.tex
Expand Up @@ -357,13 +357,13 @@ \subsection{Component Variability Prefixes discrete, parameter, constant}\label{
not differentiable.
\end{itemize}

If a \lstinline!Real! variable is declared with the prefix \lstinline!discrete!\indexinline{discrete} it must in a simulation model be assigned in a when-clause, either by an assignment or an equation.
The variable assigned in a when-clause shall not be defined in a sub-component of \lstinline!model! or \lstinline!block! specialized class.
If a \lstinline!Real! variable is declared with the prefix \lstinline!discrete!\indexinline{discrete} it must in a simulation model be assigned in a \lstinline!when!-clause, either by an assignment or an equation.
The variable assigned in a \lstinline!when!-clause shall not be defined in a sub-component of \lstinline!model! or \lstinline!block! specialized class.
(This is to keep the property of balanced models.)

A \lstinline!Real! variable assigned in a when-clause is a discrete-time variable,
A \lstinline!Real! variable assigned in a \lstinline!when!-clause is a discrete-time variable,
even though it was not declared with the prefix \lstinline!discrete!. A \lstinline!Real!
variable not assigned in any when-clause and without any type prefix is
variable not assigned in any \lstinline!when!-clause and without any type prefix is
a continuous-time variable.

The default variability for \lstinline!Integer!, \lstinline!String!,
Expand All @@ -384,13 +384,13 @@ \subsection{Component Variability Prefixes discrete, parameter, constant}\label{
\begin{nonnormative}
For \lstinline!Real! variables we can distinguish two subtly different categories: discrete-time and piecewise constant, where the discrete-time variables are a subset of all piecewise constant variables.
The \lstinline!Real! variables declared with the prefix \lstinline!discrete! is a subset of the discrete-time \lstinline!Real! variables.
For a \lstinline!Real! variable, being discrete-time is equivalent to being assigned in a when-clause.
A variable used as argument to \lstinline!pre! outside a when-clause must be discrete-time.
For a \lstinline!Real! variable, being discrete-time is equivalent to being assigned in a \lstinline!when!-clause.
A variable used as argument to \lstinline!pre! outside a \lstinline!when!-clause must be discrete-time.

\begin{lstlisting}[language=modelica]
model PiecewiseConstantReals
discrete Real xd1 "Must be assigned in a when-clause, discrete-time";
Real xd2 "Assigned in a when-clause (below) and thus discrete-time";
discrete Real xd1 "Must be assigned in a \lstinline!when!-clause, discrete-time";
Real xd2 "Assigned in a \lstinline!when!-clause (below) and thus discrete-time";
Real xc3 "Not discrete-time, but piecewise constant";
Real x4 "Piecewise constant, but changes between events";
equation
Expand All @@ -410,7 +410,12 @@ \subsection{Component Variability Prefixes discrete, parameter, constant}\label{
As shown above variables can be piecewise constant, but change at times that are not events (in the example above \lstinline!x4!).
It is not clear how a tool could detect and optimize the latter case.

A \lstinline!parameter! variable is constant during simulation. This prefix gives the library designer the possibility to express that the physical equations in a library are only valid if some of the used components are constant during simulation. The same also holds for discrete-time and constant variables. Additionally, the \lstinline!parameter! prefix allows a convenient graphical user interface in an experiment environment, to support quick changes of the most important constants of a compiled model. In combination with an if-clause, a \lstinline!parameter! prefix allows removing parts of a model before the symbolic processing of a model takes place in order to avoid variable causalities in the model (similar to \lstinline!#ifdef! in C). Class parameters can be sometimes used as an alternative.
A \lstinline!parameter! variable is constant during simulation.
This prefix gives the library designer the possibility to express that the physical equations in a library are only valid if some of the used components are constant during simulation.
The same also holds for discrete-time and constant variables.
Additionally, the \lstinline!parameter! prefix allows a convenient graphical user interface in an experiment environment, to support quick changes of the most important constants of a compiled model.
In combination with an \lstinline!if!-equation, a \lstinline!parameter! prefix allows removing parts of a model before the symbolic processing of a model takes place in order to avoid variable causalities in the model (similar to \lstinline!#ifdef! in C).
Class parameters can be sometimes used as an alternative.

Example:
\begin{lstlisting}[language=modelica]
Expand Down Expand Up @@ -562,7 +567,7 @@ \section{Class Declarations}\label{class-declarations}

The following is the formal syntax of class definitions, including the special variants described in later sections.

An \firstuse{element}\index{element} is part of a class definition, and is one of: class definition, component declaration, or extends clause.
An \firstuse{element}\index{element} is part of a class definition, and is one of: class definition, component declaration, or \lstinline!extends!-clause.
Component declarations and class definitions are called \firstuse{named elements}\index{named elements}.
An element is either inherited from a base class or local.

Expand Down Expand Up @@ -928,7 +933,7 @@ \section{Balanced Models}\label{balanced-models}
\item
The number of equations defined locally (i.e.\ not in any \lstinline!model! or \lstinline!block! component), including binding equations, and equations generated from connect-equations.
\begin{nonnormative}
This includes the proper count for when-clauses (see \cref{when-equations}), and algorithms (see \cref{algorithm-sections}), and is also used for
This includes the proper count for \lstinline!when!-clauses (see \cref{when-equations}), and algorithms (see \cref{algorithm-sections}), and is also used for
the flat Hybrid DAE formulation (see \cref{modelica-dae-representation}).
\end{nonnormative}
\item
Expand Down
2 changes: 1 addition & 1 deletion chapters/connectors.tex
Expand Up @@ -869,7 +869,7 @@ \subsection{Overconstrained Equation Operators for Connection Graphs}\label{over
% TODO: Can't have angle brackets and \emph in the same mathescape due to LaTeXML issue:
% - https://github.com/brucemiller/LaTeXML/issues/1477
% Once we cut the MathJax dependency, change to single mathescape for better character spacing.
E.g., it is not allowed to use this function in a when-clause.
E.g., it is not allowed to use this function in a \lstinline!when!-clause.
This definition shall be used if in a model with connectors \lstinline!A! and \lstinline!B! the overdetermined records \lstinline!A.R! and \lstinline!B.R! are algebraically coupled in the model, e.g., due to \lstinline!B.R = f(A.R, $\langle$$\mbox{\emph{other unknowns}}$$\rangle$)!.
\end{nonnormative}
\end{semantics}
Expand Down
6 changes: 3 additions & 3 deletions chapters/dae.tex
Expand Up @@ -18,7 +18,7 @@ \chapter{Modelica DAE Representation}\label{modelica-dae-representation}
\item
Mapping all algorithm sections to equation sets.
\item
Mapping all when-clauses to equation sets (see \cref{when-equations}).
Mapping all \lstinline!when!-clauses to equation sets (see \cref{when-equations}).
\end{itemize}

As a result of this transformation process, a set of equations is
Expand Down Expand Up @@ -64,7 +64,7 @@ \chapter{Modelica DAE Representation}\label{modelica-dae-representation}
Modelica variables of discrete-valued types (\lstinline!Boolean!, \lstinline!Integer!, etc) which are unknown. These variables change their value only at event instants $t_{\mathrm{e}}$. \lstinline!pre(m)! are the values of $m$ immediately before the current event occurred.

\item $c(t_{\mathrm{e}})$:
The conditions of all \lstinline!if!-expressions generated including when-clauses after conversion, see \cref{when-equations}).
The conditions of all \lstinline!if!-expressions generated including \lstinline!when!-clauses after conversion, see \cref{when-equations}).

\item $\mathit{relation}(v)$:
A relation containing variables $v_{i}$, e.g.\ $v_{1} > v_{2}$, $v_{3} \geq 0$.
Expand Down Expand Up @@ -96,7 +96,7 @@ \chapter{Modelica DAE Representation}\label{modelica-dae-representation}
\begin{enumerate}
\item\label{perform-simulation-integrate}
The DAE \eqref{eq:dae} is solved by a numerical integration method. In this
phase the conditions $c$ of the if- and when-clauses, as well as the
phase the conditions $c$ of the if- and \lstinline!when!-clauses, as well as the
discrete-time variables $z$ and $m$ are kept constant. Therefore, \eqref{eq:dae} is a
continuous function of continuous variables and the most basic
requirement of numerical integrators is fulfilled.
Expand Down

0 comments on commit a21efbe

Please sign in to comment.