From a21efbed1bcaca5574cae920084e10faa93efa2a Mon Sep 17 00:00:00 2001 From: Henrik Tidefelt Date: Wed, 14 Apr 2021 22:41:20 +0200 Subject: [PATCH] Use correct variants of "clause" By accident, this commit also includes added empty lines around sectioning commands, which should have been committed separately. --- chapters/annotations.tex | 26 ++++----- chapters/arrays.tex | 31 +++++------ chapters/classes.tex | 27 ++++++---- chapters/connectors.tex | 2 +- chapters/dae.tex | 6 +-- chapters/derivationofstream.tex | 13 +++-- chapters/equations.tex | 52 ++++++++++-------- chapters/functions.tex | 13 +++-- chapters/inheritance.tex | 80 ++++++++++++---------------- chapters/interface.tex | 8 +-- chapters/introduction.tex | 8 +-- chapters/operatorsandexpressions.tex | 37 +++++++------ chapters/packages.tex | 50 ++++++++--------- chapters/revisions.tex | 66 +++++++++++------------ chapters/scoping.tex | 23 ++++---- chapters/statemachines.tex | 1 + chapters/statements.tex | 3 +- chapters/synchronous.tex | 49 ++++++++--------- chapters/syntax.tex | 9 ++++ chapters/unitexpressions.tex | 1 + 20 files changed, 258 insertions(+), 247 deletions(-) diff --git a/chapters/annotations.tex b/chapters/annotations.tex index e68a4fce3..9fe22124a 100644 --- a/chapters/annotations.tex +++ b/chapters/annotations.tex @@ -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} @@ -570,7 +570,7 @@ \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 @@ -578,7 +578,7 @@ \section{Annotations for Graphical Objects}\label{annotations-for-graphical-obje \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} @@ -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}})!. @@ -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 @@ -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} @@ -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. @@ -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}. diff --git a/chapters/arrays.tex b/chapters/arrays.tex index 4171c1a17..8f50603ba 100644 --- a/chapters/arrays.tex +++ b/chapters/arrays.tex @@ -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.)} @@ -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} @@ -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!. diff --git a/chapters/classes.tex b/chapters/classes.tex index 11d6e7153..496bd2d3f 100644 --- a/chapters/classes.tex +++ b/chapters/classes.tex @@ -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!, @@ -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 @@ -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] @@ -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. @@ -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 diff --git a/chapters/connectors.tex b/chapters/connectors.tex index 7dded30ba..91d85047a 100644 --- a/chapters/connectors.tex +++ b/chapters/connectors.tex @@ -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} diff --git a/chapters/dae.tex b/chapters/dae.tex index ecb6bd240..63522a9cd 100644 --- a/chapters/dae.tex +++ b/chapters/dae.tex @@ -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 @@ -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$. @@ -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. diff --git a/chapters/derivationofstream.tex b/chapters/derivationofstream.tex index f8207a68b..7fd0fe87a 100644 --- a/chapters/derivationofstream.tex +++ b/chapters/derivationofstream.tex @@ -151,7 +151,9 @@ \section{Rationale for the formulation of inStream}\label{rationale-for-the-form \end{equation*} \section{Special cases covered by inStream definition}\label{special-cases-covered-by-the-instream-operator-definition} + \subsection{Stream connector is not connected (N = 1)}\label{stream-connector-is-not-connected-n-1} + For this case, the return value of \lstinline!inStream! is arbitrary. Therefore, it is set to the outflow value. @@ -169,15 +171,12 @@ \subsection{Connection of 2 stream connectors, one to one connections (N = 2)}\l case is treated directly. \subsection{Connection of 3 stream connectors where one mass flow rate is identical to zero}\label{connection-of-3-stream-connectors-where-one-mass-flow-rate-is-identical-to-zero-n-3-and} -The case where $N=3$ and $\tilde{m}_3=0$ occurs when a one-port sensor (like a temperature sensor) is -connected to two connected components. For the sensor, the \lstinline!min! attribute -of the mass flow rate should be set to zero (no fluid exiting the -component via this connector). + +The case where $N=3$ and $\tilde{m}_3=0$ occurs when a one-port sensor (like a temperature sensor) is connected to two connected components. +For the sensor, the \lstinline!min! attribute of the mass flow rate should be set to zero (no fluid exiting the component via this connector). This simplification (and similar ones) can also be used if a tool determines that a mass flow rate is zero or non-negative. It is also possible to generalize this to the case where more than one sensor is connected. -The suggested implementation results in -the following equations, and as indicated the last formula can be -simplified further by using $\tilde{m}_3=0$: +The suggested implementation results in the following equations, and as indicated the last formula can be simplified further by using $\tilde{m}_3=0$: \begin{align*} \text{\lstinline!inStream!}(h_{\mathrm{outflow},1}) &= h_{\mathrm{outflow},2}\\ \text{\lstinline!inStream!}(h_{\mathrm{outflow},2}) &= h_{\mathrm{outflow},1}\\ diff --git a/chapters/equations.tex b/chapters/equations.tex index dbb872f9d..907a7e567 100644 --- a/chapters/equations.tex +++ b/chapters/equations.tex @@ -154,7 +154,9 @@ \subsection{Connect-Equations}\label{connect-equations} connect "(" component-reference "," component-reference ")" ";" \end{lstlisting} -These can be placed inside for-equations and if-equations; provided the indices of the for-loop and conditions of the if-clause are parameter expressions that do not depend on \lstinline!cardinality!, \lstinline!rooted!, \lstinline!Connections.rooted!, or \lstinline!Connections.isRoot!. The for-equations/if-equations are expanded. Connect-equations are described in detail in \cref{connect-equations-and-connectors}. +These can be placed inside \lstinline!for!-equations and \lstinline!if!-equations; provided the indices of the \lstinline!for!-loop and conditions of the \lstinline!if!-equation are parameter expressions that do not depend on \lstinline!cardinality!, \lstinline!rooted!, \lstinline!Connections.rooted!, or \lstinline!Connections.isRoot!. +The for-equations/if-equations are expanded. +Connect-equations are described in detail in \cref{connect-equations-and-connectors}. The same restrictions apply to \lstinline!Connections.branch!, \lstinline!Connections.root!, and \lstinline!Connections.potentialRoot!; which after expansion are handled according to \cref{equation-operators-for-overconstrained-connection-based-equation-systems1}. @@ -172,7 +174,12 @@ \subsection{If-Equations}\label{if-equations} end if ";" \end{lstlisting} -The \lstinline!expression! of an if- or elseif-clause must be a scalar \lstinline!Boolean! expression. One if-clause, and zero or more elseif-clauses, and an optional else-clause together form a list of branches. One or zero of the bodies of these if-, elseif- and else-clauses is selected, by evaluating the conditions of the if- and elseif-clauses sequentially until a condition that evaluates to true is found. If none of the conditions evaluate to true the body of the else-clause is selected (if an else-clause exists, otherwise no body is selected). In an equation section, the equations in the body are seen as equations that must be satisfied. The bodies that are not selected have no effect on that model evaluation. +The \lstinline!expression! of an \lstinline!if!- or \lstinline!elseif!-clause must be a scalar \lstinline!Boolean! expression. +One \lstinline!if!-clause, and zero or more \lstinline!elseif!-clauses, and an optional \lstinline!else!-clause together form a list of branches. +One or zero of the bodies of these \lstinline!if!-, \lstinline!elseif!- and \lstinline!else!-clauses is selected, by evaluating the conditions of the \lstinline!if!- and \lstinline!elseif!-clauses sequentially until a condition that evaluates to true is found. +If none of the conditions evaluate to true the body of the \lstinline!else!-clause is selected (if an \lstinline!else!-clause exists, otherwise no body is selected). +In an equation section, the equations in the body are seen as equations that must be satisfied. +The bodies that are not selected have no effect on that model evaluation. If-equations in equation sections which do not have exclusively parameter expressions as switching conditions shall have the same number @@ -232,7 +239,7 @@ \subsubsection{Defining When-Equations by If-Expressions in Equality Equations}\ \end{lstlisting} \begin{nonnormative} -The equivalence is conceptual since \lstinline!pre($\ldots$)! of a non discrete-time \lstinline!Real! variable or expression can only be used within a when-clause. Example: +The equivalence is conceptual since \lstinline!pre($\ldots$)! of a non discrete-time \lstinline!Real! variable or expression can only be used within a \lstinline!when!-clause. Example: \begin{lstlisting}[language=modelica] /* discrete */ Real x; input Real u; @@ -245,7 +252,7 @@ \subsubsection{Defining When-Equations by If-Expressions in Equality Equations}\ \end{lstlisting} Here, \lstinline!x! is a discrete-time variable (whether it is declared with the \lstinline!discrete! prefix or not), but \lstinline!u! and \lstinline!y! cannot be discrete-time variables -(since they are not assigned in when-clauses). However, \lstinline!pre(u)! is legal within the when-clause, since the body of the when-clause is only evaluated at events, and thus all expressions +(since they are not assigned in \lstinline!when!-clauses). However, \lstinline!pre(u)! is legal within the \lstinline!when!-clause, since the body of the \lstinline!when!-clause is only evaluated at events, and thus all expressions are discrete-time expressions. \end{nonnormative} @@ -254,6 +261,7 @@ \subsubsection{Defining When-Equations by If-Expressions in Equality Equations}\ The start value of the special functions \lstinline!initial!, \lstinline!terminal!, and \lstinline!sample! is \lstinline!false!. \subsubsection{Restrictions on Where a When-Equation may Occur}\label{restrictions-on-where-a-when-equation-may-occur} + \begin{itemize} \item When-equations shall not occur inside initial equations. @@ -290,10 +298,10 @@ \subsubsection{Restrictions on Equations within When-Equations}\label{restrictio \item The different branches of \lstinline!when!/\lstinline!elsewhen! must have the same set of component references on the left-hand side. \item - The branches of an if-then-else clause inside when-equations must have the same set of component references on the left-hand side, unless the if-then-else have exclusively parameter expressions as switching conditions. + The branches of an \lstinline!if!-equation inside when-equations must have the same set of component references on the left-hand side, unless all switching conditions of the \lstinline!if!-equation are parameter expressions. \end{itemize} -Any left hand side reference, (\lstinline!v!, \lstinline!out1!, \ldots), in a when-clause must +Any left hand side reference, (\lstinline!v!, \lstinline!out1!, \ldots), in a \lstinline!when!-clause must be a component reference, and any indices must be parameter expressions. \begin{nonnormative} @@ -437,7 +445,7 @@ \subsection{reinit}\label{reinit} state variables, some state variables need to be redefined to non-state variables. During simulation, non-state variables should be chosen in such a way that variables with an applied \lstinline!reinit! are -selected as states at least when the corresponding when-clauses become +selected as states at least when the corresponding \lstinline!when!-clauses become active. If this is not possible, an error occurs, since otherwise \lstinline!reinit! would be applied to a non-state variable. @@ -570,7 +578,7 @@ \section{Synchronous Data-flow Principle and Single Assignment Rule}\label{synch \section{Events and Synchronization}\label{events-and-synchronization} An \firstuse{event}\index{event} is something that occurs instantaneously at a specific time or when a specific condition occurs. -Events are for example defined by the condition occurring in a when-clause, if-clause, or \lstinline!if!-expression. +Events are for example defined by the condition occurring in a \lstinline!when!-clause, \lstinline!if!-equation, or \lstinline!if!-expression. The integration is halted and an event occurs whenever an event generation expression, e.g.\ \lstinline!x > 2! o or \lstinline!floor(x)!, changes @@ -622,13 +630,15 @@ \section{Events and Synchronization}\label{events-and-synchronization} In this case \lstinline!x = y = z!, but a tool might generate events for \lstinline!z!. The \lstinline!if!-expression is taken literally without inducing state events. -The \lstinline!smooth! operator is useful, if e.g.\ the modeler can guarantee that the used if-clauses fulfill at least the continuity requirement of integrators. In this case the simulation speed is improved, since no state event iterations occur during integration. The \lstinline!noEvent! operator is used to guard against \emph{outside domain} errors, e.g.\ \lstinline!y = if noEvent(x >= 0) then sqrt(x) else 0.! +The \lstinline!smooth! operator is useful, if e.g.\ the modeler can guarantee that the used \lstinline!if!-expressions fulfill at least the continuity requirement of integrators. +In this case the simulation speed is improved, since no state event iterations occur during integration. +The \lstinline!noEvent! operator is used to guard against \emph{outside domain} errors, e.g.\ \lstinline!y = if noEvent(x >= 0) then sqrt(x) else 0.! \end{example} -All equations and assignment statements within when-clauses and all assignment statements within \lstinline!function! classes are implicitly treated with \lstinline!noEvent!, i.e., relations within the scope of these operators never induce state or time events. +All equations and assignment statements within \lstinline!when!-clauses and all assignment statements within \lstinline!function! classes are implicitly treated with \lstinline!noEvent!, i.e., relations within the scope of these operators never induce state or time events. \begin{nonnormative} -Using state events in when-clauses is unnecessary because the body of a when-clause is not evaluated during continuous integration. +Using state events in \lstinline!when!-clauses is unnecessary because the body of a \lstinline!when!-clause is not evaluated during continuous integration. \end{nonnormative} \begin{example} @@ -707,8 +717,8 @@ \section{Events and Synchronization}\label{events-and-synchronization} end when; \end{lstlisting} -The \lstinline!slowSample! when-clause is evaluated at every 5th occurrence of the -\lstinline!fastSample! when-clause. +The \lstinline!slowSample! \lstinline!when!-clause is evaluated at every 5th occurrence of the +\lstinline!fastSample! \lstinline!when!-clause. \end{nonnormative} \begin{nonnormative} @@ -723,21 +733,21 @@ \section{Initialization, initial equation, and initial algorithm}\label{initiali During this phase, called the \firstuse{initialization problem}\index{initialization problem}, also the derivatives (\lstinline!der!), and the pre-variables (\lstinline!pre!), are interpreted as unknown algebraic variables. The initialization uses all equations and algorithms that are utilized in the intended operation (such as simulation or linearization). -The equations of a when-clause are active during initialization, if and only if they are explicitly enabled with \lstinline!initial()!, and only in one of the two forms -\lstinline!when initial() then! or \lstinline!when {$\ldots$, initial(), $\ldots$} then! (and similarly for \lstinline!elsewhen! and algorithms see below). In this case, the when-clause equations remain active during the +The equations of a \lstinline!when!-clause are active during initialization, if and only if they are explicitly enabled with \lstinline!initial()!, and only in one of the two forms +\lstinline!when initial() then! or \lstinline!when {$\ldots$, initial(), $\ldots$} then! (and similarly for \lstinline!elsewhen! and algorithms see below). In this case, the \lstinline!when!-clause equations remain active during the whole initialization phase. In case of a \lstinline!reinit(x, expr)! being active during initialization (due to being inside \lstinline!when initial()!) this is interpreted as adding \lstinline!x = expr! (the \lstinline!reinit!-equation) as an initial equation. \begin{nonnormative} -If a when-clause equation \lstinline!v = expr;! is not active during the initialization phase, the equation \lstinline!v = pre(v)! is added for -initialization. This follows from the mapping rule of when-clause equations. If the condition of the when-clause contains \lstinline!initial()!, -but not in one of the specific forms, the when-clause is not active during initialization: \lstinline!when not initial() then print("simulation started"); end when;! +If a \lstinline!when!-clause equation \lstinline!v = expr;! is not active during the initialization phase, the equation \lstinline!v = pre(v)! is added for +initialization. This follows from the mapping rule of \lstinline!when!-clause equations. If the condition of the \lstinline!when!-clause contains \lstinline!initial()!, +but not in one of the specific forms, the \lstinline!when!-clause is not active during initialization: \lstinline!when not initial() then print("simulation started"); end when;! \end{nonnormative} The algorithmic statements within a \lstinline!when!-statement are active during initialization, if and only they are explicitly enabled with \lstinline!initial()!, and only in one of the two forms \lstinline!when initial() then! or \lstinline!when {$\ldots$, initial(), $\ldots$} then!. In this case, the algorithmic statements within the \lstinline!when!-statement remain active during the whole initialization phase. -An active when-clause inactivates the following \lstinline!elsewhen! (similarly as for when-clauses during simulation), but apart from that +An active \lstinline!when!-clause inactivates the following \lstinline!elsewhen! (similarly as for \lstinline!when!-clauses during simulation), but apart from that the first \lstinline!elsewhen initial() then! or \lstinline!elsewhen {$\ldots$, initial(), $\ldots$} then! is similarly active during initialization as \lstinline!when initial() then! or \lstinline!when {$\ldots$, initial(), $\ldots$} then!. @@ -756,7 +766,7 @@ \section{Initialization, initial equation, and initial algorithm}\label{initiali \item As equations in an \lstinline!initial equation!\indexinline{initial equation} section or as assignments in an \lstinline!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. + It is not allowed to use \lstinline!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} @@ -813,7 +823,7 @@ \section{Initialization, initial equation, and initial algorithm}\label{initiali It may be difficult for a user to figure out how many initial equations have to be added, especially if the system has a higher index. A tool may add or remove initial equations automatically such that the resulting system is structurally nonsingular. In these cases diagnostics are appropriate since the result is not unique and not necessarily what the user expects. A missing initial value of a discrete-time variable which does not influence the simulation result, may be automatically set to the \lstinline!start! value or its default without -informing the user. For example, variables assigned in a when-clause which are not accessed outside of the when-clause and where \lstinline!pre! is not explicitly +informing the user. For example, variables assigned in a \lstinline!when!-clause which are not accessed outside of the \lstinline!when!-clause and where \lstinline!pre! is not explicitly used on these variables, do not have an effect on the simulation. \end{nonnormative} diff --git a/chapters/functions.tex b/chapters/functions.tex index 5ca8118d8..b7d3f82d0 100644 --- a/chapters/functions.tex +++ b/chapters/functions.tex @@ -707,8 +707,8 @@ \subsection{Output Formal Parameters of Functions}\label{output-formal-parameter \end{lstlisting} \end{example} -\subsection{Initialization and Binding Equations of Components in Functions} -\label{initialization-and-binding-equations-of-components-in-functions} +\subsection{Initialization and Binding Equations of Components in Functions}% +\label{initialization-and-binding-equations-of-components-in-functions}% \label{initialization-and-declaration-assignments-of-components-in-functions} Components in a function can be divided into three groups: @@ -917,7 +917,7 @@ \section{Record Constructor Functions}\label{record-constructor-functions} The declaration of the record is partially flattened including inheritance, modifications, redeclarations, and expansion of all names referring to declarations outside of the scope of the record to their fully qualified names. \begin{nonnormative} -The partial flattening is performed in order to remove potentially conflicting import-clauses in the record constructor function due to flattening the inheritance tree. +The partial flattening is performed in order to remove potentially conflicting \lstinline!import!-clauses in the record constructor function due to flattening the inheritance tree. \end{nonnormative} All record elements (i.e., components and local class @@ -1794,7 +1794,7 @@ \subsubsection{Simple Types}\label{simple-types} \subsubsection{Arrays}\label{arrays-1} -Unless an explicit function call is present in the external-clause, an array is passed by its address followed by $n$ arguments of type \lstinline!size_t! with the corresponding array dimension sizes, where $n$ is the number of dimensions. +Unless an explicit function call is present in the \lstinline!external!-clause, an array is passed by its address followed by $n$ arguments of type \lstinline!size_t! with the corresponding array dimension sizes, where $n$ is the number of dimensions. \begin{nonnormative} The type \lstinline[language=C]!size_t! is a C unsigned integer type. @@ -2088,7 +2088,7 @@ \subsection{Aliasing}\label{aliasing} \subsection{Annotations for External Libraries and Include Files}\label{annotations-for-external-libraries-and-include-files} -The following annotations are useful in the context of calling external functions from Modelica, and they should occur on the external-clause and no other standard annotations should occur on the external-clause. +The following annotations are useful in the context of calling external functions from Modelica, and they should occur on the \lstinline!external!-clause and no other standard annotations should occur on the \lstinline!external!-clause. They can all specify either a scalar value or an array of values as indicated below for the \lstinline!Library! annotation: \begin{itemize} \item @@ -2542,8 +2542,7 @@ \subsection{External Objects}\label{external-objects} This is the only use of \lstinline!class!. \end{nonnormative} \item - Classes derived from \lstinline!ExternalObject! can neither be used in an - extends-clause nor in a short class definition. + Classes derived from \lstinline!ExternalObject! can neither be used in an \lstinline!extends!-clause nor in a short class definition. \item Only the constructor may return external objects and an external object can only be bound in component declarations and neither modified later diff --git a/chapters/inheritance.tex b/chapters/inheritance.tex index c017b0d30..9c6ded124 100644 --- a/chapters/inheritance.tex +++ b/chapters/inheritance.tex @@ -10,28 +10,25 @@ \section{Inheritance -- Extends Clause}\label{inheritance-extends-clause} The class \lstinline!A! is called a \firstuse{base class}\index{base class} of \lstinline!B!, if \lstinline!B! extends \lstinline!A!. The converse relation is then expressed as \lstinline!B! being a \firstuse{derived class}\index{derived class} of \lstinline!A!, or as \lstinline!B! being \firstuse{derived from} \lstinline!A!. -This relation is specified by an extends-clause in \lstinline!B! or in one of \lstinline!B!'s base classes. +This relation is specified by an \lstinline!extends!-clause in \lstinline!B! or in one of \lstinline!B!'s base classes. A class inherits all elements from its base classes, and may modify all non-final elements inherited from base classes, as explained below. -The \firstuse{extends-clause}\index{extends-clause} is used to specify inheritance from a base class into an (enclosing) class containing the extends-clause. +The \lstinline!extends!-clause is used to specify inheritance from a base class into an (enclosing) class containing the \lstinline!extends!-clause. It is an unnamed element of a class definition that uses a name and an optional modification to specify a base class of the class defined using the class definition. -The syntax of the extends-clause is as follows: +The syntax of the \lstinline!extends!-clause is as follows: \begin{lstlisting}[language=grammar] extends-clause : extends name [ class-modification ] [annotation] \end{lstlisting}% \indexinline{extends} -The name of the base class is looked up in the partially flattened -enclosing class (\cref{enclosing-classes}) of the extends-clause. The found base -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 +The name of the base class is looked up in the partially flattened enclosing class (\cref{enclosing-classes}) of the \lstinline!extends!-clause. +The found base class is flattened with a new environment and the partially flattened enclosing class of the \lstinline!extends!-clause. +The new environment is the result of merging \begin{itemize} \item - arguments of all enclosing class environments that match names in the - flattened base class + arguments of all enclosing class environments that match names in the flattened base class \item - the optional \lstinline!class-modification! of the extends-clause + the optional \lstinline!class-modification! of the \lstinline!extends!-clause \end{itemize} in that order. @@ -51,7 +48,7 @@ \section{Inheritance -- Extends Clause}\label{inheritance-extends-clause} \end{lstlisting} \end{example} -The elements of the flattened base class become elements of the flattened enclosing class, and are added at the place of the extends-clause: specifically components and classes, the equation sections, algorithm sections, optional external-clause, and the contents of the annotation at the end of the class, but excluding import-clauses. +The elements of the flattened base class become elements of the flattened enclosing class, and are added at the place of the \lstinline!extends!-clause: specifically components and classes, the equation sections, algorithm sections, optional \lstinline!external!-clause, and the contents of the annotation at the end of the class, but excluding \lstinline!import!-clauses. \begin{nonnormative} From the example above we get the following flattened class: @@ -117,27 +114,18 @@ \section{Inheritance -- Extends Clause}\label{inheritance-extends-clause} \subsection{Multiple Inheritance}\label{multiple-inheritance} -Multiple inheritance is possible since multiple extends-clauses can be -present in a class. +Multiple inheritance is possible since multiple \lstinline!extends!-clauses can be present in a class. \subsection{Inheritance of Protected and Public Elements}\label{inheritance-of-protected-and-public-elements} -If an extends-clause is used under the \lstinline!protected! heading, all elements -of the base class become protected elements of the current class. If an -extends-clause is a public element, all elements of the base class are -inherited with their own protection. The eventual headings \lstinline!protected! and -\lstinline!public! from the base class do not affect the consequent elements of the -current class (i.e., headings \lstinline!protected! and \lstinline!public! are not inherited). +If an \lstinline!extends!-clause is used under the \lstinline!protected! heading, all elements of the base class become protected elements of the current class. +If an \lstinline!extends!-clause is a public element, all elements of the base class are inherited with their own protection. +The eventual headings \lstinline!protected! and \lstinline!public! from the base class do not affect the consequent elements of the current class (i.e., headings \lstinline!protected! and \lstinline!public! are not inherited). \subsection{Restrictions on the Kind of Base Class}\label{restrictions-on-the-kind-of-base-class} -Since specialized classes of different kinds have different properties, -see \cref{specialized-classes}, only specialized classes that are \emph{in some sense -compatible} to each other can be derived from each other via -inheritance. The following table shows which kind of specialized class -can be used in an extends clause of another kind of specialized class -(the grey cells mark the few exceptional cases, where a specialized -class can be derived from a specialized class of another kind): +Since specialized classes of different kinds have different properties, see \cref{specialized-classes}, only specialized classes that are \emph{in some sense compatible} to each other can be derived from each other via inheritance. +The following table shows which kind of specialized class can be used in an \lstinline!extends!-clause of another kind of specialized class (the grey cells mark the few exceptional cases, where a specialized class can be derived from a specialized class of another kind): % The PDF contains an excessive amount of vertical space here, but it seems like a bad idea to try to make it go away % by adding LaTeX spacing commands that will cause problems later when things move around. \begin{center} @@ -191,7 +179,7 @@ \subsection{Restrictions on the Kind of Base Class}\label{restrictions-on-the-ki \end{nonnormative} All specialized classes can be derived from \lstinline!class!\indexinline{class}, provided that the resulting class fulfills the restriction of the specialized class. -A \lstinline!class! may only contain class-definitions, annotations, and extends-clauses (having any other contents is deprecated). +A \lstinline!class! may only contain class definitions, annotations, and \lstinline!extends!-clauses (having any other contents is deprecated). \begin{nonnormative} It is recommended to use the most specific specialized class. @@ -203,7 +191,8 @@ \subsection{Restrictions on the Kind of Base Class}\label{restrictions-on-the-ki own kind and from \lstinline!class!. \begin{nonnormative} -E.g.\ a package can only be base class for packages. All other kinds of classes can use the import-clause to use the contents of a package. +E.g.\ a package can only be base class for packages. +All other kinds of classes can use the \lstinline!import!-clause to use the contents of a package. \end{nonnormative} \begin{example} @@ -233,14 +222,14 @@ \subsection{Restrictions on the Kind of Base Class}\label{restrictions-on-the-ki \subsection{Restrictions on Base Classes and Constraining Types to be Transitively Non-Replaceable}\label{restrictions-on-base-classes-and-constraining-types-to-be-transitively-non-replaceable} The class name used after \lstinline!extends! for base classes and for constraining classes must use a class reference considered transitively non-replaceable, see definition in \cref{transitively-non-replaceable}. -For a replaceable component declaration without constraining clause the class must use a class reference considered transitively non-replaceable. +For a replaceable component declaration without \lstinline[language=grammar]!constraining-clause! the class must use a class reference considered transitively non-replaceable. \begin{nonnormative} The requirement to use a transitively non-replaceable name excludes the long form of redeclare, i.e.\ \lstinline!redeclare model extends M $\ldots$! where \lstinline!M! must be an inherited replaceable class. \end{nonnormative} \begin{nonnormative} -The rule for a replaceable component declaration without constraining clause implies that constraining classes are always transitively non-replaceable -- both +The rule for a replaceable component declaration without \lstinline[language=grammar]!constraining-clause! implies that constraining classes are always transitively non-replaceable -- both if explicitly given or implicitly by the declaration. \end{nonnormative} @@ -253,11 +242,11 @@ \section{Modifications}\label{modifications} There are three kinds of constructs in the Modelica language in which modifications can occur: \begin{itemize} \item - Variable declarations. + Variable declarations \item - Short class declarations. + Short class declarations \item - Extends-clauses. + \lstinline!extends!-clauses \end{itemize} A modifier modifies one or more declarations from a class by changing some aspect(s) of the declarations. @@ -576,7 +565,7 @@ \section{Redeclaration}\label{redeclaration} A \lstinline!redeclare!\indexinline{redeclare} construct in a modifier replaces the declaration of a local class or component with another declaration. A \lstinline!redeclare! construct as an element replaces the declaration of a local class or component with another declaration. Both \lstinline!redeclare! constructs work in the same way. -The \lstinline!redeclare! construct as an element requires that the element is inherited, and cannot be combined with a modifier of the same element in the extends-clause. +The \lstinline!redeclare! construct as an element requires that the element is inherited, and cannot be combined with a modifier of the same element in the \lstinline!extends!-clause. For modifiers, the redeclare of classes uses the \lstinline[language=grammar]!short-class-definition! construct, which is a special case of normal class definitions and semantically behaves as the corresponding \lstinline[language=grammar]!class-definition!. A modifier with the keyword \lstinline!replaceable!\indexinline{replaceable} is automatically seen as being a \lstinline!redeclare!. @@ -657,7 +646,9 @@ \section{Redeclaration}\label{redeclaration} \subsection{The class extends Redeclaration Mechanism}\label{the-class-extends-redeclaration-mechanism} -A class declaration of the type \lstinline!redeclare class extends B($\ldots$)!, where \lstinline!class! as usual can be replaced by any other specialized class, replaces the inherited class \lstinline!B! with another declaration that extends the inherited class where the optional class-modification is applied to the inherited class. Inherited \lstinline!B! here means that the class containing \lstinline!redeclare class extends B($\ldots$)! should also inherit another declaration of \lstinline!B! from one of its extends-clauses. The new declaration should explicitly include \lstinline!redeclare!. +A class declaration of the type \lstinline!redeclare class extends B($\ldots$)!, where \lstinline!class! as usual can be replaced by any other specialized class, replaces the inherited class \lstinline!B! with another declaration that extends the inherited class where the optional class-modification is applied to the inherited class. +Inherited \lstinline!B! here means that the class containing \lstinline!redeclare class extends B($\ldots$)! should also inherit another declaration of \lstinline!B! from one of its \lstinline!extends!-clauses. +The new declaration should explicitly include \lstinline!redeclare!. \begin{nonnormative} Since the rule about applying the optional class-modification implies that all declarations are inherited with modifications applied, there is no need @@ -792,14 +783,11 @@ \subsection{The class extends Redeclaration Mechanism}\label{the-class-extends-r \subsection{Constraining Type}\label{constraining-type} -In a replaceable declaration the optional \lstinline!constraining-clause! defines a -constraining type. Any modifications following the constraining type -name are applied both for the purpose of defining the actual -constraining type and they are automatically applied in the declaration -and in any subsequent redeclaration. The precedence order is that -declaration modifiers override constraining type modifiers. +In a replaceable declaration the optional \lstinline[language=grammar]!constraining-clause! defines a constraining type. +Any modifications following the constraining type name are applied both for the purpose of defining the actual constraining type and they are automatically applied in the declaration and in any subsequent redeclaration. +The precedence order is that declaration modifiers override constraining type modifiers. -If the \lstinline!constraining-clause! is not present in the original declaration (i.e., the non-redeclared declaration): +If the \lstinline[language=grammar]!constraining-clause! is not present in the original declaration (i.e., the non-redeclared declaration): \begin{itemize} \item The type of the declaration is also used as a constraining type. @@ -807,7 +795,7 @@ \subsection{Constraining Type}\label{constraining-type} The modifiers for subsequent redeclarations and constraining type are the modifiers on the component or \lstinline[language=grammar]!short-class-definition! if that is used in the original declaration, otherwise empty. \end{itemize} -The syntax of a constraining-clause\indexinline{constrainedby} is as follows: +The syntax of a \lstinline[language=grammar]!constraining-clause!\indexinline{constrainedby} is as follows: \begin{lstlisting}[language=grammar] constraining-clause : constrainedby name [ class-modification ] @@ -934,9 +922,7 @@ \subsection{Constraining Type}\label{constraining-type} \subsubsection{Constraining-clause annotations}\label{constraining-clause-annotations} -Description and annotations on the constraining-clause are applied to -the entire declaration, and it is an error if they also appear on the -definition. +Description and annotations on the \lstinline[language=grammar]!constraining-clause! are applied to the entire declaration, and it is an error if they also appear on the definition. \begin{nonnormative} The intent is that the description and/or annotation are at the end of the declaration, but it is not straightforward to specify this in the grammar. diff --git a/chapters/interface.tex b/chapters/interface.tex index f4f37290e..a518e488f 100644 --- a/chapters/interface.tex +++ b/chapters/interface.tex @@ -12,10 +12,10 @@ \chapter{Interface or Type Relationships}\label{interface-or-type-relationships} also be viewed as sub-typing (\cref{the-concepts-of-type-interface-and-subtype}). \section{Interface Terminology}\label{interface-terminology} -In this chapter, two kinds of terminology is used for identical concepts -to get better understanding (e.g.\ by both engineers and computer -scientists). A short summary of the terms is given in the following -table. The details are defined in the rest of this chapter. + +In this chapter, two kinds of terminology is used for identical concepts to get better understanding (e.g.\ by both engineers and computer scientists). +A short summary of the terms is given in the following table. +The details are defined in the rest of this chapter. \begin{definition}[Type \emph{or} interface]\index{type!interface}\index{interface} The ``essential'' part of the public declaration sections of a class diff --git a/chapters/introduction.tex b/chapters/introduction.tex index 1e4c7de60..e1b200500 100644 --- a/chapters/introduction.tex +++ b/chapters/introduction.tex @@ -1,5 +1,7 @@ \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 @@ -61,7 +63,7 @@ \section{Scope of the Specification}\label{scope-of-the-specification} section (number of equations = number of different assigned variables). \item - When-clauses where every 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). + \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. @@ -79,11 +81,11 @@ \section{Some Definitions}\label{some-definitions} Some important terms are defined below. \begin{definition}[Component]\index{component} -An element defined by the production \lstinline!component-clause! in the Modelica grammar (basically a variable or an instance of a class) +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 definitions, extends-clauses and component-clauses declared in a class (basically a class reference or a component in a declaration). +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} diff --git a/chapters/operatorsandexpressions.tex b/chapters/operatorsandexpressions.tex index e8c796c37..32b2c9489 100644 --- a/chapters/operatorsandexpressions.tex +++ b/chapters/operatorsandexpressions.tex @@ -86,11 +86,10 @@ \section{Operator Precedence and Associativity}\label{operator-precedence-and-as \end{center} \end{table} -The conditional operator may also include elseif-clauses. Equality \lstinline!=! and -assignment \lstinline!:=! are not expression operators since they are allowed only -in equations and in assignment statements respectively. All binary -expression operators are left associative, except exponentiation which -is non-associative. The array range operator is non-associative. +The conditional operator may also include \lstinline!elseif!-branches. +Equality \lstinline!=! and assignment \lstinline!:=! are not expression operators since they are allowed only in equations and in assignment statements respectively. +All binary expression operators are left associative, except exponentiation which is non-associative. +The array range operator is non-associative. \begin{nonnormative} The unary minus and plus in Modelica is slightly different than in Mathematica\footnote{\emph{Mathematica} is a registered trademark of Wolfram Research Inc.} and in MATLAB\footnote{\emph{MATLAB} is @@ -112,7 +111,7 @@ \section{Operator Precedence and Associativity}\label{operator-precedence-and-as \section{Evaluation Order}\label{evaluation-order} A tool is free to solve equations, reorder expressions and to not evaluate expressions if their values do not influence the result (e.g.\ short-circuit evaluation of \lstinline!Boolean! expressions). -\lstinline!if!-statements and \lstinline!if!-expressions guarantee that their clauses are only evaluated if the appropriate condition is true, but relational operators generating state or time events will during continuous integration have the value from the most recent event. +\lstinline!if!-statements and \lstinline!if!-expressions guarantee that their branches are only evaluated if the appropriate condition is true, but relational operators generating state or time events will during continuous integration have the value from the most recent event. If a numeric operation overflows the result is undefined. For literals it is recommended to automatically convert the number to another type @@ -297,7 +296,7 @@ \subsection{If-Expressions}\label{if-expressions} 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. +\lstinline!elseif! in expressions has been added to the Modelica language for symmetry with \lstinline!if!-equations. \end{nonnormative} \begin{example} @@ -490,7 +489,7 @@ \subsection{Numeric Functions and Conversion Functions}\label{numeric-functions- \subsection{Event Triggering Mathematical Functions}\label{event-triggering-mathematical-functions} -The operators listed below trigger events if used outside of a when-clause and outside of a clocked discrete-time partition (see \cref{clocked-discrete-time-and-clocked-discretized-continuous-time-partition}). +The operators listed below trigger events if used outside of a \lstinline!when!-clause and outside of a clocked discrete-time partition (see \cref{clocked-discrete-time-and-clocked-discretized-continuous-time-partition}). \begin{center} \begin{tabular}{l|l l} \hline @@ -533,7 +532,7 @@ \subsection{Event Triggering Mathematical Functions}\label{event-triggering-math \begin{semantics} Integer modulus of $x / y$, i.e. \lstinline!mod($x$, $y$) = $x$ - floor($x$ / $y$) * $y$!. Result and arguments shall have type \lstinline!Real! or \lstinline!Integer!. If either of the arguments is \lstinline!Real! the result is \lstinline!Real! otherwise \lstinline!Integer!. \begin{nonnormative} -Note, outside of a when-clause state events are triggered when the return value changes discontinuously. Examples: \lstinline!mod(3, 1.4) = 0.2!, \lstinline!mod(-3, 1.4) = 1.2!, \lstinline!mod(3, -1.4) = -1.2!. +Note, outside of a \lstinline!when!-clause state events are triggered when the return value changes discontinuously. Examples: \lstinline!mod(3, 1.4) = 0.2!, \lstinline!mod(-3, 1.4) = 1.2!, \lstinline!mod(3, -1.4) = -1.2!. \end{nonnormative} \end{semantics} \end{operatordefinition} @@ -545,7 +544,7 @@ \subsection{Event Triggering Mathematical Functions}\label{event-triggering-math \begin{semantics} Integer remainder of $x / y$, such that \lstinline!div($x$, $y$) * $y$ + rem($x$, $y$) = $x$!. Result and arguments shall have type \lstinline!Real! or \lstinline!Integer!. If either of the arguments is \lstinline!Real! the result is \lstinline!Real! otherwise \lstinline!Integer!. \begin{nonnormative} -Note, outside of a when-clause state events are triggered when the return value changes discontinuously. Examples: \lstinline!rem(3, 1.4) = 0.2!, \lstinline!rem(-3, 1.4) = -0.2!. +Note, outside of a \lstinline!when!-clause state events are triggered when the return value changes discontinuously. Examples: \lstinline!rem(3, 1.4) = 0.2!, \lstinline!rem(-3, 1.4) = -0.2!. \end{nonnormative} \end{semantics} \end{operatordefinition} @@ -557,7 +556,7 @@ \subsection{Event Triggering Mathematical Functions}\label{event-triggering-math \begin{semantics} Smallest integer not less than $x$. Result and argument shall have type \lstinline!Real!. \begin{nonnormative} -Note, outside of a when-clause state events are triggered when the return value changes discontinuously. +Note, outside of a \lstinline!when!-clause state events are triggered when the return value changes discontinuously. \end{nonnormative} \end{semantics} \end{operatordefinition} @@ -569,7 +568,7 @@ \subsection{Event Triggering Mathematical Functions}\label{event-triggering-math \begin{semantics} Largest integer not greater than $x$. Result and argument shall have type \lstinline!Real!. \begin{nonnormative} -Note, outside of a when-clause state events are triggered when the return value changes discontinuously. +Note, outside of a \lstinline!when!-clause state events are triggered when the return value changes discontinuously. \end{nonnormative} \end{semantics} \end{operatordefinition} @@ -581,7 +580,7 @@ \subsection{Event Triggering Mathematical Functions}\label{event-triggering-math \begin{semantics} Largest integer not greater than $x$. The argument shall have type \lstinline!Real!. The result has type \lstinline!Integer!. \begin{nonnormative} -Note, outside of a when-clause state events are triggered when the return value changes discontinuously. +Note, outside of a \lstinline!when!-clause state events are triggered when the return value changes discontinuously. \end{nonnormative} \end{semantics} \end{operatordefinition} @@ -1293,14 +1292,14 @@ \subsection{Event-Related Operators with Function Syntax}\label{event-related-op Any subscripts in the component expression $y$ must be parameter expressions. \lstinline!pre! can be applied if the following three conditions are fulfilled simultaneously: (a) variable $y$ is either a subtype of a simple type or is a record component, (b) $y$ is a discrete-time expression (c) the operator is \emph{not} applied in a \lstinline!function! class. \begin{nonnormative} -This can be applied to continuous-time variables in when-clauses, see \cref{discrete-time-expressions} for the definition of discrete-time expression. +This can be applied to continuous-time variables in \lstinline!when!-clauses, see \cref{discrete-time-expressions} for the definition of discrete-time expression. \end{nonnormative} The first value of \lstinline!pre($y$)! is determined in the initialization phase. A new event is triggered if there is at least for one variable \lstinline!v! such that \lstinline!pre(v) <> v! after the active model equations are evaluated at an event instant. In this case the model is at once reevaluated. This evaluation sequence is called \emph{event iteration}. The integration is restarted once \lstinline!pre(v) == v! for all \lstinline!v! appearing inside \lstinline!pre($\ldots$)!. \begin{nonnormative} -If \lstinline!v! and \lstinline!pre(v)! are only used in when-clauses, the translator might mask event iteration for variable \lstinline!v! since \lstinline!v! cannot change during event iteration. +If \lstinline!v! and \lstinline!pre(v)! are only used in \lstinline!when!-clauses, the translator might mask event iteration for variable \lstinline!v! since \lstinline!v! cannot change during event iteration. It is a quality of implementation to find the minimal loops for event iteration, i.e., not all parts of the model need to be reevaluated. The language allows mixed algebraic systems of equations where the unknown variables are of type \lstinline!Real!, \lstinline!Integer!, \lstinline!Boolean!, or an enumeration. @@ -1333,11 +1332,15 @@ \subsection{Event-Related Operators with Function Syntax}\label{event-related-op reinit($x$, $\mathit{expr}$) \end{lstlisting}\end{synopsis} \begin{semantics} -In the body of a when clause, reinitializes $x$ with $\mathit{expr}$ at an event instant. $x$ is a scalar or array \lstinline!Real! variable that is implicitly defined to have \lstinline!StateSelect.always!. +In the body of a \lstinline!when!-clause, reinitializes $x$ with $\mathit{expr}$ at an event instant. +$x$ is a scalar or array \lstinline!Real! variable that is implicitly defined to have \lstinline!StateSelect.always!. \begin{nonnormative} It is an error if the variable cannot be selected as a state. \end{nonnormative} -$\mathit{expr}$ needs to be type-compatible with $x$. \lstinline!reinit! can only be applied once for the same variable -- either as an individual variable or as part of an array of variables. It can only be applied in the body of a when clause in an equation section. See also \cref{reinit}. +$\mathit{expr}$ needs to be type-compatible with $x$. +\lstinline!reinit! can only be applied once for the same variable -- either as an individual variable or as part of an array of variables. +It can only be applied in the body of a \lstinline!when!-clause in an equation section. +See also \cref{reinit}. \end{semantics} \end{operatordefinition} diff --git a/chapters/packages.tex b/chapters/packages.tex index 06011def8..a71836510 100644 --- a/chapters/packages.tex +++ b/chapters/packages.tex @@ -32,6 +32,7 @@ \chapter{Packages}\label{packages} standard mapping of package names to storage places, typically file or directory locations in the file system. \end{itemize} + \section{Package as Specialized Class}\label{package-as-specialized-class} The package concept is a specialized class (\cref{specialized-classes}), using the @@ -39,17 +40,14 @@ \section{Package as Specialized Class}\label{package-as-specialized-class} \section{Importing Definitions from a Package}\label{importing-definitions-from-a-package} -The import-clause makes public classes and other public definitions -declared in some package available for use by shorter names in a class -or a package. It is the only way of referring to definitions declared in -some other package for use inside an encapsulated package or class. +The \lstinline!import!-clause makes public classes and other public definitions declared in some package available for use by shorter names in a class or a package. +It is the only way of referring to definitions declared in some other package for use inside an encapsulated package or class. \begin{nonnormative} -Import-clauses in a package or class fill the following two needs: +\lstinline!import!-clauses in a package or class fill the following two needs: \begin{itemize} \item - Making definitions from other packages available for use (by shorter - names) in a package or class. + Making definitions from other packages available for use (by shorter names) in a package or class. \item Explicit declaration of usage dependences on other packages. \end{itemize} @@ -81,11 +79,15 @@ \section{Importing Definitions from a Package}\label{importing-definitions-from- \subsection{Lookup of Imported Names}\label{lookup-of-imported-names} -This section only defines how the imported name is looked up in the import-clause. For lookup in general -- including how import-clauses are used -- see \cref{static-name-lookup}. +This section only defines how the imported name is looked up in the \lstinline!import!-clause. +For lookup in general -- including how \lstinline!import!-clauses are used -- see \cref{static-name-lookup}. -Lookup of the name of an imported package or class deviates from the normal lexical lookup. For example, consider \lstinline!A.B.C! in the clauses \lstinline!import A.B.C;!, \lstinline!import D = A.B.C;!, or \lstinline!import A.B.C.*;!. Here, lookup starts with the lexical lookup of the first part of the name (\lstinline!A!) at the top-level. +Lookup of the name of an imported package or class deviates from the normal lexical lookup. +For example, consider \lstinline!A.B.C! in the \lstinline!import!-clauses \lstinline!import A.B.C;!, \lstinline!import D = A.B.C;!, or \lstinline!import A.B.C.*;!. +Here, lookup starts with the lexical lookup of the first part of the name (\lstinline!A!) at the top-level. -Qualified import-clauses may only refer to packages or elements of packages, i.e., in \lstinline!import A.B.C;! or \lstinline!import D = A.B.C;!, \lstinline!A.B! must be a package. Unqualified import-clauses may only import from packages, i.e., in \lstinline!import A.B.*;!, \lstinline!A.B! must be a package. +Qualified \lstinline!import!-clauses may only refer to packages or elements of packages, i.e., in \lstinline!import A.B.C;! or \lstinline!import D = A.B.C;!, \lstinline!A.B! must be a package. +Unqualified \lstinline!import!-clauses may only import from packages, i.e., in \lstinline!import A.B.*;!, \lstinline!A.B! must be a package. \begin{nonnormative} In \lstinline!import A;! the class \lstinline!A! can be any class which is an element of the unnamed top-level package. @@ -111,23 +113,21 @@ \subsection{Summary of Rules for Import-Clauses}\label{summary-of-rules-for-impo The following rules apply to \lstinline!import!-clauses: \begin{itemize} \item - Import-clauses are \emph{not} inherited. + \lstinline!import!-clauses are \emph{not} inherited. \item - Import-clauses are not named elements of a class or package. This - means that import-clauses cannot be changed by modifiers or - redeclarations. + \lstinline!import!-clauses are not named elements of a class or package. + This means that \lstinline!import!-clauses cannot be changed by modifiers or redeclarations. \item - The \emph{order} of import-clauses does not matter. + The \emph{order} of \lstinline!import!-clauses does not matter. \item - One can only import \emph{from} packages, not from other kinds of - classes. Both packages and classes can be imported \emph{into} i.e., - they may contain import-clauses. + One can only import \emph{from} packages, not from other kinds of classes. + Both packages and classes can be imported \emph{into} i.e., they may contain \lstinline!import!-clauses. \item - An imported package or definition should always be referred to by its - fully qualified name in the import-clause. + An imported package or definition should always be referred to by its fully qualified name in the \lstinline!import!-clause. \item - Multiple qualified import-clauses shall not have the same import name. + Multiple qualified \lstinline!import!-clauses shall not have the same import name. \end{itemize} + \section{The Modelica Library Path -- MODELICAPATH}\label{the-modelica-library-path-modelicapath} The top-level scope implicitly contains a number of classes stored externally. @@ -258,14 +258,14 @@ \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 \lstinline!within!-clause has the following syntax: \begin{lstlisting}[language=grammar] within [ packageprefixname ] ";" \end{lstlisting}% \indexinline{within} -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 \lstinline!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 \lstinline!within!-clause with no name. +For a sub-entity of an enclosing structured entity, the \lstinline!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/revisions.tex b/chapters/revisions.tex index bd51ea436..115665ab8 100644 --- a/chapters/revisions.tex +++ b/chapters/revisions.tex @@ -6,6 +6,7 @@ \chapter{Modelica Revision History}\label{modelica-revision-history} \url{https://www.modelica.org/documents}. \section{Modelica 3.5}\label{modelica-3-5} + Modelica 3.5 was last edited December 31, 2020, and will later be voted to be approved. The Modelica 3.5 specification was edited by Hans Olsson. @@ -403,6 +404,7 @@ \subsection{Main changes in Modelica 3.5}\label{main-changes-in-modelica-3-5} \end{itemize} \section{Modelica 3.4}\label{modelica-3-4} + Modelica 3.4 was released April 10, 2017. The Modelica 3.4 specification was edited by Hans Olsson. @@ -515,7 +517,7 @@ \subsection{Main changes in Modelica 3.4}\label{main-changes-in-modelica-3-4} Clarify restrictions on record components, \cref{specialized-classes}. Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/1615}{\#1615}. \item - Clarify that only functions may have external-clause, \cref{specialized-classes} and \cref{function-as-a-specialized-class}. + Clarify that only functions may have \lstinline!external!-clause, \cref{specialized-classes} and \cref{function-as-a-specialized-class}. Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/2014}{\#2014}. \item Clarified equation count for operator record, \cref{balanced-models}. Ticket @@ -564,7 +566,7 @@ \subsection{Main changes in Modelica 3.4}\label{main-changes-in-modelica-3-4} Clarified that 2/3 and 2\^{}(-3) are \lstinline!Real!, \cref{type-compatible-expressions}. Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/1647}{\#1647}. \item - Clarified that the external-clause is inherited, \cref{inheritance-extends-clause}. + Clarified that the \lstinline!external!-clause is inherited, \cref{inheritance-extends-clause}. Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/789}{\#789}. \item Further clarified order for multiple inheritance, \cref{instantiation} and @@ -593,7 +595,7 @@ \subsection{Main changes in Modelica 3.4}\label{main-changes-in-modelica-3-4} Corrected example, \cref{constraining-type}. Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/1725}{\#1725}. \item - Clarified description and annotation on constraining-clause, \cref{constraining-clause-annotations}. Ticket + Clarified description and annotation on \lstinline[language=grammar]!constraining-clause!, \cref{constraining-clause-annotations}. Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/512}{\#512}. \item Corrected typo, \cref{annotation-choices-for-suggested-redeclarations-and-modifications}. Ticket @@ -605,7 +607,7 @@ \subsection{Main changes in Modelica 3.4}\label{main-changes-in-modelica-3-4} Clarified event generation, \cref{events-and-synchronization}. Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/2114}{\#2114}. \item - Further clarified \lstinline!initial()! for when-clauses, \cref{initialization-initial-equation-and-initial-algorithm}, and indicated that this appendix is not normative. + Further clarified \lstinline!initial()! for \lstinline!when!-clauses, \cref{initialization-initial-equation-and-initial-algorithm}, and indicated that this appendix is not normative. Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/1852}{\#1852}. \item Clarified using \lstinline!start!-attribute for parameters, \cref{initialization-initial-equation-and-initial-algorithm}. Ticket @@ -856,6 +858,7 @@ \section{Modelica 3.3 Revision 1}\label{modelica-3-3-revision-1} Revision 1 specification was edited by Hans Olsson. \subsection{Main changes in Modelica 3.3 Revision 1}\label{main-changes-in-modelica-3-3-revision-1} + The changes made in Modelica 3.2 Revision 2 are included, and in addition the following improvements were made: \begin{itemize} @@ -1165,7 +1168,7 @@ \subsection{Contributors to Modelica 3.3}\label{contributors-to-modelica-3-3} The \lstinline!spatialDistribution! operator was initiated by Hubertus Tummescheit, based on an operator of Dymola, and with contributions from Hans Olsson. -The improved definition of pure and impure functions and the enhanced import-clause was proposed by Peter Fritzson. +The improved definition of pure and impure functions and the enhanced \lstinline!import!-clause was proposed by Peter Fritzson. The various smaller language improvements based on submitted tickets have been developed by a group headed by Hans Olsson and with group @@ -1307,8 +1310,8 @@ \subsection{Main changes in Modelica 3.2 Revision 2}\label{main-changes-in-model \cref{modifications}. Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/1042}{\#1042}. \item - Precedence for modifiers on constraining-clause clarified, \cref{constraining-type}. Ticket - \href{https://github.com/modelica/ModelicaSpecification/issues/1128}{\#1128}. + Precedence for modifiers on \lstinline[language=grammar]!constraining-clause! clarified, \cref{constraining-type}. + Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/1128}{\#1128}. \item Clarified arrays for constraining type, \cref{constraining-type}. Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/1148}{\#1148}. @@ -1454,11 +1457,8 @@ \subsection{Main changes in Modelica 3.2 Revision 1}\label{main-changes-in-model Clarified inner/outer declarations. \item \cref{inheritance-extends-clause} Inheritance\\ - Clarified that the elements of a flattened base class are added at the - place of the extends clause.\\ - Equations of the flattened base class that are syntactically - equivalent to equations in the flattened enclosing class are - deprecated. + Clarified that the elements of a flattened base class are added at the place of the \lstinline!extends!-clause.\\ + Equations of the flattened base class that are syntactically equivalent to equations in the flattened enclosing class are deprecated. \item \cref{modifications} Modifications\\ Element modifiers are no longer part of language, reference grammar @@ -1472,7 +1472,7 @@ \subsection{Main changes in Modelica 3.2 Revision 1}\label{main-changes-in-model Improved \lstinline!reinit! definition. \item \cref{initialization-initial-equation-and-initial-algorithm} Initialization\\ - Clarified that only when-clauses with restricted form of initial() as + Clarified that only \lstinline!when!-clauses with restricted form of initial() as condition will be active during initialization. \item \cref{reduction-expressions} Reduction Expressions\\ @@ -1831,7 +1831,7 @@ \subsection{Main changes in Modelica 3.1}\label{main-changes-in-modelica-3-1} \item Example with \lstinline!MatrixGain! was corrected. \item - Ambiguous annotations after external-clause were corrected (as already used). + Ambiguous annotations after \lstinline!external!-clause were corrected (as already used). \item The \lstinline!reinit! operator can be used multiple times in one algorithm, and the semantics clarified. \item @@ -2151,11 +2151,7 @@ \subsection{Main Changes in Modelica 3.0}\label{main-changes-in-modelica-3-0} generate events but are implicitly defined with a \lstinline!noEvent! operator. \item - The constraining clause of a replaceable class or component is changed - from keyword \lstinline!extends! to the new keyword \lstinline!constrainedby! (since the - \lstinline!extends! keyword could lead to the wrong impression that the redeclared - model must inherit from the constraining class, but this is not the - case). + The \lstinline[language=grammar]!constraining-clause! of a replaceable class or component is changed from keyword \lstinline!extends! to the new keyword \lstinline!constrainedby! (since the \lstinline!extends! keyword could lead to the wrong impression that the redeclared model must inherit from the constraining class, but this is not the case). \item The \lstinline!isPresent! construct, which was not implemented in tools, was removed. \end{itemize} @@ -2235,6 +2231,7 @@ \section{Modelica 2.2}\label{modelica-2-2} Otter. \subsection{Contributors to the Modelica Language, Version 2.2}\label{contributors-to-the-modelica-language-version-2-2} + \indent\indent Bernhard Bachmann , University of Applied Sciences, Bielefeld, Germany @@ -2337,6 +2334,7 @@ \section{Modelica 2.1}\label{modelica-2-1} specification was edited by Hans Olsson and Martin Otter. \subsection{Contributors to the Modelica Language, Version 2.1}\label{contributors-to-the-modelica-language-version-2-1} + \indent\indent Mikael Adlers, MathCore, Linköping, Sweden @@ -2453,6 +2451,7 @@ \section{Modelica 2.0}\label{modelica-2-0} Association since November 2001. \subsection{Contributors to the Modelica Language, Version 2.0}\label{contributors-to-the-modelica-language-version-2-0} + \indent\indent Peter Aronsson, Linköping University, Sweden @@ -2554,8 +2553,7 @@ \subsection{Main Changes in Modelica 2.0}\label{main-changes-in-modelica-2-0} interface user-defined tables, property databases, sparse matrix handling, hardware interfaces). \item - Added an index, and specification of some basic constructs that had - previously not formally be defined, such as while-clauses, if-clauses. + Added an index, and specification of some basic constructs that had previously not formally be defined, such as \lstinline!while!-clauses, \lstinline!if!-clauses. \end{itemize} The language changes are backward compatible, except for the introduction of the new keyword enumeration and the removal of the operator \lstinline!analysisType!. The library change of the block library which will become available soon requires changes in user-models. @@ -2568,6 +2566,7 @@ \section{Modelica 1.4}\label{modelica-1-4} Olsson and Dag Brück. \subsection{Contributors to the Modelica Language, Version 1.4}\label{contributors-to-the-modelica-language-version-1-4} + \indent\indent Bernhard Bachmann, Fachhochschule Bielefeld, Germany @@ -2613,6 +2612,7 @@ \subsection{Contributors to the Modelica Language, Version 1.4}\label{contributo Hans-Jürg Wiesmann, ABB Corporate Research Ltd., Baden, Switzerland \subsection{Contributors to the Modelica Standard Library}\label{contributors-to-the-modelica-standard-library} + % https://tex.stackexchange.com/questions/31555/how-can-i-indent-the-paragraphs-which-follow-a-heading \indent\indent Peter Beater, University of Paderborn, Germany @@ -2639,15 +2639,14 @@ \subsection{Main Changes in Modelica 1.4}\label{main-changes-in-modelica-1-4} Encapsulated classes can be seen as ``self-contained units'': When copying or moving an encapsulated class, at most the \lstinline!import!-clauses in this class have to be changed. \item - Refined when-clause: - The \lstinline[morekeywords={[2]{nondiscrete}}]!nondiscrete!\index{nondiscrete@\robustinline{nondiscrete} (removed keyword)} keyword is removed, equations in when-clauses must have a unique variable name on left hand side variable and the exact mapping of when-clauses to equations is defined. - As a result, when-clauses are now precisely defined without referring to a sorting algorithm and it is possible to handle algebraic loops between when-clauses with different conditions and between when-clauses and the continuous-time part of a model. + Refined \lstinline!when!-clause: + The \lstinline[morekeywords={[2]{nondiscrete}}]!nondiscrete!\index{nondiscrete@\robustinline{nondiscrete} (removed keyword)} keyword is removed, equations in \lstinline!when!-clauses must have a unique variable name on left hand side variable and the exact mapping of \lstinline!when!-clauses to equations is defined. + As a result, \lstinline!when!-clauses are now precisely defined without referring to a sorting algorithm and it is possible to handle algebraic loops between \lstinline!when!-clauses with different conditions and between \lstinline!when!-clauses and the continuous-time part of a model. The \lstinline!discrete! keyword is now optional, simplifying the library development because only one type of connector is needed and not several types which do contain or do not contain the discrete prefix on variables. - Additionally, when-clauses in algorithm sections may have elsewhen-clauses which simplifies the definition of priorities between when-clauses. + Additionally, \lstinline!when!-clauses in algorithm sections may have \lstinline!elsewhen!-clauses which simplifies the definition of priorities between \lstinline!when!-clauses. \item - For replaceable declarations: allowed constraining clauses, and - annotations listing suitable redeclarations. This allows a graphical - user environment to automatically build menus with meaningful choices. + For replaceable declarations: allowed \lstinline[language=grammar]!constraining-clause!, and annotations listing suitable redeclarations. + This allows a graphical user environment to automatically build menus with meaningful choices. \item Functions can specify their derivative. This allows, e.g., the application of the Pantelides algorithm to reduce the index of a DAE @@ -2655,7 +2654,7 @@ \subsection{Main Changes in Modelica 1.4}\label{main-changes-in-modelica-1-4} \item New built-in operator \lstinline!rem! (remainder) and the built-in operators div, mod, ceil, floor, integer, previously only allowed to be used in - when-clauses can now be used everywhere, because state events are + \lstinline!when!-clauses can now be used everywhere, because state events are automatically generated when the result value of one of these operator changes discontinuously. \item @@ -2681,15 +2680,15 @@ \subsection{Main Changes in Modelica 1.4}\label{main-changes-in-modelica-1-4} Internally restructured specification. \end{itemize} -Modelica 1.4 is backwards compatible with Modelica 1.3, with the exception of (1) some exotic cases where different results are achieved with the removed ``declare-before-use-rule'' and the previous declaration order, (2) when-clauses in equations sections, which use the general form \lstinline!expr1 = expr2! (now only \lstinline!v = expr! is allowed + some special cases for functions), (3) some exotic cases where a when-clause may be no longer evaluated at the initial time, because the initialization of the when-condition is now defined in a more meaningful way (before Modelica 1.4, every condition in a when-clause has a ``previous'' value of false), and (4) models containing the \lstinline[morekeywords={[2]{nondiscrete}}]!nondiscrete! keyword which was removed. +Modelica 1.4 is backwards compatible with Modelica 1.3, with the exception of (1) some exotic cases where different results are achieved with the removed ``declare-before-use-rule'' and the previous declaration order, (2) \lstinline!when!-clauses in equations sections, which use the general form \lstinline!expr1 = expr2! (now only \lstinline!v = expr! is allowed + some special cases for functions), (3) some exotic cases where a \lstinline!when!-clause may be no longer evaluated at the initial time, because the initialization of the when-condition is now defined in a more meaningful way (before Modelica 1.4, every condition in a \lstinline!when!-clause has a ``previous'' value of false), and (4) models containing the \lstinline[morekeywords={[2]{nondiscrete}}]!nondiscrete! keyword which was removed. \section{Modelica 1.3 and Older Versions.}\label{modelica-1-3-and-older-versions} Modelica 1.3 was released December 15, 1999. \subsection{Contributors up to Modelica 1.3}\label{contributors-up-to-modelica-1-3} -The following list contributors and their affiliations at the time when -Modelica 1.3 was released. + +The following list contributors and their affiliations at the time when Modelica 1.3 was released. Hilding Elmqvist, Dynasim AB, Lund, Sweden @@ -2770,7 +2769,7 @@ \subsection{Main Changes in Modelica 1.2}\label{main-changes-in-modelica-1-2} \item Restricted redeclaration to replaceable elements. \item - Defined semantics for if-clauses. + Defined semantics for \lstinline!if!-clauses. \item Defined allowed code optimizations. \item @@ -2782,6 +2781,7 @@ \subsection{Main Changes in Modelica 1.2}\label{main-changes-in-modelica-1-2} \end{itemize} \subsection{Main Changes in Modelica 1.1}\label{main-changes-in-modelica-1-1} + Modelica 1.1 was released in December 1998. Major changes: diff --git a/chapters/scoping.tex b/chapters/scoping.tex index 44f7cbb00..786845a38 100644 --- a/chapters/scoping.tex +++ b/chapters/scoping.tex @@ -114,12 +114,8 @@ \subsection{Composite Name Lookup}\label{composite-name-lookup} \end{itemize} \begin{nonnormative} -The temporary class flattening performed for composite names -follow the same rules as class flattening of the base class in an -extends-clause, local classes and the type in a component clause, except -that the environment is empty. See also \lstinline!MoistAir2! example in -\cref{redeclaration} for further explanations regarding looking inside -partial packages. +The temporary class flattening performed for composite names follow the same rules as class flattening of the base class in an extends-clause, local classes and the type in a \lstinline[language=grammar]!component-clause!, except that the environment is empty. +See also \lstinline!MoistAir2! example in \cref{redeclaration} for further explanations regarding looking inside partial packages. \end{nonnormative} \begin{example} Components and classes are part of the same name-space and thus a component cannot @@ -421,7 +417,7 @@ \subsubsection{The Instance Tree}\label{the-instance-tree} The output of the instantiation process is an \firstuse{instance tree}\index{instance tree}. The instance tree consists of nodes representing the elements of a class definition from the class tree. -For a component the subtree of a particular node is created using the information from the class of the component clause and a new modification environment as result of merging the current modification environment with the modifications from the current element declaration (see \cref{merging-of-modifications}). +For a component the subtree of a particular node is created using the information from the class of the \lstinline[language=grammar]!component-clause! and a new modification environment as result of merging the current modification environment with the modifications from the current element declaration (see \cref{merging-of-modifications}). The instance tree has the following properties: \begin{itemize} @@ -458,7 +454,9 @@ \subsubsection{The Instance Tree}\label{the-instance-tree} instance scope is the starting point for name lookup. \begin{nonnormative} -If the name is not found the lookup is continued in the instance scope corresponding to the lexically enclosing class. Extends clauses are treated as unnamed nodes in the instance tree -- when searching for an element in an instance scope the search also recursively examines the elements of the extends clauses. Except that inherited import-clauses are ignored. +If the name is not found the lookup is continued in the instance scope corresponding to the lexically enclosing class. +\lstinline!extends!-clauses are treated as unnamed nodes in the instance tree -- when searching for an element in an instance scope the search also recursively examines the elements of the \lstinline!extends!-clauses. +Except that inherited \lstinline!import!-clauses are ignored. \end{nonnormative} \subsubsection{The Instantiation Procedure.}\label{the-instantiation-procedure} @@ -516,11 +514,11 @@ \subsubsection{Steps of Instantiation}\label{steps-of-instantiation} (\cref{annotations-for-simulation-experiments}) or functions (\cref{declaring-derivatives-of-functions}, \cref{declaring-inverses-of-functions} and \cref{external-function-interface}). \end{nonnormative} -Extends clauses are not looked up, but empty extends clause nodes are created and inserted into the current instance (to be able to preserve the declaration order of components). +\lstinline!extends!-clauses are not looked up, but empty \lstinline!extends!-clause nodes are created and inserted into the current instance (to be able to preserve the declaration order of components). \paragraph*{The inherited contents of the element}\label{the-inherited-contents-of-the-element} -Classes of extends clauses of the current class are looked up in the instance tree, modifiers (including redeclarations) are merged, the contents of these classes are partially instantiated using the new modification environment, and are inserted into an extends clause node, which is an unnamed node in the current instance that only contains the inherited contents from that base class. +Classes of \lstinline!extends!-clauses of the current class are looked up in the instance tree, modifiers (including redeclarations) are merged, the contents of these classes are partially instantiated using the new modification environment, and are inserted into an \lstinline!extends!-clause node, which is an unnamed node in the current instance that only contains the inherited contents from that base class. The classes of extends-clauses are looked up before and after handling extends-clauses; and it is an error if those lookups generate different @@ -637,9 +635,8 @@ \subsection{Generation of the flat equation system}\label{generation-of-the-flat instance. \begin{nonnormative} -This identifier is normally constructed from the names of the instances along a path in the instance tree (and omitting the unnamed nodes of extends clauses), separated -by dots. Either the referenced instance belongs to the model to be simulated the path starts at the model itself, or if not, it starts at the unnamed root of the instance -tree, e.g.\ in case of a constant in a package. +This identifier is normally constructed from the names of the instances along a path in the instance tree (and omitting the unnamed nodes of \lstinline!extends!-clauses), separated by dots. +Either the referenced instance belongs to the model to be simulated the path starts at the model itself, or if not, it starts at the unnamed root of the instance tree, e.g.\ in case of a constant in a package. \end{nonnormative} \begin{nonnormative} diff --git a/chapters/statemachines.tex b/chapters/statemachines.tex index 227b45bc5..60e72f3cd 100644 --- a/chapters/statemachines.tex +++ b/chapters/statemachines.tex @@ -400,6 +400,7 @@ \subsection{Semantics Summary}\label{semantics-summary} Boolean stateMachineInFinalState = finalStates[activeState]; end StateMachineSemantics; \end{lstlisting} + \subsection{Merging Variable Definitions}\label{merging-variable-definitions} \begin{nonnormative} diff --git a/chapters/statements.tex b/chapters/statements.tex index c6b446029..85fff2024 100644 --- a/chapters/statements.tex +++ b/chapters/statements.tex @@ -407,6 +407,7 @@ \subsection{When-Statements}\label{when-statements} \end{example} \subsubsection{Restrictions on Where a When-statement may occur}\label{restrictions-on-where-a-when-statement-may-occur} + \begin{itemize} \item A \lstinline!when!-statement shall not be used within a function. @@ -469,7 +470,7 @@ \subsubsection{Defining When-Statements by If-Statements}\label{defining-when-st end if; \end{lstlisting} with \lstinline!edge(A) = A and not pre(A)! and the additional guarantee, that the statements within this special \lstinline!if!-statement are only evaluated at event instants. -The difference compared to the when-statements is that e.g.\ \lstinline!pre! may only be used on continuous-time real variables inside the body of a when-clause and not inside these if-statements. +The difference compared to the when-statements is that e.g.\ \lstinline!pre! may only be used on continuous-time real variables inside the body of a \lstinline!when!-clause and not inside these if-statements. \subsection{Special Statements}\label{special-statements} diff --git a/chapters/synchronous.tex b/chapters/synchronous.tex index 96b5aac12..9a5cf0cfd 100644 --- a/chapters/synchronous.tex +++ b/chapters/synchronous.tex @@ -3,7 +3,7 @@ \chapter{Synchronous Language Elements}\label{synchronous-language-elements} This chapter defines synchronous behavior suited for implementation of control systems. The synchronous behavior relies on an additional kind of discrete-time -variables and equations, as well as an additional kind of when-clause. +variables and equations, as well as an additional kind of \lstinline!when!-clause. The benefits of synchronous behavior is that it allows a model to define large sampled data systems in a safe way, so that the translator can provide good diagnostics in case of a modeling error. @@ -37,7 +37,7 @@ \chapter{Synchronous Language Elements}\label{synchronous-language-elements} When no argument is defined for \lstinline!Clock!, the clock is deduced by clock inference. \item - For a \lstinline!when!-clause with an associated clock, all equations inside the \lstinline!when!-clause are clocked with the given clock. All equations on an associated clock are treated together and in the same way regardless of whether they are inside a \lstinline!when!-clause or not. This means that automatic sampling and hold of variables inside the \lstinline!when!-clause does not apply (explicit sampling and hold is required) and that general equations can be used in such when-clauses (this is not allowed for \lstinline!when!-clauses with \lstinline!Boolean! conditions, that require a variable reference on the left-hand side of an equation). + For a \lstinline!when!-clause with an associated clock, all equations inside the \lstinline!when!-clause are clocked with the given clock. All equations on an associated clock are treated together and in the same way regardless of whether they are inside a \lstinline!when!-clause or not. This means that automatic sampling and hold of variables inside the \lstinline!when!-clause does not apply (explicit sampling and hold is required) and that general equations can be used in such \lstinline!when!-clauses (this is not allowed for \lstinline!when!-clauses with \lstinline!Boolean! conditions, that require a variable reference on the left-hand side of an equation). \item The \lstinline!when!-clause in the controller could also be removed and the controller could just be defined by the equations: @@ -60,10 +60,11 @@ \chapter{Synchronous Language Elements}\label{synchronous-language-elements} However, the Modelica approach also uses multi-rate periodic clocks based on rational arithmetic introduced by \textcite{ForgetEtAl2008MultiPeriodic}, as an extension of the Lucid Synchrone semantics. These approaches belong to the class of synchronous languages \parencite{BenvenisteEtAl2003SynchronousTwelveYearsLater}. \end{itemize} + \section{Rationale for Clocked Semantics}\label{rationale-for-clocked-semantics} \begin{nonnormative} -Periodically sampled control systems could also be defined with standard when-clauses, see \cref{when-equations}, and the \lstinline!sample! operator, see \cref{event-related-operators-with-function-syntax}. For example: +Periodically sampled control systems could also be defined with standard \lstinline!when!-clauses, see \cref{when-equations}, and the \lstinline!sample! operator, see \cref{event-related-operators-with-function-syntax}. For example: \begin{lstlisting}[language=modelica] when sample(0, 3) then xd = A * pre(xd) + B * y; @@ -71,15 +72,15 @@ \section{Rationale for Clocked Semantics}\label{rationale-for-clocked-semantics} end when; \end{lstlisting} -Equations in a when-clause with a \lstinline!Boolean! condition have the +Equations in a \lstinline!when!-clause with a \lstinline!Boolean! condition have the property that (a) variables on the left hand side of the equal sign are assigned a value when the when-condition becomes true and otherwise hold -their value, (b) variables not assigned in the when-clause are directly +their value, (b) variables not assigned in the \lstinline!when!-clause are directly accessed (= automatic \lstinline!sample! semantics), and (c) the variables -assigned in the when-clause can be directly accessed outside of the -when-clause (= automatic \lstinline!hold! semantics). +assigned in the \lstinline!when!-clause can be directly accessed outside of the +\lstinline!when!-clause (= automatic \lstinline!hold! semantics). -Using standard when-clauses works well for individual simple sampled blocks, but the synchronous approach using clocks and clocked equations provide the following benefits (especially for large sampled systems): +Using standard \lstinline!when!-clauses works well for individual simple sampled blocks, but the synchronous approach using clocks and clocked equations provide the following benefits (especially for large sampled systems): \begin{enumerate} \item Possibility to detect inconsistent sampling rate, since clock partitioning (see \cref{clock-partitioning}), @@ -87,7 +88,7 @@ \section{Rationale for Clocked Semantics}\label{rationale-for-clocked-semantics} \begin{enumerate} \def\labelenumii{\alph{enumii}.} \item - If when-clauses in different blocks should belong to the same + If \lstinline!when!-clauses in different blocks should belong to the same controller part, but by accident different when-conditions are given, then this is accepted (no error is detected). \item @@ -103,23 +104,23 @@ \section{Rationale for Clocked Semantics}\label{rationale-for-clocked-semantics} \item Fewer initial conditions are needed, as only a subset of clocked variables need initial conditions -- the clocked state variables (see \cref{clocked-state-variables}). - For a standard when-clause all variables - assigned in a when-clause must have an initial value + For a standard \lstinline!when!-clause all variables + assigned in a \lstinline!when!-clause must have an initial value because they might be used, before they are assigned a value the first time. As a result, all these variables are ``discrete-time states'' although in reality only a subset of them need an initial value. \item - More general equations can be used, compared to standard when-clauses that require + More general equations can be used, compared to standard \lstinline!when!-clauses that require a restricted form of equations where the left hand side has to be a variable, in order - to identify the variables that are assigned in the when-clause. - This restriction can be circumvented for standard when-clauses, but is + to identify the variables that are assigned in the \lstinline!when!-clause. + This restriction can be circumvented for standard \lstinline!when!-clauses, but is absent for clocked equations and make it more convenient to define nonlinear control algorithms. \item Clocked equations allow clock inference, meaning that the sampling need only be given once for a sub-system. - For a standard when-clause the condition (sampling) must be explicitly + For a standard \lstinline!when!-clause the condition (sampling) must be explicitly propagated to all blocks, which is tedious and error prone for large systems. \item Possible to use general continuous-time models in synchronous models (e.g.\ some advanced controllers use an inverse model of a plant in the feedforward path of the controller, see \textcite{ThummelEtAl2005InverseModels}). @@ -128,10 +129,10 @@ \section{Rationale for Clocked Semantics}\label{rationale-for-clocked-semantics} \item Clocked equations are straightforward to optimize because they are evaluated exactly once at each an event instant. - In contrast a standard when-clause with \lstinline!sample! conceptually + In contrast a standard \lstinline!when!-clause with \lstinline!sample! conceptually requires several evaluations of the model (in some cases tools can optimize this to avoid unneeded evaluations). - The problem for the standard when-clause is that after \lstinline!v! + The problem for the standard \lstinline!when!-clause is that after \lstinline!v! is changed, \lstinline!pre(v)! shall be updated and the model re-evaluated, since the equations could depend on \lstinline!pre(v)!. For clocked equations this iteration can be omitted @@ -141,9 +142,9 @@ \section{Rationale for Clocked Semantics}\label{rationale-for-clocked-semantics} Clocked subsystems using arithmetic blocks are straightforward to optimize. When a standard math-block (e.g.\ addition) is part of a clocked sub-system it is automatically clocked and only evaluated when the clocked equations trigger. - For standard when-clauses one either needs a separate sampled math-block for each operation, or + For standard \lstinline!when!-clauses one either needs a separate sampled math-block for each operation, or it will conceptually be evaluated all the time. - However, tools may perform a similar optimization for standard when-clauses + However, tools may perform a similar optimization for standard \lstinline!when!-clauses and it is only relevant in large sampled systems. \end{enumerate} \end{nonnormative} @@ -812,7 +813,7 @@ \subsection{Sub-clock conversion operators}\label{sub-clock-conversion-operators \section{Clocked When-Clause}\label{clocked-when-clause} -In addition to the previously discussed conditional when-clause, a \emph{clocked} when-clause\index{clocked!when-clause}\index{when-clause!clocked} is introduced: +In addition to the previously discussed conditional \lstinline!when!-clause, a \emph{clocked} \lstinline!when!-clause\index{clocked!\lstinline!when!-clause}\index{\lstinline!when!-clause!clocked} is introduced: % 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. @@ -823,9 +824,9 @@ \section{Clocked When-Clause}\label{clocked-when-clause} end when; \end{lstlisting} -The clocked when-clause cannot be nested and does not have any \lstinline!elsewhen! part. It cannot be used inside an algorithm. General equations are allowed in a clocked when-clause. +The clocked \lstinline!when!-clause cannot be nested and does not have any \lstinline!elsewhen! part. It cannot be used inside an algorithm. General equations are allowed in a clocked \lstinline!when!-clause. -For a clocked when-clause, all equations inside the when-clause are clocked with the same clock given by the $\mathit{clockExpression}$. +For a clocked \lstinline!when!-clause, all equations inside the \lstinline!when!-clause are clocked with the same clock given by the $\mathit{clockExpression}$. \section{Clock Partitioning}\label{clock-partitioning} @@ -841,7 +842,7 @@ \section{Clock Partitioning}\label{clock-partitioning} After model flattening, every equation in an equation section, every expression and every algorithm section is either continuous-time, or it is uniquely associated with exactly one clock. % Warning: The uses of \firstuse below aren't the first time these terms are used. In the latter case it is called a \firstuse{clocked equation}\index{clocked!equation}\index{equation!clocked}, a \willintroduce{clocked expression} or \firstuse{clocked algorithm}\index{clocked!algorithm}\index{algorithm!clocked} section respectively. -The associated clock is either explicitly defined by a when-clause, see \cref{sub-clock-conversion-operators}, or it is implicitly defined by the requirement that a clocked equation, a clocked expression and a clocked algorithm section must have the same clock as the variables used in them with exception of the expressions used as first arguments in the conversion operators of \cref{partitioning-operators}. +The associated clock is either explicitly defined by a \lstinline!when!-clause, see \cref{sub-clock-conversion-operators}, or it is implicitly defined by the requirement that a clocked equation, a clocked expression and a clocked algorithm section must have the same clock as the variables used in them with exception of the expressions used as first arguments in the conversion operators of \cref{partitioning-operators}. \firstuse{Clock inference}\index{clock!inference} means to infer the clock of a variable, an equation, an expression or an algorithm section if the clock is not explicitly defined and is deduced from the required properties in the previous two paragraphs. All variables in an expression without clock conversion operators must @@ -915,7 +916,7 @@ \subsection{Base-clock Partitioning}\label{base-clock-partitioning} \lstinline!y = backSample(u)!, \lstinline!y = previous(u)!, are in a clocked partition. -Equations in a clocked when clause are also in a clocked partition. +Equations in a clocked \lstinline!when!-clause are also in a clocked partition. Other partitions where none of the variables in the partition are associated with any of the operators above have an unspecified partition kind and are considered continuous-time partitions. All continuous-time partitions are collected together and form \firstuse{the continuous-time partition}\index{continuous-time!partition@partition, \emph{the}}. diff --git a/chapters/syntax.tex b/chapters/syntax.tex index 1451a4fef..3115e61c4 100644 --- a/chapters/syntax.tex +++ b/chapters/syntax.tex @@ -1,4 +1,5 @@ \chapter{Modelica Concrete Syntax}\label{modelica-concrete-syntax} + \section{Lexical conventions}\label{lexical-conventions} The following syntactic meta symbols are used (extended BNF): @@ -71,7 +72,9 @@ \section{Lexical conventions}\label{lexical-conventions} \end{itemize} \section{Grammar}\label{grammar} + \subsection{Stored Definition -- Within}\label{stored-definition-within} + \begin{lstlisting}[language=grammar] stored-definition : [ within [ name ] ";" ] @@ -79,6 +82,7 @@ \subsection{Stored Definition -- Within}\label{stored-definition-within} \end{lstlisting} \subsection{Class Definition}\label{class-definition} + \begin{lstlisting}[language=grammar] class-definition : [ encapsulated ] class-prefixes class-specifier @@ -166,6 +170,7 @@ \subsection{Class Definition}\label{class-definition} \end{lstlisting} \subsection{Extends}\label{extends} + \begin{lstlisting}[language=grammar] extends-clause : extends type-specifier [ class-modification ] [ annotation-clause ] @@ -175,6 +180,7 @@ \subsection{Extends}\label{extends} \end{lstlisting} \subsection{Component Clause}\label{component-clause} + \begin{lstlisting}[language=grammar] component-clause : type-prefix type-specifier [ array-subscripts ] component-list @@ -198,6 +204,7 @@ \subsection{Component Clause}\label{component-clause} \end{lstlisting} \subsection{Modification}\label{modification} + \begin{lstlisting}[language=grammar] modification : class-modification [ "=" expression ] @@ -239,6 +246,7 @@ \subsection{Modification}\label{modification} \end{lstlisting} \subsection{Equations}\label{equations1} + \begin{lstlisting}[language=grammar] equation-section : [ initial ] equation { equation ";" } @@ -333,6 +341,7 @@ \subsection{Equations}\label{equations1} \end{lstlisting} \subsection{Expressions}\label{expressions1} + \begin{lstlisting}[language=grammar] expression : simple-expression diff --git a/chapters/unitexpressions.tex b/chapters/unitexpressions.tex index 93e649eda..909a7c6bd 100644 --- a/chapters/unitexpressions.tex +++ b/chapters/unitexpressions.tex @@ -17,6 +17,7 @@ \chapter{Unit Expressions}\label{unit-expressions} \lstinline!"mm/s"!. \section{The Syntax of Unit Expressions}\label{the-syntax-of-unit-expressions} + \begin{lstlisting}[language=grammar] unit_expression: unit_numerator [ "/" unit_denominator ]