From 99f8fb8e9eeafc3375b25966ab1d987a266f2d6a Mon Sep 17 00:00:00 2001 From: Henrik Tidefelt Date: Tue, 13 Oct 2020 17:53:13 +0200 Subject: [PATCH] Cleanup related to 'flow' --- chapters/annotations.tex | 23 ++++------------------- chapters/classes.tex | 22 +++++----------------- chapters/connectors.tex | 12 ++++-------- chapters/interface.tex | 12 +----------- chapters/revisions.tex | 4 ++-- 5 files changed, 16 insertions(+), 57 deletions(-) diff --git a/chapters/annotations.tex b/chapters/annotations.tex index 2639f3153..d6078f88d 100644 --- a/chapters/annotations.tex +++ b/chapters/annotations.tex @@ -1078,27 +1078,12 @@ \section{Annotations for the Graphical User Interface}\label{annotations-for-the annotation(defaultConnectionStructurallyInconsistent=true) \end{lstlisting} -If \lstinline!true!, it is stated that a default connection will result in a -structurally inconsistent model or block\footnote{For the precise - definition of "structurally inconsistent" see the article: - \href{http://epubs.siam.org/doi/abs/10.1137/0909014}{Pantelides C.C.: - The Consistent Initialization of Differential-Algebraic Systems, SIAM - J.\ Sci.\ and Stat.\ Comput.\ Volume 9, Issue 2, pp. 213--231 (March - 1988)}}. A "default connection" is constructed by instantiating the -respective \lstinline!model! or \lstinline!block! and for every input \lstinline!u! providing an equation -\lstinline!0=f(u)!, and for every (potential,flow) pair of the form \lstinline!(v,i)!, providing -an equation of the form \lstinline!0=f(v,i)!. +If \lstinline!true!, it is stated that a default connection will result in a structurally inconsistent model or block\footnote{% + For the precise definition of \emph{structurally inconsistent} see the article: \href{http://epubs.siam.org/doi/abs/10.1137/0909014}{Pantelides C.C.: The Consistent Initialization of Differential-Algebraic Systems, SIAM J.\ Sci.\ and Stat.\ Comput.\ Volume 9, Issue 2, pp. 213--231 (March 1988)}}. +A "default connection" is constructed by instantiating the respective \lstinline!model! or \lstinline!block! and for every input \lstinline!u! providing an equation \lstinline!0 = f(u)!, and for every (potential, flow) pair of the form \lstinline!(v, i)!, providing an equation of the form \lstinline!0 = f(v, i)!. \begin{nonnormative} -It is useful to check all models/blocks of a Modelica package -in a simple way. One check is to default connect every model/block and -to check whether the resulting class is structurally consistent (which is a -stronger requirement than being balanced). It is rarely needed; but is for -example used in Modelica.Blocks.Math.InverseBlockConstraints, in order -to prevent a wrong error message. Additionally, when a user defined -model is structurally inconsistent, a tool should try to pinpoint in -which class the error is present. This annotation avoids then to show a -wrong error message. +It is useful to check all models/blocks of a Modelica package in a simple way. One check is to default connect every model/block and to check whether the resulting class is structurally consistent (which is a stronger requirement than being balanced). It is rarely needed; but is for example used in \lstinline!Modelica.Blocks.Math.InverseBlockConstraints!, in order to prevent a wrong error message. Additionally, when a user defined model is structurally inconsistent, a tool should try to pinpoint in which class the error is present. This annotation avoids then to show a wrong error message. \end{nonnormative} A class may have the following annotation: diff --git a/chapters/classes.tex b/chapters/classes.tex index 1da926a84..af4969948 100644 --- a/chapters/classes.tex +++ b/chapters/classes.tex @@ -230,19 +230,7 @@ \subsubsection{Prefix Rules}\label{prefix-rules} In addition, instances of classes extending from \lstinline!ExternalObject! may have type prefixes \lstinline!parameter! and \lstinline!constant!, and in functions also type prefixes \lstinline!input! and \lstinline!output!, see \cref{external-objects}. -The type prefixes \lstinline!flow!, \lstinline!stream!, \lstinline!input! -and \lstinline!output! of a structured -component (except as described above) are also applied to the elements -of the component (this is done after verifying that the type prefixes -occurring on elements of the component are correct; e.g.\ the \lstinline!flow! prefix -can be used on a record component and all the record elements will -generate zero-sum equations, even if elements of a record shall not be -declared with the flow prefix). When any of the type prefixes \lstinline!flow!, -\lstinline!stream!, \lstinline!input! and \lstinline!output! are applied for a structured component, no -element of the component may have any of these type prefixes. -The corresponding rules for the type prefixes \lstinline!discrete!, -\lstinline!parameter! and \lstinline!constant! are described in \cref{variability-of-structured-entities} for structured -components. +The type prefixes \lstinline!flow!, \lstinline!stream!, \lstinline!input! and \lstinline!output! of a structured component (except as described above) are also applied to the elements of the component (this is done after verifying that the type prefixes occurring on elements of the component are correct; e.g.\ the \lstinline!flow! prefix can be used on a record component and all the record elements will generate zero-sum equations, even if elements of a record shall not be declared with the \lstinline!flow! prefix). When any of the type prefixes \lstinline!flow!, \lstinline!stream!, \lstinline!input! and \lstinline!output! are applied for a structured component, no element of the component may have any of these type prefixes. The corresponding rules for the type prefixes \lstinline!discrete!, \lstinline!parameter! and \lstinline!constant! are described in \cref{variability-of-structured-entities} for structured components. \begin{example} \lstinline!input! can only be used, if none of the elements has a \lstinline!flow!, \lstinline!stream!, \lstinline!input! or @@ -958,7 +946,7 @@ \section{Balanced Models}\label{balanced-models} the flat Hybrid DAE formulation (see \cref{modelica-dae-representation}). \end{nonnormative} \item - The number of input and flow-variables present in each (top-level) public connector component. + The number of input and flow variables present in each (top-level) public connector component. \begin{nonnormative} This represents the number of connection equations that will be provided when the class is used. \end{nonnormative} @@ -1008,7 +996,7 @@ \section{Balanced Models}\label{balanced-models} \item The number of equations defined (included in any \lstinline!model! or \lstinline!block! component), including equations generated from connect-equations. \item - The number of input and flow-variables present in each (top-level) public connector component. + The number of input and flow variables present in each (top-level) public connector component. \item The number of (top level) public input variables that neither are connectors nor have binding equations. \begin{nonnormative} @@ -1084,7 +1072,7 @@ \section{Balanced Models}\label{balanced-models} u &= p.v - n.v;\\ C \cdot \text{der}(u) &= p.i; \end{align*} -and 2 equations corresponding to the 2 flow-variables \lstinline!p.i! and \lstinline!n.i!. +and 2 equations corresponding to the 2 flow variables \lstinline!p.i! and \lstinline!n.i!. These are 5 equations in 5 unknowns (locally balanced model). A more detailed analysis would reveal that this is structurally non-singular, i.e.\ that the hybrid DAE will not contain a singularity independent of actual values. @@ -1094,7 +1082,7 @@ \section{Balanced Models}\label{balanced-models} If the equation \lstinline!u = p.v - n.v! would be replaced by the equation \lstinline!u = 0! and the equation \lstinline!C*der(u) = p.i! would be replaced by the equation \lstinline!C*der(u) = 0!, there would be 5 equations in 5 unknowns (locally balanced), but the equations would be singular, -regardless of how the equations corresponding to the flow-variables are constructed because the information that \lstinline!u! is constant is given twice +regardless of how the equations corresponding to the flow variables are constructed because the information that \lstinline!u! is constant is given twice in a slightly different form. \end{example} diff --git a/chapters/connectors.tex b/chapters/connectors.tex index 28d60cea3..1258e9954 100644 --- a/chapters/connectors.tex +++ b/chapters/connectors.tex @@ -423,7 +423,7 @@ \section{Generation of Connection Equations}\label{generation-of-connection-equa merged): \begin{itemize} \item - Each primitive flow-variable as inside connector. + Each primitive flow variable as inside connector. \item Each flow variable \emph{added} during augmentation of expandable connectors, both as inside and as outside. @@ -445,13 +445,13 @@ \section{Generation of Connection Equations}\label{generation-of-connection-equa \item $a_{1} = a_{2} = \ldots = a_{n}$ (neither flow nor stream variables) \item -$z_{1} + z_{2} + (-z_{3}) + \ldots + z_{n} = \mathbf{0}$ (flow-variables) +$z_{1} + z_{2} + (-z_{3}) + \ldots + z_{n} = \mathbf{0}$ (flow variables) \end{itemize} The bold-face $\mathbf{0}$ represents an array or scalar zero of appropriate dimensions (i.e.\ the same size as $z$). -For an \lstinline!operator record! type this uses the operator \lstinline!'0'! -- which must be defined in the operator record -- and all of the flow-variables for the \lstinline!operator record! +For an \lstinline!operator record! type this uses the operator \lstinline!'0'! -- which must be defined in the operator record -- and all of the flow variables for the \lstinline!operator record! must be of the same \lstinline!operator record! type. This implies that in order to have flow variables of an \lstinline!operator record! type the \lstinline!operator record! must define addition, negation, and \lstinline!'0'!; and these operations should define an additive group. @@ -601,11 +601,7 @@ \section{Restrictions of Connections and Connectors}\label{restrictions-of-conne primitive components. The primitive components with the same name are matched and belong to the same connection set. \item - The matched primitive components of the two connectors must have the - same primitive types, and flow-variables may only connect to other - flow-variables, stream-variables only to other stream-variables, and - causal variables (\lstinline!input!/\lstinline!output!) only to causal variables - (\lstinline!input!/\lstinline!output!). + The matched primitive components of the two connectors must have the same primitive types, and flow variables may only connect to other flow variables, stream variables only to other stream variables, and causal variables (\lstinline!input!/\lstinline!output!) only to causal variables (\lstinline!input!/\lstinline!output!). \item A connection set of causal variables (\lstinline!input!/\lstinline!output!) may at most contain variables from one inside \lstinline!output! connector or one public diff --git a/chapters/interface.tex b/chapters/interface.tex index 5b28a5ad0..02def7283 100644 --- a/chapters/interface.tex +++ b/chapters/interface.tex @@ -522,17 +522,7 @@ \section{Plug-Compatibility or Restricted Subtyping}\label{plug-compatibility-or end UseDriveLine; \end{lstlisting} -If a subcomponent is redeclared, it is impossible to connect to -any new connector. Thus any new connectors must work without being -connected, i.e., the default connection of flow-variables. That fails -for inputs (and expandable connectors may contain inputs). For -parameters and non-connector inputs it would be possible to provide -bindings in a derived class, but that would require hierarchical -modifiers and it would be bad modeling practice that a hierarchical -modifier must be used in order to make a model valid. A replaceable -class might be used as the class for a sub-component, therefore -plug-compatibility is required not only for replaceable sub-components, -but also for replaceable classes. +If a subcomponent is redeclared, it is impossible to connect to any new connector. Thus any new connectors must work without being connected, i.e., the default connection of flow variables. That fails for inputs (and expandable connectors may contain inputs). For parameters and non-connector inputs it would be possible to provide bindings in a derived class, but that would require hierarchical modifiers and it would be bad modeling practice that a hierarchical modifier must be used in order to make a model valid. A replaceable class might be used as the class for a sub-component, therefore plug-compatibility is required not only for replaceable sub-components, but also for replaceable classes. \end{nonnormative} \section{Function-Compatibility or Function-Subtyping for Functions}\label{function-compatibility-or-function-subtyping-for-functions} diff --git a/chapters/revisions.tex b/chapters/revisions.tex index d72598cc8..212817ae6 100644 --- a/chapters/revisions.tex +++ b/chapters/revisions.tex @@ -230,8 +230,8 @@ \subsection{Main changes in Modelica 3.4}\label{main-changes-in-modelica-3-4} Corrected expandable connector example, \cref{expandable-connectors}. Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/1763}{\#1763}. \item - Clarified that stream-variables do not generate equations, \cref{generation-of-connection-equations}. Ticket - \href{https://github.com/modelica/ModelicaSpecification/issues/1584}{\#1584}. + Clarified that stream variables do not generate equations, \cref{generation-of-connection-equations}. + Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/1584}{\#1584}. \item Restrict that stream only connects to stream, \cref{restrictions-of-connections-and-connectors}. Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/796}{\#796}.