Skip to content

Commit

Permalink
Cleanup related to 'sample'
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikt-ma committed Oct 13, 2020
1 parent 312409d commit 2d12453
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 25 deletions.
4 changes: 2 additions & 2 deletions chapters/revisions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ \subsection{Main changes in Modelica 3.4}\label{main-changes-in-modelica-3-4}
Corrected typo for events, \cref{modelica:smooth}. Ticket
\href{https://github.com/modelica/ModelicaSpecification/issues/1657}{\#1657}.
\item
Clarified sample operator, \cref{event-related-operators-with-function-syntax}. Ticket
\href{https://github.com/modelica/ModelicaSpecification/issues/677}{\#677}.
Clarified \lstinline!sample! operator, \cref{event-related-operators-with-function-syntax}.
Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/677}{\#677}.
\item
Additional functions give parameter expression, \cref{parameter-expressions}. Ticket
\href{https://github.com/modelica/ModelicaSpecification/issues/1082}{\#1082}.
Expand Down
29 changes: 6 additions & 23 deletions chapters/synchronous.tex
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,11 @@ \chapter{Synchronous Language Elements}\label{synchronous-language-elements}
\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 sample operator, see
\cref{event-related-operators-with-function-syntax}. For example:
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:
\begin{lstlisting}[language=modelica]
when sample(0,3) then
xd = A*pre(xd) + B*y;
u = C*pre(xd) + D*y;
when sample(0, 3) then
xd = A * pre(xd) + B * y;
u = C * pre(xd) + D * y;
end when;
\end{lstlisting}

Expand Down Expand Up @@ -602,22 +600,7 @@ \subsection{Base-clock conversion operators}\label{base-clock-conversion-operato
and therefore \lstinline!yc = 2!.

Sorting of a simulation model:\\
Since sample(u) returns the left limit of u, and the left limit of u is
a known value, all inputs to a base-clock partition are treated as known
during sorting. Since a periodic and interval clock can tick at most
once at a time instant, and since the left limit of a variable does not
change during event iteration (i.e., re-evaluating a base-clock
partition associated with a condition clock always gives the same result
because the sample(u) inputs do not change and therefore need not to be
re-evaluated) all base-clock partitions, see \cref{base-clock-partitioning}, need
not to be sorted with respect to each other. Instead, at an event
instant, active base-clock partitions can be evaluated first (and once)
in any order. Afterwards, the continuous-time partition is evaluated.
Event iteration takes place only over the continuous-time partition. In
such a scenario, accessing the left limit of u in sample(u) just means
to pick the latest available value of u when the partition is entered,
storing it in a local variable of the partition and only using this
local copy during evaluation of the equations in this partition.
Since \lstinline!sample(u)! returns the left limit of \lstinline!u!, and the left limit of \lstinline!u! is a known value, all inputs to a base-clock partition are treated as known during sorting. Since a periodic and interval clock can tick at most once at a time instant, and since the left limit of a variable does not change during event iteration (i.e., re-evaluating a base-clock partition associated with a condition clock always gives the same result because the \lstinline!sample(u)! inputs do not change and therefore need not to be re-evaluated) all base-clock partitions, see \cref{base-clock-partitioning}, need not to be sorted with respect to each other. Instead, at an event instant, active base-clock partitions can be evaluated first (and once) in any order. Afterwards, the continuous-time partition is evaluated. Event iteration takes place only over the continuous-time partition. In such a scenario, accessing the left limit of \lstinline!u! in \lstinline!sample(u)! just means to pick the latest available value of \lstinline!u! when the partition is entered, storing it in a local variable of the partition and only using this local copy during evaluation of the equations in this partition.
\end{example}

\subsection{Sub-clock conversion operators}\label{sub-clock-conversion-operators}
Expand Down Expand Up @@ -792,7 +775,7 @@ \subsection{Sub-clock conversion operators}\label{sub-clock-conversion-operators
end NoClockVsSampleHold;
\end{lstlisting}

Due to the infinitesimal delay of sample; \lstinline!z! will not show the current value of \lstinline!x! as \lstinline!clk2! ticks, but will show its previous value (left limit). However, \lstinline!y! will show the current value, since it has no infinitesimal delay.
Due to the infinitesimal delay of \lstinline!sample!, \lstinline!z! will not show the current value of \lstinline!x! as \lstinline!clk2! ticks, but will show its previous value (left limit). However, \lstinline!y! will show the current value, since it has no infinitesimal delay.
\end{nonnormative}

Note that it is not legal to compute the derivative of the \lstinline!sample!, \lstinline!subSample!, \lstinline!superSample!, \lstinline!backSample!,
Expand Down

0 comments on commit 2d12453

Please sign in to comment.