Skip to content

Commit

Permalink
Cleanup related to 'noEvent' and 'smooth'
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikt-ma committed Oct 13, 2020
1 parent 80b1aa7 commit 312409d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
18 changes: 3 additions & 15 deletions chapters/equations.tex
Expand Up @@ -603,14 +603,7 @@ \section{Events and Synchronization}\label{events-and-synchronization}
exact event instant.
\end{nonnormative}

Relations are taken literally also during continuous integration, if the
relation or the expression in which the relation is present, are the
argument of \lstinline!noEvent!. \lstinline!smooth! also
allows relations used as argument to be taken literally. The \lstinline!noEvent!
feature is propagated to all subrelations in the scope of the \lstinline!noEvent!
application. For \lstinline!smooth! the liberty to not allow literal evaluation is
propagated to all subrelations, but the smooth-property itself is not
propagated.
Relations are taken literally also during continuous integration, if the relation or the expression in which the relation is present, are the argument of \lstinline!noEvent!. \lstinline!smooth! also allows relations used as argument to be taken literally. The \lstinline!noEvent! feature is propagated to all subrelations in the scope of the \lstinline!noEvent! application. For \lstinline!smooth! the liberty to not allow literal evaluation is propagated to all subrelations, but the smoothness property itself is not propagated.

\begin{example}
\begin{lstlisting}[language=modelica]
Expand All @@ -619,14 +612,9 @@ \section{Events and Synchronization}\label{events-and-synchronization}
z = smooth(0, if u > uMax then uMax elseif u < uMin then uMin else u);
\end{lstlisting}

In this case \lstinline!x = y = z!, but a tool might generate events for \lstinline!z!. The
if-expression is taken literally without inducing state events.
In this case \lstinline!x = y = z!, but a tool might generate events for \lstinline!z!. The if-expression is taken literally without inducing state events.

The \lstinline!smooth! function is useful, if e.g.\ the modeler can guarantee that
the used if-clauses fulfill at least the continuity requirement of
integrators. In this case the simulation speed is improved, since no
state event iterations occur during integration. The \lstinline!noEvent! function is
used to guard against \emph{outside domain} errors, e.g.\ \lstinline!y = if noEvent(x>= 0) then sqrt(x) else 0.!
The \lstinline!smooth! operator is useful, if e.g.\ the modeler can guarantee that the used if-clauses fulfill at least the continuity requirement of integrators. In this case the simulation speed is improved, since no state event iterations occur during integration. The \lstinline!noEvent! operator is used to guard against \emph{outside domain} errors, e.g.\ \lstinline!y = if noEvent(x >= 0) then sqrt(x) else 0.!
\end{example}

All equations and assignment statements within when-clauses and all assignment statements within \lstinline!function! classes are implicitly treated with \lstinline!noEvent!, i.e., relations within the scope of these operators never induce state or time events.
Expand Down
5 changes: 3 additions & 2 deletions chapters/lexicalstructure.tex
Expand Up @@ -235,14 +235,15 @@ \subsection{Strings}\label{strings}
literal. For example, the following statement defines one string that
contains (non-printable) newline characters:
\begin{lstlisting}[language=modelica]
assert(noEvent(length > s_small), "
assert(noEvent(length > s_small),
"
The distance between the origin of frame_a and the origin of frame_b
of a LineForceWithMass component became smaller as parameter s_small
(= a small number, defined in the
\"Advanced\" menu). The distance is
set to s_small, although it is smaller, to avoid a division by zero
when computing the direction of the line force.",
level = AssertionLevel.warning);
level = AssertionLevel.warning);
\end{lstlisting}
\end{nonnormative}

Expand Down
2 changes: 1 addition & 1 deletion chapters/operatorsandexpressions.tex
Expand Up @@ -516,7 +516,7 @@ \subsection{Event Triggering Mathematical Functions}\label{event-triggering-math
These expression for \lstinline!div!, \lstinline!ceil!, \lstinline!floor!, and \lstinline!integer! are event generating expression. The event generating expression for \lstinline!mod(x,y)! is \lstinline!floor(x/y)!, and for \lstinline!rem(x,y)! it is \lstinline!div(x,y)! -- i.e.\ events are not generated when \lstinline!mod! or \lstinline!rem! changes continuously in an interval, but when they change discontinuously from one interval to the next.

\begin{nonnormative}
If this is not desired, the \lstinline!noEvent! function can be applied to them. E.g.\ \lstinline!noEvent(integer(v))!.
If this is not desired, the \lstinline!noEvent! operator can be applied to them. E.g.\ \lstinline!noEvent(integer(v))!.
\end{nonnormative}

\begin{operatordefinition}[div]
Expand Down

0 comments on commit 312409d

Please sign in to comment.