Skip to content

Commit

Permalink
BasedOnFeedback
Browse files Browse the repository at this point in the history
  • Loading branch information
HansOlsson committed Mar 16, 2021
1 parent 16d271c commit 0898f07
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions chapters/classes.tex
Expand Up @@ -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.
The discrete-time variables are a subset of all variables that are piecewise constant and only change at events.
Tools may optimize code to only compute piecewise constant variables at events.

\begin{lstlisting}[language=modelica]
model ShowDiscrete
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";
Real xc3 "Not discrete-time, but piecewise constant";
Expand All @@ -402,7 +402,7 @@ \subsection{Component Variability Prefixes discrete, parameter, constant}\label{
// It is legal to use pre for a discrete-time variable outside of when
xc3 = xd1 + pre(xd2);
// But pre(xc3) would not be legal
end ShowDiscrete;
end PiecewiseConstantReals;
\end{lstlisting}

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.
Expand Down

0 comments on commit 0898f07

Please sign in to comment.