-
Notifications
You must be signed in to change notification settings - Fork 45
Try to clean up clause-meaning. #3896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
574ae9a
219fdaf
f91a816
079cb76
1ecd6f9
35ffdf9
9460dcf
195d06f
1b4d7c8
3303338
3a93256
fe3027c
a18d419
48ae3ea
b2a1a9a
d63f515
e572a1e
22aa705
f07b4d3
e33b150
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -74,7 +74,7 @@ \subsubsection{Explicit Iteration Ranges of For-Equations}\label{explicit-iterat | |||||||||
| The expression of a \lstinline!for!-equation shall be evaluable. | ||||||||||
| The iteration range of a \lstinline!for!-equation can also be specified as \lstinline!Boolean! or as an enumeration type, see \cref{types-as-iteration-ranges} for more information. | ||||||||||
| The loop-variable (\lstinline!IDENT!) is in scope inside the loop-construct and shall not be assigned to. | ||||||||||
| For each element of the evaluated vector expression, in the normal order, the loop-variable gets the value of that element and that is used to evaluate the body of the \lstinline!for!-loop. | ||||||||||
| For each element of the evaluated vector expression, in the normal order, the loop-variable gets the value of that element and that is used to evaluate the \lstinline!for!-loop body. | ||||||||||
|
|
||||||||||
| \begin{example} | ||||||||||
| \begin{lstlisting}[language=modelica] | ||||||||||
|
|
@@ -126,13 +126,13 @@ \subsection{Connect-Equations}\label{connect-equations} | |||||||||
|
|
||||||||||
| \subsection{If-Equations}\label{if-equations} | ||||||||||
|
|
||||||||||
| The syntax of an \lstinline!if!-equations\index{if@\robustinline{if}!equation}\index{then@\robustinline{then}!if-equation@\robustinline{if}-equation}\index{else@\robustinline{else}!if-equation@\robustinline{if}-equation}\index{elseif@\robustinline{elseif}!if-equation@\robustinline{if}-equation} is given by \productionref{if-equation} in the grammar. | ||||||||||
| Here, each \productionref{expression} in the grammar (representing the condition 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. | ||||||||||
| The syntax of an \lstinline!if!-equation\index{if@\robustinline{if}!equation}\index{then@\robustinline{then}!if-equation@\robustinline{if}-equation}\index{else@\robustinline{else}!if-equation@\robustinline{if}-equation}\index{elseif@\robustinline{elseif}!if-equation@\robustinline{if}-equation} is given by \productionref{if-equation} in the grammar. | ||||||||||
| An \lstinline!if!-statement is seen as a list of branches: one \lstinline!if!-branch, and zero or more \lstinline!elseif!-branches, and an optional \lstinline!else!-branch. | ||||||||||
| One or zero of the branches is selected, by evaluating their conditions sequentially until a condition that evaluates to true is found. | ||||||||||
| If none of the conditions evaluate to true the \lstinline!else!-branch is selected if it exists, otherwise no branch is selected. | ||||||||||
| In an equation section, the equations in the body of the selected branch are seen as equations that must be satisfied. | ||||||||||
| The bodies of the branches that are not selected have no effect on that model evaluation. | ||||||||||
|
HansOlsson marked this conversation as resolved.
|
||||||||||
| Each branch condition (represented by \productionref{expression} in the grammar) must be a scalar \lstinline!Boolean! expression. | ||||||||||
|
|
||||||||||
| The \lstinline!if!-equations which do not have exclusively evaluable expressions as switching conditions shall satisfy the following: | ||||||||||
| \begin{itemize} | ||||||||||
|
|
@@ -196,7 +196,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 \lstinline!when!-clause. | ||||||||||
| 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 body. | ||||||||||
| Example: | ||||||||||
| \begin{lstlisting}[language=modelica] | ||||||||||
| /* discrete */ Real x; | ||||||||||
|
|
@@ -211,7 +211,7 @@ \subsubsection{Defining When-Equations by If-Expressions in Equality Equations}\ | |||||||||
|
|
||||||||||
| 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 \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. | ||||||||||
| However, \lstinline!pre(u)! is legal within the \lstinline!when!-clause body, since the body is only evaluated at events, and thus all expressions are discrete-time expressions. | ||||||||||
| \end{nonnormative} | ||||||||||
|
|
||||||||||
| The start values of the introduced \lstinline!Boolean! variables are defined by the taking the start value of the when-condition, as above where \lstinline!b! is a parameter variable. | ||||||||||
|
|
@@ -227,6 +227,7 @@ \subsubsection{Where a When-Equation May Occur}\label{restrictions-on-where-a-wh | |||||||||
| \lstinline!when!-equations cannot be nested. | ||||||||||
| \item | ||||||||||
| \lstinline!when!-equations can only occur within \lstinline!if!-equations and \lstinline!for!-equations if the controlling expressions are exclusively evaluable expressions. | ||||||||||
| For \lstinline!if!-equations this requires that the condition of the branch containing the \lstinline!when!-equation and the conditions of all preceding branches are evaluable. | ||||||||||
| \end{itemize} | ||||||||||
|
|
||||||||||
| \begin{example} | ||||||||||
|
|
@@ -400,7 +401,7 @@ \subsubsection{Single Assignment Rule Applied to When-Equations}\label{applicati | |||||||||
|
|
||||||||||
| \subsection{reinit}\label{reinit} | ||||||||||
|
|
||||||||||
| \lstinline!reinit! can only be used in the body of a \lstinline!when!-equation. | ||||||||||
| \lstinline!reinit! can only be used in a \lstinline!when!-equation body. | ||||||||||
| It has the following syntax: | ||||||||||
| \begin{lstlisting}[language=modelica] | ||||||||||
| reinit(x, expr); | ||||||||||
|
|
@@ -409,15 +410,15 @@ \subsection{reinit}\label{reinit} | |||||||||
| The operator reinitializes \lstinline!x! with \lstinline!expr! at an event instant. | ||||||||||
| \lstinline!x! is a component-reference (where any subscripts are evaluable) referring to a \lstinline!Real! variable (or an array of \lstinline!Real! variables) that must be selected as a state (resp., states), i.e., \lstinline!reinit! on \lstinline!x! implies \lstinline!stateSelect = StateSelect.always! on \lstinline!x!. | ||||||||||
| \lstinline!expr! needs to be type-compatible with \lstinline!x!. | ||||||||||
| For any given variable (possibly an array variable), \lstinline!reinit! can only be applied (either to an individual variable or to a part of an array variable) in one \lstinline!when!-equation (applying \lstinline!reinit! to a variable in several \lstinline!when!- or \lstinline!elsewhen!-clauses of the same \lstinline!when!-equation is allowed). | ||||||||||
| If there are multiple \lstinline!reinit! for a variable inside the same \lstinline!when!- or \lstinline!elsewhen!-clause, they must appear in different branches of an \lstinline!if!-equation (in order that at most one \lstinline!reinit! for the variable is active at any event). | ||||||||||
| For any given variable (possibly an array variable), \lstinline!reinit! can only be applied (either to an individual variable or to a part of an array variable) in one \lstinline!when!-equation (applying \lstinline!reinit! to a variable in several branches of the same \lstinline!when!-equation is allowed). | ||||||||||
| If there are multiple \lstinline!reinit! for a variable inside one \lstinline!when!-clause body, they must appear in different branches of an \lstinline!if!-equation (in order that at most one \lstinline!reinit! for the variable is active at any event). | ||||||||||
| In case of \lstinline!reinit! active during initialization (due to \lstinline!when initial()!), see \cref{initialization-initial-equation-and-initial-algorithm}. | ||||||||||
|
|
||||||||||
| \lstinline!reinit! does not break the single assignment rule, because \lstinline!reinit(x, expr)! in equations evaluates \lstinline!expr! to a value, then at the end of the current event iteration step it assigns this value to \lstinline!x! (this copying from values to reinitialized state(s) is done after all other evaluations of the model and before copying \lstinline!x! to \lstinline!pre(x)!). | ||||||||||
|
|
||||||||||
| \begin{example} | ||||||||||
| If a higher index system is present, i.e., constraints between 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 \lstinline!when!-clauses become active. | ||||||||||
| 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 during the events when the \lstinline!reinit!-equation is active. | ||||||||||
| If this is not possible, an error occurs, since otherwise \lstinline!reinit! would be applied to a non-state variable. | ||||||||||
|
|
||||||||||
| Example for the usage of \lstinline!reinit! (bouncing ball): | ||||||||||
|
|
@@ -643,7 +644,7 @@ \section{Events and Synchronization}\label{events-and-synchronization} | |||||||||
| Clocked discrete-time partitions are also treated this way, see \cref{clocked-discrete-time-and-clocked-discretized-continuous-time-partition}. | ||||||||||
|
|
||||||||||
| \begin{nonnormative} | ||||||||||
| Using state events in \lstinline!when!-clauses is unnecessary because the body of a \lstinline!when!-clause is not evaluated during continuous integration. | ||||||||||
| Expressions in \lstinline!when!-clause bodies do not trigger state events since they are not active during during continuous integration. | ||||||||||
| \end{nonnormative} | ||||||||||
|
|
||||||||||
| \begin{example} | ||||||||||
|
|
@@ -715,7 +716,7 @@ \section{Events and Synchronization}\label{events-and-synchronization} | |||||||||
| end when; | ||||||||||
| \end{lstlisting} | ||||||||||
|
|
||||||||||
| The \lstinline!slowSample! \lstinline!when!-clause is evaluated at every 5th occurrence of the \lstinline!fastSample! \lstinline!when!-clause. | ||||||||||
| The \lstinline!slowSample! \lstinline!when!-clause body is evaluated at every 5th evaluation of the \lstinline!fastSample! \lstinline!when!-clause body. | ||||||||||
| \end{nonnormative} | ||||||||||
|
|
||||||||||
| \begin{nonnormative} | ||||||||||
|
|
@@ -744,7 +745,7 @@ \section{Initialization, initial equation, and initial algorithm}\label{initiali | |||||||||
| The algorithmic statements within a \lstinline!when!-statement 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!. | ||||||||||
| In this case, the algorithmic statements within the \lstinline!when!-statement remain active during the whole initialization phase. | ||||||||||
|
|
||||||||||
| An active \lstinline!when!-clause inactivates the following \lstinline!elsewhen! (similarly to \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!. | ||||||||||
| An active \lstinline!when!-clause branch condition inactivates the following \lstinline!elsewhen! (similarly to \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!. | ||||||||||
|
|
||||||||||
| \begin{nonnormative} | ||||||||||
| That means that any subsequent \lstinline!elsewhen initial()! has no effect, similarly to \lstinline!when false then!. | ||||||||||
|
|
@@ -946,7 +947,7 @@ \section{Initialization, initial equation, and initial algorithm}\label{initiali | |||||||||
| \end{lstlisting} | ||||||||||
| After solving the initialization problem, both \lstinline!b! and \lstinline!pre(b)! are false. | ||||||||||
| During transient analysis, \lstinline!initial()! is false, so \lstinline!b! changes from falso to true during the first round of the initial event iteration. | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nearby typo:
Suggested change
|
||||||||||
| This triggers the \lstinline!when!-clause, and \lstinline!x! gets reinitialized. | ||||||||||
| This triggers the \lstinline!when!-clause body, and \lstinline!x! gets reinitialized. | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't it better to speak of triggered branches than triggered bodies?
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above I think that only the body is active/triggered.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd say it's especially when speaking of triggering that branch makes much better sense than body.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking more I believe that a solution might be something subtly different (which indicates that more time is needed). I still think that only the body is really triggered, whereas the condition is triggering it. Both of these are part of the branch, so to me it seems that the branch should be more active (instead of passively getting triggered). Perhaps something like:
Suggested change
possibly replace "triggers" by "triggers based on the change in b".
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The difference is very subtle and I don't see why the active way to see it would make more sense than the passive, while at least the passive is more easy to concisely connect with the previous sentence. |
||||||||||
| \end{example} | ||||||||||
|
|
||||||||||
|
|
||||||||||
|
|
||||||||||
Uh oh!
There was an error while loading. Please reload this page.