Skip to content

Commit

Permalink
Add remaining keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikt-ma committed Dec 2, 2020
1 parent 586720a commit b1265f8
Show file tree
Hide file tree
Showing 15 changed files with 122 additions and 148 deletions.
15 changes: 7 additions & 8 deletions chapters/arrays.tex
Expand Up @@ -245,7 +245,7 @@ \subsection{Array Dimension and Size Functions}\label{array-dimension-and-size-f
\end{tabular}
\end{center}

\begin{operatordefinition}[ndims]
\begin{operatordefinition}[ndims]\index{ndims@\indexinline{ndims}}
\begin{synopsis}\begin{lstlisting}
ndims($A$)
\end{lstlisting}\end{synopsis}
Expand All @@ -254,7 +254,7 @@ \subsection{Array Dimension and Size Functions}\label{array-dimension-and-size-f
\end{semantics}
\end{operatordefinition}

\begin{operatordefinition*}[size]\label{modelica:size-of-dim}
\begin{operatordefinition*}[size]\label{modelica:size-of-dim}\index{size@\indexinline{size}!of single array dimension}
\begin{synopsis}\begin{lstlisting}
size($A$, $i$)
\end{lstlisting}\end{synopsis}
Expand All @@ -265,7 +265,7 @@ \subsection{Array Dimension and Size Functions}\label{array-dimension-and-size-f
\end{semantics}
\end{operatordefinition*}

\begin{operatordefinition*}[size]\label{modelica:size-vector}
\begin{operatordefinition*}[size]\label{modelica:size-vector}\index{size@\indexinline{size}!of all array dimensions}
\begin{synopsis}\begin{lstlisting}
size($A$)
\end{lstlisting}\end{synopsis}
Expand Down Expand Up @@ -554,7 +554,7 @@ \subsection{Reduction Functions and Operators}\label{reduction-functions-and-ope

\subsubsection{Reduction Expressions}\label{reduction-expressions}

An expression:
An expression\index{for@\indexinline{for}!reduction expression}:
\begin{lstlisting}[language=grammar]
function-name "(" expression1 for iterators ")"
\end{lstlisting}
Expand All @@ -564,7 +564,7 @@ \subsubsection{Reduction Expressions}\label{reduction-expressions}
once for each reduction-expression, and are evaluated in the scope
immediately enclosing the reduction-expression.

For an iterator:
For an iterator\index{in@\indexinline{in}!reduction expression}:
\begin{lstlisting}[language=grammar]
IDENT in expression2
\end{lstlisting}
Expand Down Expand Up @@ -1017,9 +1017,8 @@ \subsection{Indexing with Boolean or Enumeration Values}\label{indexing-with-boo

\subsection{Indexing with end}\label{indexing-with-end}

The expression \lstinline!end! may only appear inside array subscripts, and if used in the $i$:th subscript of an array expression \lstinline!A! it is equivalent
to \lstinline!size(A, $i$)! provided indices to \lstinline!A! are a subtype of \lstinline!Integer!. If used inside nested array subscripts it refers
to the most closely nested array.
The expression \lstinline!end!\index{end@\indexinline{end}} may only appear inside array subscripts, and if used in the $i$:th subscript of an array expression \lstinline!A! it is equivalent to \lstinline!size(A, $i$)! provided indices to \lstinline!A! are a subtype of \lstinline!Integer!.
If used inside nested array subscripts it refers to the most closely nested array.

\begin{example}
\begin{lstlisting}[language=modelica, escapechar=!]
Expand Down
17 changes: 8 additions & 9 deletions chapters/classes.tex
Expand Up @@ -14,8 +14,8 @@ \chapter{Classes, Predefined Types, and Declarations}\label{class-predefined-typ

\section{Access Control -- Public and Protected Elements}\label{access-control-public-and-protected-elements}

Members of a Modelica class can have two levels of visibility: \lstinline!public! or
\lstinline!protected!. The default is \lstinline!public! if nothing else is specified
Members of a Modelica class can have two levels of visibility: \lstinline!public!\index{public@\indexinline{public}} or \lstinline!protected!\index{protected@\indexinline{protected}}.
The default is \lstinline!public! if nothing else is specified.

A protected element, \lstinline!P!, in classes and components shall not be accessed via dot notation (e.g., \lstinline!A.P!, \lstinline!a.P!, \lstinline!a[1].P!, \lstinline!a.b.P!,
\lstinline!.A.P!; but there is no restriction on using \lstinline!P! or \lstinline!P.x! for a protected element \lstinline!P!). They shall not be modified or redeclared except for
Expand Down Expand Up @@ -221,8 +221,7 @@ \subsubsection{Prefix Rules}\label{prefix-rules}
\lstinline!input! can only be used, if none of the elements has a \lstinline!flow!, \lstinline!stream!, \lstinline!input! or \lstinline!output! type prefix.
\end{example}

The prefixes \lstinline!input! and \lstinline!output! have a slightly different semantic meaning
depending on the context where they are used:
The prefixes \lstinline!input!\index{input@\indexinline{input}} and \lstinline!output!\index{output@\indexinline{output}} have a slightly different semantic meaning depending on the context where they are used:
\begin{itemize}
\item
In \emph{functions}, these prefixes define the computational causality
Expand Down Expand Up @@ -322,11 +321,9 @@ \subsection{Component Variability Prefixes discrete, parameter, constant}\label{
The prefixes \lstinline!discrete!, \lstinline!parameter!, \lstinline!constant! of a component declaration are called \firstuse{variability prefixes}\index{variability!prefix}\index{declared variability}\index{variability!declared|see{declared variability}} and define in which situation the variable values of a component are initialized (see \cref{events-and-synchronization} and \cref{initialization-initial-equation-and-initial-algorithm}) and when they are changed in transient analysis (= solution of initial value problem of the hybrid DAE):
\begin{itemize}
\item
A variable \lstinline!vc! declared with \lstinline!constant! prefix remains constant during transient analysis,
with a value that is unaffected by the initialization problem.
A variable \lstinline!vc! declared with \lstinline!constant!\index{constant@\indexinline{constant}} prefix remains constant during transient analysis, with a value that is unaffected by the initialization problem.
\item
A variable \lstinline!vc! declared with the \lstinline!parameter! prefix remains constant during transient analysis,
with a value determined by the initialization problem.
A variable \lstinline!vc! declared with the \lstinline!parameter!\index{parameter@\indexinline{parameter}} prefix remains constant during transient analysis, with a value determined by the initialization problem.
\item
A \emph{discrete-time} variable \lstinline!vd! has a vanishing time derivative between events.
Note that this is not the same as saying that \lstinline!der(vd)=0! almost everywhere,
Expand All @@ -342,7 +339,9 @@ \subsection{Component Variability Prefixes discrete, parameter, constant}\label{
not differentiable.
\end{itemize}

If a \lstinline!Real! variable is declared with the prefix \lstinline!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. (This is to keep the property of balanced models.)
If a \lstinline!Real! variable is declared with the prefix \lstinline!discrete!\index{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.
(This is to keep the property of balanced models.)

A \lstinline!Real! variable assigned in a when-clause is a discrete-time variable,
even though it was not declared with the prefix \lstinline!discrete!. A \lstinline!Real!
Expand Down
17 changes: 6 additions & 11 deletions chapters/connectors.tex
Expand Up @@ -7,9 +7,9 @@ \chapter{Connectors and Connections}\label{connectors-and-connections}

\section{Connect-Equations and Connectors}\label{connect-equations-and-connectors}

Connections between objects are introduced by connect-equations in the
equation part of a class. A connect-equation has the following syntax:
\begin{lstlisting}[language=modelica]
Connections between objects are introduced by connect-equations in the equation part of a class.
A connect-equation\index{connect@\indexinline{connect}} has the following syntax:
\begin{lstlisting}[language=grammar]
connect(component-reference, component-reference);
\end{lstlisting}

Expand Down Expand Up @@ -111,7 +111,7 @@ \subsection{Inside and Outside Connectors}\label{inside-and-outside-connectors}

\subsection{Expandable Connectors}\label{expandable-connectors}

If the \lstinline!expandable! qualifier is present on a connector definition, all instances of that connector are referred to as \firstuse{expandable connectors}\index{expandable connector}.
If the \lstinline!expandable!\index{expandable@\indexinline{expandable}} qualifier is present on a connector definition, all instances of that connector are referred to as \firstuse{expandable connectors}\index{expandable connector}.
Instances of connectors that do not possess this qualifier will be referred to as \firstuse{non-expandable connectors}\index{non-expandable connector}.

Before generating connection equations non-parameter scalar variables and non-parameter array elements declared in expandable connectors are marked as only being
Expand Down Expand Up @@ -204,9 +204,7 @@ \subsection{Expandable Connectors}\label{expandable-connectors}
\end{example}

\item
An expandable connector shall not contain a component declared with the
prefix \lstinline!flow!, but may contain non-expandable connector components with
\lstinline!flow! components.
An expandable connector shall not contain a component declared with the prefix \lstinline!flow!\index{flow@\indexinline{flow}!in expandable connector}, but may contain non-expandable connector components with \lstinline!flow! components.
\begin{example}
\begin{lstlisting}[language=modelica]
import Interfaces=Modelica.Electrical.Analog.Interfaces;
Expand Down Expand Up @@ -442,10 +440,7 @@ \section{Generation of Connection Equations}\label{generation-of-connection-equa
must be of the same \lstinline!operator record! type. This implies that in order to have flow variables of an \lstinline!operator record! type the \lstinline!operator record! must define addition,
negation, and \lstinline!'0'!; and these operations should define an additive group.

In order to generate equations for flow variables (using the
\lstinline!flow! prefix), the sign used for the connector variable
$z_{i}$ above is +1 for inside connectors and -1 for outside
connectors ($z_{3}$ in the example above).
In order to generate equations for flow variables (using the \lstinline!flow!\index{flow@\indexinline{flow}} prefix), the sign used for the connector variable $z_{i}$ above is +1 for inside connectors and -1 for outside connectors ($z_{3}$ in the example above).

\begin{example}
Simple example:
Expand Down
25 changes: 15 additions & 10 deletions chapters/equations.tex
Expand Up @@ -33,6 +33,13 @@ \section{Flattening and Lookup in Equations}\label{flattening-and-lookup-in-equa

\section{Equations in Equation Sections}\label{equations-in-equation-sections}

An equation section is comprised of the keyword \lstinline!equation!\index{equation@\indexinline{equation}} followed by a sequence of equations.
The formal syntax is as follows:
\begin{lstlisting}[language=grammar]
equation-section :
[ initial ] equation { equation ";" }
\end{lstlisting}

The following kinds of equations may occur in equation sections. The
syntax is defined as follows:
\begin{lstlisting}[language=grammar]
Expand Down Expand Up @@ -80,15 +87,14 @@ \subsection{Simple Equality Equations}\label{simple-equality-equations}

\subsection{For-Equations -- Repetitive Equation Structures}\label{for-equations-repetitive-equation-structures}

The syntax of a for-equation is as follows:
The syntax of a for-equation\index{for@\indexinline{for}!equation}\index{loop@\indexinline{loop}!for-equation} is as follows:
\begin{lstlisting}[language=grammar]
for for-indices loop
{ equation ";" }
end for ";"
\end{lstlisting}

For-equations may optionally use several iterators (for-indices), see
\cref{nested-for-loops-and-reduction-expressions-with-multiple-iterators} for more information:
For-equations may optionally use several iterators (for-indices)\index{in@\indexinline{in}!for-equation}, see \cref{nested-for-loops-and-reduction-expressions-with-multiple-iterators} for more information:
\begin{lstlisting}[language=grammar]
for-indices:
for-index {"," for-index}
Expand Down Expand Up @@ -153,7 +159,7 @@ \subsection{Connect-Equations}\label{connect-equations}

\subsection{If-Equations}\label{if-equations}

If-equations have the following syntax:
If-equations\index{if@\indexinline{if}!equation}\index{then@\indexinline{then}!if-equation}\index{else@\indexinline{else}!if-equation}\index{elseif@\indexinline{elseif}!if-equation} have the following syntax:
\begin{lstlisting}[language=grammar]
if expression then
{ equation ";" }
Expand All @@ -180,7 +186,7 @@ \subsection{If-Equations}\label{if-equations}

\subsection{When-Equations}\label{when-equations}

When-equations have the following syntax:
When-equations\index{when@\indexinline{when}!equation}\index{then@\indexinline{then}!when-equation}\index{elsewhen@\indexinline{elsewhen}!when-equation} have the following syntax:
\begin{lstlisting}[language=grammar]
when expression then
{ equation ";" }
Expand Down Expand Up @@ -267,6 +273,7 @@ \subsubsection{Restrictions on Where a When-Equation may Occur}\label{restrictio
\end{example}

\subsubsection{Restrictions on Equations within When-Equations}\label{restrictions-on-equations-within-when-equations}

The equations within the when-equation must have one of the following forms:
\begin{itemize}
\item
Expand Down Expand Up @@ -747,11 +754,9 @@ \section{Initialization, initial equation, and initial algorithm}\label{initiali
variables, can be defined in the following ways:
\begin{enumerate}
\item
As equations in an \lstinline!initial equation! section or as assignments in an
\lstinline!initial algorithm! section. The equations and assignments in these
initial sections are purely algebraic, stating constraints between the
variables at the initial time instant. It is not allowed to use
when-clauses in these sections.
As equations in an \lstinline!initial equation!\index{initial equation@\indexinline{initial equation}} section or as assignments in an \lstinline!initial algorithm!\index{initial algorithm@\indexinline{initial algorithm}} section.
The equations and assignments in these initial sections are purely algebraic, stating constraints between the variables at the initial time instant.
It is not allowed to use when-clauses in these sections.
\item
For a non-discrete (that is continuous-time) \lstinline!Real! variable \lstinline!vc!, the equation \lstinline!pre(vc) = vc! is added to the initialization equations.
\begin{nonnormative}
Expand Down
22 changes: 9 additions & 13 deletions chapters/functions.tex
Expand Up @@ -4,14 +4,10 @@ \chapter{Functions}\label{functions}

\section{Function Declaration}\label{function-declaration}

A Modelica function is a specialized class (\cref{function-as-a-specialized-class}) using the
keyword \lstinline!function!. The body of a Modelica function is an algorithm
section that contains procedural algorithmic code to be executed when
the function is called, or alternatively an external function specifier
(\cref{external-function-interface}). Formal parameters are specified using the \lstinline!input! keyword,
whereas results are denoted using the \lstinline!output! keyword. This makes the
syntax of function definitions quite close to Modelica class
definitions, but using the keyword \lstinline!function! instead of \lstinline!class!.
A Modelica function is a specialized class (\cref{function-as-a-specialized-class}) using the keyword \lstinline!function!.
The body of a Modelica function is an algorithm section that contains procedural algorithmic code to be executed when the function is called, or alternatively an external function specifier (\cref{external-function-interface}).
Formal parameters are specified using the \lstinline!input!\index{input@\indexinline{input}} keyword, whereas results are denoted using the \lstinline!output!\index{output@\indexinline{output}} keyword.
This makes the syntax of function definitions quite close to Modelica class definitions, but using the keyword \lstinline!function! instead of \lstinline!class!.

\begin{nonnormative}
The structure of a typical function declaration is sketched by
Expand Down Expand Up @@ -241,7 +237,8 @@ \section{Pure Modelica Functions}\label{pure-modelica-functions}
The declaration of functions follow these rules:
\begin{itemize}
\item
Functions defined in Modelica (non-external) are \emph{normally} assumed to be pure (the exception is the deprecated case below), if they are impure they shall be marked with the \lstinline!impure! keyword. They can be explicitly marked as \lstinline!pure!.
Functions defined in Modelica (non-external) are \emph{normally} assumed to be pure (the exception is the deprecated case below), if they are impure they shall be marked with the \lstinline!impure! keyword.
They can be explicitly marked as \lstinline!pure!\index{pure@\indexinline{pure}}.
\begin{nonnormative}
However, since functions as default are pure it is not recommended to explicitly declare them as \lstinline!pure!.
\end{nonnormative}
Expand Down Expand Up @@ -286,9 +283,7 @@ \section{Pure Modelica Functions}\label{pure-modelica-functions}
variables for performance or printing trace output to a log file.
\end{nonnormative}

With the prefix keyword \lstinline!impure! it is stated that a Modelica
function is \emph{impure} and it is only allowed to call such a function
from within:
With the prefix keyword \lstinline!impure!\index{impure@\indexinline{impure}} it is stated that a Modelica function is \emph{impure} and it is only allowed to call such a function from within:
\begin{itemize}
\item
Another function marked with the prefix \lstinline!impure!.
Expand Down Expand Up @@ -1595,6 +1590,7 @@ \section{Declaring Inverses of Functions}\label{declaring-inverses-of-functions}
end sine;
\end{lstlisting}
\end{example}

\section{External Function Interface}\label{external-function-interface}

Here, the word function is used to refer to an arbitrary external
Expand Down Expand Up @@ -1627,7 +1623,7 @@ \section{External Function Interface}\label{external-function-interface}
\end{nonnormative}
\end{itemize}

The format of an external function declaration is as follows.
The format of an external\index{external@\indexinline{external}} function declaration is as follows.
\begin{lstlisting}[language=grammar]
function IDENT description-string
{ component-clause ";" }
Expand Down

0 comments on commit b1265f8

Please sign in to comment.