Skip to content

Commit

Permalink
Use "discrete-time variable" consistently. (#2646)
Browse files Browse the repository at this point in the history
* Use "discrete-time variable" consistently, and some minor cleanup.
Closes #2640

Co-authored-by: Henrik Tidefelt <henrikt@wolfram.com>
  • Loading branch information
HansOlsson and henrikt-ma committed Sep 15, 2020
1 parent ac98919 commit 82b922e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion chapters/annotations.tex
Expand Up @@ -934,7 +934,7 @@ \subsection{Variable Graphics and Schematic Animation}\label{variable-graphics-a
\subsection{User input}\label{user-input}

It is possible to interactively modify variables during a simulation.
The variables may either be parameters, discrete variables or states.
The variables may either be parameters, discrete-time variables or states.
New numeric values can be given, a mouse click can change a Boolean
variable or a mouse movement can change a Real variable. Input fields
may be associated with a \lstinline!GraphicItem! or a component as an array named
Expand Down
6 changes: 3 additions & 3 deletions chapters/dae.tex
Expand Up @@ -70,7 +70,7 @@ \chapter{Modelica DAE Representation}\label{modelica-dae-representation}
\item
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
discrete variables $m$ are kept constant. Therefore, \eqref{eq:dae} is a
discrete-time variables $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.
\item
Expand All @@ -91,8 +91,8 @@ \chapter{Modelica DAE Representation}\label{modelica-dae-representation}
$m$ (all \lstinline!discrete Real!, \lstinline!Boolean! and \lstinline!Integer! variables) are only changed at
an event instant and that these variables remain constant during
continuous integration. At every event instant, new values of the
discrete variables $m$ and of new initial values for the states $x$ are
determined. The change of discrete variables may characterize a new
discrete-time variables $m$ and of new initial values for the states $x$ are
determined. The change of discrete-time variables may characterize a new
structure of a DAE where elements of the state vector $x$ are
\emph{disabled}. In other words, the number of state variables,
algebraic variables and residue equations of a DAE may change at event
Expand Down
8 changes: 4 additions & 4 deletions chapters/equations.tex
Expand Up @@ -555,7 +555,7 @@ \section{Synchronous Data-flow Principle and Single Assignment Rule}\label{synch
Modelica is based on the synchronous data flow principle and the single
assignment rule, which are defined in the following way:
\begin{enumerate}
\item Discrete variables keep their actual values until these variables are explicitly changed.
\item Discrete-time variables keep their values until these variables are explicitly changed.
Differentiated variables have \lstinline!der(x)! corresponding to the time-derivative of \lstinline!x!,
and \lstinline!x! is continuous, except when \lstinline!reinit! is triggered, see \cref{reinit}.
Variable values can be accessed at any time instant during continuous integration and at event instants.
Expand Down Expand Up @@ -796,9 +796,9 @@ \section{Initialization, initial equation, and initial algorithm}\label{initiali
Implicitly by using the \lstinline!start! attribute for variables with \lstinline!fixed = true!. With \lstinline!start! given by \lstinline!startExpression!:
\begin{itemize}
\item
For a non-discrete (that is continuous-time) \lstinline!Real! variable \lstinline!vc!, the equation \lstinline!vc = startExpression! is added to the initialization equations.
For a non-discrete-time (that is continuous-time) \lstinline!Real! variable \lstinline!vc!, the equation \lstinline!vc = startExpression! is added to the initialization equations.
\item
For a discrete variables \lstinline!vd!, the equation \lstinline!pre(vd) = startExpression! is added to the initialization equations.
For a discrete-time variables \lstinline!vd!, the equation \lstinline!pre(vd) = startExpression! is added to the initialization equations.
\item
For a variable declared as \lstinline!constant! or \lstinline!parameter!, no equation is added to the initialization equations.
\end{itemize}
Expand Down Expand Up @@ -843,7 +843,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 may not be what the user
expects. A missing initial value of a discrete variable which does not influence the simulation result, may be automatically set to the \lstinline!start! value or its default without
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
used on these variables, do not have an effect on the simulation.
\end{nonnormative}
Expand Down
4 changes: 2 additions & 2 deletions chapters/operatorsandexpressions.tex
Expand Up @@ -1376,12 +1376,12 @@ \subsection{Discrete-Time Expressions}\label{discrete-time-expressions}
Inside an if-expression, \lstinline!if!-clause, \lstinline!while!-statement or \lstinline!for!-clause, that
is controlled by a non-discrete-time (that is continuous-time, but not
discrete-time) switching expression and not in the body of a
\lstinline!when!-clause, it is not legal to have assignments to discrete variables,
\lstinline!when!-clause, it is not legal to have assignments to discrete-time variables,
equations between discrete-time expressions, or real elementary
relations/functions that should generate events.

\begin{nonnormative}
The restriction above is necessary in order to guarantee that all equations for discrete variable are discrete-time expressions, and to ensure that crossing
The restriction above is necessary in order to guarantee that all equations for discrete-time variable are discrete-time expressions, and to ensure that crossing
functions do not become active between events.
\end{nonnormative}

Expand Down
15 changes: 13 additions & 2 deletions chapters/statements.tex
Expand Up @@ -33,14 +33,20 @@ \subsection{Execution of an algorithm in a model}\label{execution-of-an-algorith
\lstinline!:=! are initialized (at least conceptually):
\begin{itemize}
\item
A non-discrete variable is initialized with its start value (i.e.\ the
A continuous-time variable is initialized with its start value (i.e.\ the
value of the start-attribute).
\item
A discrete variable \lstinline!v! is initialized with \lstinline!pre(v)!.
A discrete-time variable \lstinline!v! is initialized with \lstinline!pre(v)!.
\item
If at least one element of an array appears on the left hand side of
the assignment operator, then the complete array is initialized in
this algorithm section.
\item
A parameter assigned in an initial algorithm, \cref{initialization-initial-equation-and-initial-algorithm},
is initialized with its start-value (i.e.\ the value of the \lstinline!start! attribute)
provided the start-value can be evaluated before evaluating the initial algorithm
(a literal value can always be evaluated); otherwise a default start-value is used
(together with appropriate diagnostics) as if the \lstinline!start! attribute was not set.
\end{itemize}

\begin{nonnormative}
Expand Down Expand Up @@ -68,6 +74,11 @@ \subsection{Execution of an algorithm in a model}\label{execution-of-an-algorith
x[2] := 2;
end Test;
\end{lstlisting}

The conceptual part indicate that if the variable is assigned unconditionally
in the algorithm before it is used the initialization can be omitted.
This is usually the case, except for algorithms with when-statements,
and especially for initial algorithms.
\end{nonnormative}

\subsection{Execution of the algorithm in a function}\label{execution-of-the-algorithm-in-a-function}
Expand Down

0 comments on commit 82b922e

Please sign in to comment.