diff --git a/chapters/arrays.tex b/chapters/arrays.tex index d539422a4..9051db56d 100644 --- a/chapters/arrays.tex +++ b/chapters/arrays.tex @@ -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} @@ -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} @@ -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} @@ -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} @@ -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} @@ -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=!] diff --git a/chapters/classes.tex b/chapters/classes.tex index 64c5eb19a..70f3b38cb 100644 --- a/chapters/classes.tex +++ b/chapters/classes.tex @@ -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 @@ -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 @@ -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, @@ -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! diff --git a/chapters/connectors.tex b/chapters/connectors.tex index 93410d522..dacf90894 100644 --- a/chapters/connectors.tex +++ b/chapters/connectors.tex @@ -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} @@ -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 @@ -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; @@ -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: diff --git a/chapters/equations.tex b/chapters/equations.tex index a546045e9..d1a02a9cd 100644 --- a/chapters/equations.tex +++ b/chapters/equations.tex @@ -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] @@ -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} @@ -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 ";" } @@ -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 ";" } @@ -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 @@ -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} diff --git a/chapters/functions.tex b/chapters/functions.tex index 933542131..de0f01b2e 100644 --- a/chapters/functions.tex +++ b/chapters/functions.tex @@ -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 @@ -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} @@ -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!. @@ -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 @@ -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 ";" } diff --git a/chapters/inheritance.tex b/chapters/inheritance.tex index 29b542fdf..a5dc6bd20 100644 --- a/chapters/inheritance.tex +++ b/chapters/inheritance.tex @@ -17,7 +17,7 @@ \section{Inheritance -- Extends Clause}\label{inheritance-extends-clause} The extends-clause is used to specify inheritance from a base class into an (enclosing) class containing the extends-clause. The syntax of the -extends-clause is as follows: +extends-clause\index{extends@\indexinline{extends}} is as follows: \begin{lstlisting}[language=grammar] extends-clause : extends name [ class-modification ] [annotation] @@ -27,7 +27,6 @@ \section{Inheritance -- Extends Clause}\label{inheritance-extends-clause} class is flattened with a new environment and the partially flattened enclosing class of the extends-clause. The new environment is the result of merging - \begin{itemize} \item arguments of all enclosing class environments that match names in the @@ -467,19 +466,10 @@ \subsection{Modifiers for Array Elements}\label{modifiers-for-array-elements} The following rules apply to modifiers: \begin{itemize} \item - The \lstinline!each! keyword on a modifier requires that it is applied in an array - declaration/modification, and the modifier is applied individually to - each element of the enclosing array (with regard to the position of \lstinline!each!). - In case of nested modifiers this implies it - is applied individually to each element of each element of the - enclosing array; see example. If the modified element is a vector and - the modifier does not contain the \lstinline!each!-prefix, the modification is - split such that the first element in the vector is applied to the - first element of the vector of elements, the second to the second - element, until the last element of the vector-expression is applied to - the last element of the array; it is an error if these sizes do not - match. Matrices and general arrays of elements are treated by viewing - those as vectors of vectors etc. + The \lstinline!each!\index{each@\indexinline{each}} keyword on a modifier requires that it is applied in an array declaration/modification, and the modifier is applied individually to each element of the enclosing array (with regard to the position of \lstinline!each!). + In case of nested modifiers this implies it is applied individually to each element of each element of the enclosing array; see example. + If the modified element is a vector and the modifier does not contain the \lstinline!each!-prefix, the modification is split such that the first element in the vector is applied to the first element of the vector of elements, the second to the second element, until the last element of the vector-expression is applied to the last element of the array; it is an error if these sizes do not match. + Matrices and general arrays of elements are treated by viewing those as vectors of vectors etc. \item If a nested modifier is split, the split is propagated to all elements of the nested modifier, and if they are modified by the \lstinline!each!-keyword @@ -532,7 +522,7 @@ \subsection{Modifiers for Array Elements}\label{modifiers-for-array-elements} \subsection{Final Element Modification Prevention}\label{final-element-modification-prevention} -An element defined as final by the \lstinline!final! prefix in an element modification or declaration cannot be modified by a modification or by a redeclaration. All elements of a final element are also final. +An element defined as final by the \lstinline!final!\index{final@\indexinline{final}} prefix in an element modification or declaration cannot be modified by a modification or by a redeclaration. All elements of a final element are also final. \begin{nonnormative} Setting the value of a parameter in an experiment environment is conceptually treated as a modification. This implies that a final modification equation diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index 138bdb817..d22dad87a 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -164,7 +164,7 @@ \subsection{Integer Literals}\label{integer-literals} \subsection{Boolean Literals}\label{boolean-literals} -The two \lstinline!Boolean! literal values are \lstinline!true! and \lstinline!false!. +The two \lstinline!Boolean! literal values are \lstinline!true!\index{true@\indexinline{true}} and \lstinline!false!\index{false@\indexinline{false}}. \subsection{Strings}\label{strings} diff --git a/chapters/operatorsandexpressions.tex b/chapters/operatorsandexpressions.tex index e94157104..344bde9c3 100644 --- a/chapters/operatorsandexpressions.tex +++ b/chapters/operatorsandexpressions.tex @@ -206,16 +206,14 @@ \section{Equality, Relational, and Logical Operators}\label{equality-relational- \tablehead{Operator} & \tablehead{Description} \\ \hline \hline -\lstinline!not! & Logical negation (unary operator)\\ -\lstinline!and! & Logical \emph{and} (conjunction)\\ -\lstinline!or! & Logical \emph{or} (disjunction)\\ +\lstinline!not!\index{not@\indexinline{not}} & Logical negation (unary operator)\\ +\lstinline!and!\index{and@\indexinline{and}} & Logical \emph{and} (conjunction)\\ +\lstinline!or!\index{or@\indexinline{or}} & Logical \emph{or} (disjunction)\\ \hline \end{tabular} \end{center} -The grammar rules define the syntax of the relational and logical -operators. - +The grammar rules define the syntax of the relational and logical operators. \begin{lstlisting}[language=grammar] logical-expression : logical-term { or logical-term } @@ -288,18 +286,15 @@ \subsection{Array Range Operator}\label{array-range-operator} \subsection{If-Expressions}\label{if-expressions} -An expression +An expression\index{if@\indexinline{if}!expression}\index{then@\indexinline{then}!if-expression}\index{else@\indexinline{else}!if-expression} \begin{lstlisting}[language=modelica] if expression1 then expression2 else expression3 \end{lstlisting} -is one example of if-expression. First \lstinline!expression1!, which must be -\lstinline!Boolean! expression, is evaluated. If \lstinline!expression1! is true \lstinline!expression2! is -evaluated and is the value of the if-expression, else \lstinline!expression3! is -evaluated and is the value of the if-expression. The two expressions, -\lstinline!expression2! and \lstinline!expression3!, must be type compatible expressions -(\cref{type-compatible-expressions}) giving the type of the if-expression. If-expressions with -\lstinline!elseif! are defined by replacing \lstinline!elseif! by \lstinline!else if!. For -short-circuit evaluation see \cref{evaluation-order}. +is one example of if-expression. First \lstinline!expression1!, which must be \lstinline!Boolean! expression, is evaluated. +If \lstinline!expression1! is true \lstinline!expression2! is evaluated and is the value of the if-expression, else \lstinline!expression3! is evaluated and is the value of the if-expression. +The two expressions, \lstinline!expression2! and \lstinline!expression3!, must be type compatible expressions (\cref{type-compatible-expressions}) giving the type of the if-expression. +If-expressions with \lstinline!elseif!\index{elseif@\indexinline{elseif}!if-expression} are defined by replacing \lstinline!elseif! by \lstinline!else if!. +For short-circuit evaluation see \cref{evaluation-order}. \begin{nonnormative} \lstinline!elseif! in expressions has been added to the Modelica language for symmetry with if-clauses. @@ -659,7 +654,7 @@ \subsection{Derivative and Special Purpose Operators with Function Syntax}\label The special purpose operators with function syntax where the call below uses named arguments can be called with named arguments (with the specified names), or with positional arguments (the inputs of the functions are in the order given in the calls below). -\begin{operatordefinition}[der] +\begin{operatordefinition}[der]\index{der@\indexinline{der}} \begin{synopsis}\begin{lstlisting} der($\mathit{expr}$) \end{lstlisting}\end{synopsis} @@ -671,7 +666,7 @@ \subsection{Derivative and Special Purpose Operators with Function Syntax}\label \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[delay] +\begin{operatordefinition}[delay]\index{delay@\indexinline{delay}} \begin{synopsis}\begin{lstlisting} delay($\mathit{expr}$, $\mathit{delayTime}$, $\mathit{delayMax}$) delay($\mathit{expr}$, $\mathit{delayTime}$) @@ -681,7 +676,7 @@ \subsection{Derivative and Special Purpose Operators with Function Syntax}\label \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[cardinality] +\begin{operatordefinition}[cardinality]\index{cardinality@\indexinline{cardinality}} \begin{synopsis}\begin{lstlisting} cardinality($c$) \end{lstlisting}\end{synopsis} @@ -693,7 +688,7 @@ \subsection{Derivative and Special Purpose Operators with Function Syntax}\label \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[homotopy] +\begin{operatordefinition}[homotopy]\index{homotopy@\indexinline{homotopy}} \begin{synopsis}\begin{lstlisting} homotopy(actual=$\mathit{actual}$, simplified=$\mathit{simplified}$) \end{lstlisting}\end{synopsis} @@ -713,7 +708,7 @@ \subsection{Derivative and Special Purpose Operators with Function Syntax}\label \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[semiLinear] +\begin{operatordefinition}[semiLinear]\index{semiLinear@\indexinline{semiLinear}} \begin{synopsis}\begin{lstlisting} semiLinear($x$, $k^{+}$, $k^{-}$) \end{lstlisting}\end{synopsis} @@ -722,7 +717,7 @@ \subsection{Derivative and Special Purpose Operators with Function Syntax}\label \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[inStream] +\begin{operatordefinition}[inStream]\index{inStream@\indexinline{inStream}} \begin{synopsis}\begin{lstlisting} inStream($v$) \end{lstlisting}\end{synopsis} @@ -731,7 +726,7 @@ \subsection{Derivative and Special Purpose Operators with Function Syntax}\label \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[actualStream] +\begin{operatordefinition}[actualStream]\index{actualStream@\indexinline{actualStream}} \begin{synopsis}\begin{lstlisting} actualStream($v$) \end{lstlisting}\end{synopsis} @@ -740,7 +735,7 @@ \subsection{Derivative and Special Purpose Operators with Function Syntax}\label \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[spatialDistribution] +\begin{operatordefinition}[spatialDistribution]\index{spatialDistribution@\indexinline{spatialDistribution}} \begin{synopsis}\begin{lstlisting} spatialDistribution( in0=$\mathit{in0}$, in1=$\mathit{in1}$, x=$x$, @@ -753,7 +748,7 @@ \subsection{Derivative and Special Purpose Operators with Function Syntax}\label \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[getInstanceName] +\begin{operatordefinition}[getInstanceName]\index{getInstanceName@\indexinline{getInstanceName}} \begin{synopsis}\begin{lstlisting} getInstanceName() \end{lstlisting}\end{synopsis} @@ -1217,7 +1212,7 @@ \subsection{Event-Related Operators with Function Syntax}\label{event-related-op \end{tabular} \end{center} -\begin{operatordefinition}[initial] +\begin{operatordefinition}[initial]\index{initial@\indexinline{initial}} \begin{synopsis}\begin{lstlisting} initial() \end{lstlisting}\end{synopsis} @@ -1229,7 +1224,7 @@ \subsection{Event-Related Operators with Function Syntax}\label{event-related-op \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[terminal] +\begin{operatordefinition}[terminal]\index{terminal@\indexinline{terminal}} \begin{synopsis}\begin{lstlisting} terminal() \end{lstlisting}\end{synopsis} @@ -1241,7 +1236,7 @@ \subsection{Event-Related Operators with Function Syntax}\label{event-related-op \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[noEvent] +\begin{operatordefinition}[noEvent]\index{noEvent@\indexinline{noEvent}} \begin{synopsis}\begin{lstlisting} noEvent($\mathit{expr}$) \end{lstlisting}\end{synopsis} @@ -1250,7 +1245,7 @@ \subsection{Event-Related Operators with Function Syntax}\label{event-related-op \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[smooth] +\begin{operatordefinition}[smooth]\index{smooth@\indexinline{smooth}} \begin{synopsis}\begin{lstlisting} smooth($p$, $\mathit{expr}$) \end{lstlisting}\end{synopsis} @@ -1276,7 +1271,7 @@ \subsection{Event-Related Operators with Function Syntax}\label{event-related-op \end{semantics} \end{operatordefinition} -\begin{operatordefinition*}[sample]\label{modelica:event-sample} +\begin{operatordefinition*}[sample]\label{modelica:event-sample}\index{sample@\indexinline{sample}} \begin{synopsis}\begin{lstlisting} sample($\mathit{start}$, $\mathit{interval}$) \end{lstlisting}\end{synopsis} @@ -1285,7 +1280,7 @@ \subsection{Event-Related Operators with Function Syntax}\label{event-related-op \end{semantics} \end{operatordefinition*} -\begin{operatordefinition}[pre] +\begin{operatordefinition}[pre]\index{pre@\indexinline{pre}} \begin{synopsis}\begin{lstlisting} pre($y$) \end{lstlisting}\end{synopsis} @@ -1310,7 +1305,7 @@ \subsection{Event-Related Operators with Function Syntax}\label{event-related-op \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[edge] +\begin{operatordefinition}[edge]\index{edge@\indexinline{edge}} \begin{synopsis}\begin{lstlisting} edge($b$) \end{lstlisting}\end{synopsis} @@ -1319,7 +1314,7 @@ \subsection{Event-Related Operators with Function Syntax}\label{event-related-op \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[change] +\begin{operatordefinition}[change]\index{change@\indexinline{change}} \begin{synopsis}\begin{lstlisting} change(v) \end{lstlisting}\end{synopsis} @@ -1328,7 +1323,7 @@ \subsection{Event-Related Operators with Function Syntax}\label{event-related-op \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[reinit] +\begin{operatordefinition}[reinit]\index{reinit@\indexinline{reinit}} \begin{synopsis}\begin{lstlisting} reinit($x$, $\mathit{expr}$) \end{lstlisting}\end{synopsis} diff --git a/chapters/packages.tex b/chapters/packages.tex index 161781ad2..58140977b 100644 --- a/chapters/packages.tex +++ b/chapters/packages.tex @@ -56,7 +56,7 @@ \section{Importing Definitions from a Package}\label{importing-definitions-from- \end{nonnormative} %TODO-FORMAT Should be formatted using tabs or tabular? -An \lstinline!import!-clause can occur in one of the following syntactic forms: +An \lstinline!import!-clause\index{import@\indexinline{import}} can occur in one of the following syntactic forms: % Note a syntactic form cannot be written as a single \lstinline due to LaTeXML problem reported here: % https://github.com/brucemiller/LaTeXML/issues/1274 (marked as fixed as of commit 80d7940) @@ -260,16 +260,13 @@ \subsection{Mapping a Package/Class Hierarchy into a Single File (Nonstructured \subsection{The within Clause}\label{the-within-clause} -A within-clause has the following syntax: +A within-clause\index{within@\indexinline{within}} has the following syntax: \begin{lstlisting}[language=grammar] within [ packageprefixname ] ";" \end{lstlisting} - A non-top-level entity shall begin with a within-clause which for the - class defined in the entity specifies the location in the Modelica class - hierarchy. A top-level class may contain a within-clause with no name. - For a sub-entity of an enclosing structured entity, the within-clause -shall designate the class of the enclosing entity; and this class must -exist and must not have been defined using a short class definition. +A non-top-level entity shall begin with a within-clause which for the class defined in the entity specifies the location in the Modelica class hierarchy. +A top-level class may contain a within-clause with no name. +For a sub-entity of an enclosing structured entity, the within-clause shall designate the class of the enclosing entity; and this class must exist and must not have been defined using a short class definition. \begin{example} The subpackage \lstinline!Rotational! declared within diff --git a/chapters/scoping.tex b/chapters/scoping.tex index 886aeff11..757953d63 100644 --- a/chapters/scoping.tex +++ b/chapters/scoping.tex @@ -173,9 +173,7 @@ \subsection{Lookup of Imported Names}\label{lookup-of-imported-names1} \section{Instance Hierarchy Name Lookup of Inner Declarations}\label{instance-hierarchy-name-lookup-of-inner-declarations} -An element declared with the prefix \lstinline!outer! references an element instance -with the same name but using the prefix \lstinline!inner! which is nearest in the -enclosing instance hierarchy of the \lstinline!outer! element declaration. +An element declared with the prefix \lstinline!outer!\index{outer@\indexinline{outer}} references an element instance with the same name but using the prefix \lstinline!inner!\index{inner@\indexinline{inner}} which is nearest in the enclosing instance hierarchy of the \lstinline!outer! element declaration. Outer component declarations shall not have modifications (including binding equations). Outer class declarations should be defined using short-class diff --git a/chapters/statemachines.tex b/chapters/statemachines.tex index 87a94cafd..b63fef205 100644 --- a/chapters/statemachines.tex +++ b/chapters/statemachines.tex @@ -83,7 +83,7 @@ \section{Transitions}\label{transitions} \end{tabular} \end{center} -\begin{operatordefinition}[transition] +\begin{operatordefinition}[transition]\index{transition@\indexinline{transition}} \begin{synopsis}\begin{lstlisting} transition($\mathit{from}$, $\mathit{to}$, $\mathit{condition}$, immediate=$\mathit{imm}$, reset=$\mathit{reset}$, synchronize=$\mathit{synch}$, priority=$\mathit{prio}$) @@ -104,7 +104,7 @@ \section{Transitions}\label{transitions} \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[initialState] +\begin{operatordefinition}[initialState]\index{initialState@\indexinline{initialState}} \begin{synopsis}\begin{lstlisting} initialState($\mathit{state}$) \end{lstlisting}\end{synopsis} @@ -113,7 +113,7 @@ \section{Transitions}\label{transitions} \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[activeState] +\begin{operatordefinition}[activeState]\index{activeState@\indexinline{activeState}} \begin{synopsis}\begin{lstlisting} activeState($\mathit{state}$) \end{lstlisting}\end{synopsis} @@ -124,7 +124,7 @@ \section{Transitions}\label{transitions} \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[ticksInState] +\begin{operatordefinition}[ticksInState]\index{ticksInState@\indexinline{ticksInState}} \begin{synopsis}\begin{lstlisting} ticksInState() \end{lstlisting}\end{synopsis} @@ -135,7 +135,7 @@ \section{Transitions}\label{transitions} \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[timeInState] +\begin{operatordefinition}[timeInState]\index{timeInState@\indexinline{timeInState}} \begin{synopsis}\begin{lstlisting} timeInState() \end{lstlisting}\end{synopsis} diff --git a/chapters/statements.tex b/chapters/statements.tex index af120649d..4ad4cc143 100644 --- a/chapters/statements.tex +++ b/chapters/statements.tex @@ -9,11 +9,11 @@ \chapter{Statements and Algorithm Sections}\label{statements-and-algorithm-secti \section{Algorithm Sections}\label{algorithm-sections} -An algorithm section is comprised of the keyword \lstinline!algorithm! followed by a -sequence of statements. The formal syntax is as follows: +An algorithm section is comprised of the keyword \lstinline!algorithm!\index{algorithm@\indexinline{algorithm}} followed by a sequence of statements. +The formal syntax is as follows: \begin{lstlisting}[language=grammar] algorithm-section : -[ initial ] algorithm { statement ";" | annotation ";" } + [ initial ] algorithm { statement ";" | annotation ";" } \end{lstlisting} Equation equality \lstinline!=! or any other kind of equation (see \cref{equations}) shall @@ -179,7 +179,7 @@ \subsubsection{Restrictions on assigned variables}\label{restrictions-on-assigne \subsection{For-statement}\label{for-statement} -The syntax of a for-statement is as follows: +The syntax of a for-statement\index{for@\indexinline{for}!statement}\index{loop@\indexinline{loop}!for-statement} is as follows: \begin{lstlisting}[language=grammar] for for-indices loop { statement ";" } @@ -295,7 +295,7 @@ \subsubsection{Nested For-Loops and Reduction Expressions with Multiple Iterator \subsection{While-Statement}\label{while-statement} -The while-statement has the following syntax: +The while-statement\index{while@\indexinline{while}!statement}\index{loop@\indexinline{loop}!while-statement} has the following syntax: \begin{lstlisting}[language=grammar] while expression loop { statement ";" } @@ -347,12 +347,12 @@ \subsection{Return-Statements}\label{return-statements} \subsection{If-Statement}\label{if-statement} -If-statements have the following syntax: +If-statements\index{if@\indexinline{if}!statement}\index{then@\indexinline{then}!if-statement}\index{else@\indexinline{else}!if-statement}\index{elseif@\indexinline{elseif}!if-statement} have the following syntax: \begin{lstlisting}[language=grammar] if expression then { statement ";" } - { elseif expression then - { statement ";" } + { elseif expression then + { statement ";" } } [ else { statement ";" } @@ -364,7 +364,7 @@ \subsection{If-Statement}\label{if-statement} \subsection{When-Statements}\label{when-statements} -A when-statement has the following syntax: +A when-statement\index{when@\indexinline{when}!statement}\index{then@\indexinline{then}!when-statement}\index{elsewhen@\indexinline{elsewhen}!when-statement} has the following syntax: \begin{lstlisting}[language=grammar] when expression then { statement ";" } diff --git a/chapters/stream.tex b/chapters/stream.tex index f0773e450..a72b4aa59 100644 --- a/chapters/stream.tex +++ b/chapters/stream.tex @@ -2,22 +2,17 @@ \chapter{Stream Connectors}\label{stream-connectors} The two basic variable types in a connector -- \emph{potential} (or \emph{across}) variable and \emph{flow} (or \emph{through}) variable -- are not sufficient to describe in a numerically sound way the bi-directional flow of matter with convective transport of specific quantities, such as specific enthalpy and chemical composition. The values of these specific quantities are determined from the upstream side of the flow, i.e., they depend on the flow direction. When using across and through variables, the corresponding models would include nonlinear systems of equations with \lstinline!Boolean! unknowns for the flow directions and singularities around zero flow. Such equation systems cannot be solved reliably in general. The model formulations can be simplified when formulating two different balance equations for the two possible flow directions. This is not possible with across and through variables though. -This fundamental problem is addressed in Modelica by introducing a third -type of connector variable, called stream variable, declared with the -prefix \lstinline!stream!. A stream variable describes a quantity that is -carried by a flow variable, i.e., a purely convective transport -phenomenon. The value of the stream variable is the specific property -inside the component close to the boundary, assuming that matter flows -out of the component into the connection point. In other words, it is -the value the carried quantity would have if the fluid was flowing out -of the connector, irrespective of the actual flow direction. +This fundamental problem is addressed in Modelica by introducing a third type of connector variable, called \willintroduce{stream variable}, declared with the prefix \lstinline!stream!. +A stream variable describes a quantity that is carried by a flow variable, i.e., a purely convective transport phenomenon. +The value of the stream variable is the specific property inside the component close to the boundary, assuming that matter flows out of the component into the connection point. +In other words, it is the value the carried quantity would have if the fluid was flowing out of the connector, irrespective of the actual flow direction. The rationale of the definition and typical use cases are described in \cref{derivation-of-stream-equations}. \section{Definition of Stream Connectors}\label{definition-of-stream-connectors} -If at least one variable in a connector has the \lstinline!stream! prefix, the connector is called \firstuse{stream connector}\index{stream!connector} and the corresponding variable is called \firstuse{stream variable}\index{stream!variable}. +If at least one variable in a connector has the \lstinline!stream!\index{stream@\indexinline{stream}} prefix, the connector is called \firstuse{stream connector}\index{stream!connector} and the corresponding variable is called \firstuse{stream variable}\index{stream!variable}. The following definitions hold: \begin{itemize} \item diff --git a/chapters/synchronous.tex b/chapters/synchronous.tex index beddf17d5..9b2417dfc 100644 --- a/chapters/synchronous.tex +++ b/chapters/synchronous.tex @@ -547,7 +547,7 @@ \section{Clocked State Variables}\label{clocked-state-variables} A variable to which \lstinline!previous! has been applied is called a \firstuse{clocked state variable}\index{clocked state variable}\index{state variable!clocked}. -\begin{operatordefinition}[previous] +\begin{operatordefinition}[previous]\index{previous@\indexinline{previous}} \begin{synopsis}\begin{lstlisting} previous($u$) \end{lstlisting}\end{synopsis} @@ -598,7 +598,7 @@ \subsection{Base-clock conversion operators}\label{base-clock-conversion-operato \end{semantics} \end{operatordefinition*} -\begin{operatordefinition}[hold] +\begin{operatordefinition}[hold]\index{hold@\indexinline{hold}} \begin{synopsis}\begin{lstlisting} hold($u$) \end{lstlisting}\end{synopsis} @@ -672,7 +672,7 @@ \subsection{Sub-clock conversion operators}\label{sub-clock-conversion-operators The input arguments \lstinline!shiftCounter! and \lstinline!backCounter! are parameter expressions of type \lstinline!Integer! with \lstinline!min = 0!. \end{itemize} -\begin{operatordefinition}[subSample] +\begin{operatordefinition}[subSample]\index{subSample@\indexinline{subSample}} \begin{synopsis}\begin{lstlisting} subSample($u$, factor=$\mathit{factor}$) \end{lstlisting}\end{synopsis} @@ -681,7 +681,7 @@ \subsection{Sub-clock conversion operators}\label{sub-clock-conversion-operators \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[superSample] +\begin{operatordefinition}[superSample]\index{superSample@\indexinline{superSample}} \begin{synopsis}\begin{lstlisting} superSample($u$, factor=$\mathit{factor}$) \end{lstlisting}\end{synopsis} @@ -704,7 +704,7 @@ \subsection{Sub-clock conversion operators}\label{sub-clock-conversion-operators \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[shiftSample] +\begin{operatordefinition}[shiftSample]\index{shiftSample@\indexinline{shiftSample}} \begin{synopsis}\begin{lstlisting} shiftSample($u$, shiftCounter=$k$, resolution=$\mathit{resolution}$) \end{lstlisting}\end{synopsis} @@ -734,7 +734,7 @@ \subsection{Sub-clock conversion operators}\label{sub-clock-conversion-operators \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[backSample] +\begin{operatordefinition}[backSample]\index{backSample@\indexinline{backSample}} \begin{synopsis}\begin{lstlisting} backSample($u$, backCounter=$\mathit{cnt}$, resolution=$\mathit{res}$) \end{lstlisting}\end{synopsis} @@ -769,7 +769,7 @@ \subsection{Sub-clock conversion operators}\label{sub-clock-conversion-operators \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[noClock] +\begin{operatordefinition}[noClock]\index{noClock@\indexinline{noClock}} \begin{synopsis}\begin{lstlisting} noClock($u$) \end{lstlisting}\end{synopsis} @@ -1357,7 +1357,7 @@ \section{Other Operators}\label{other-operators} It is an error if these operators are called in the continuous-time partition. -\begin{operatordefinition}[firstTick] +\begin{operatordefinition}[firstTick]\index{firstTick@\indexinline{firstTick}} \begin{synopsis}\begin{lstlisting} firstTick($u$) \end{lstlisting}\end{synopsis} @@ -1366,7 +1366,7 @@ \section{Other Operators}\label{other-operators} \end{semantics} \end{operatordefinition} -\begin{operatordefinition}[interval] +\begin{operatordefinition}[interval]\index{interval@\indexinline{interval}} \begin{synopsis}\begin{lstlisting} interval($u$) \end{lstlisting}\end{synopsis} diff --git a/mlsshared.sty b/mlsshared.sty index 1b0e7f458..e3f9b1314 100644 --- a/mlsshared.sty +++ b/mlsshared.sty @@ -47,12 +47,17 @@ nondiscrete,% Not a keyword anymore, right? operator,outer,% output,package,parameter,partial,record,redeclare,replaceable,return,% - size,stream,terminate,then,type,when,while,within,algorithm,equation,% - protected,public,and,false,not,or,true,pure,impure,transition,initialState},% + size,% Not a keyword, right? + stream,terminate,then,type,when,while,within,algorithm,equation,% + protected,public,and,false,not,or,true,pure,impure,% + transition,% Not a keyword + initialState% Not a keyword. What about all the other operators in statemachines.tex? + },% % Note: initial is in both variants - depending on context, use first variant morekeywords=[3]{% red keywords - only special functions and classes: 3.7.2 #derivative-and-special-purpose-operators-with-function-syntax % 3.7.3 #event-related-operators-with-function-syntax (except initial) and 4.8 #predefined-types-and-classes - connect,der,delay,cardinality,homotopy,semiLinear,inStream,actualStream,spatialDistribution,getInstanceName,% + connect,% This is a keyword! + der,delay,cardinality,homotopy,semiLinear,inStream,actualStream,spatialDistribution,getInstanceName,% terminal,noEvent,smooth,sample,pre,edge,change,reinit,% previous,hold,subSample,superSample,shiftSample,backSample,noClock,firstTick,interval,% Real,Integer,Boolean,String},%