Skip to content

Commit

Permalink
Move smoothOrder to "Declaring Derivatives of Functions"
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikt-ma committed Apr 29, 2021
1 parent 4103f30 commit 891f414
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 29 deletions.
25 changes: 0 additions & 25 deletions chapters/annotations.tex
Expand Up @@ -346,7 +346,6 @@ \section{Annotations for Code Generation}\label{annotations-for-code-generation}
\lstinline!LateInline! & Inline after all symbolic transformations & \Cref{modelica:LateInline}\\
\lstinline!InlineAfterIndexReduction! & Inline after index reduction & \Cref{modelica:InlineAfterIndexReduction}\\
\lstinline!GenerateEvents! & Generate events for zero crossings in function & \Cref{modelica:GenerateEvents}\\
\lstinline!smoothOrder! & Function smoothness guarantee & \Cref{modelica:smoothOrder}\\
\hline
\end{tabular}
\end{center}
Expand Down Expand Up @@ -455,30 +454,6 @@ \section{Annotations for Code Generation}\label{annotations-for-code-generation}
\end{semantics}
\end{annotationdefinition}

\begin{annotationdefinition}[smoothOrder]
\begin{synopsis}[grammar]\begin{lstlisting}
"smoothOrder" "=" UNSIGNED-NUMBER ")"
"smoothOrder" "(" "normallyConstant" "=" IDENT
{ "," "normallyConstant" "=" IDENT } ")" "=" UNSIGNED-NUMBER ")"
\end{lstlisting}\end{synopsis}
\begin{semantics}
This annotation has only an effect within a function declaration.

\lstinline!smoothOrder! defines the number of differentiations of the function, in order that all of the differentiated outputs are continuous provided all input arguments and their derivatives up to order \lstinline!smoothOrder! are continuous.

\begin{nonnormative}
This means that the function is at least C\textsuperscript{smoothOrder}. \lstinline!smoothOrder = 1! means that the function can be differentiated at least once in order that all output arguments are still continuous, provided the input arguments are continuous. If a tool needs the derivative of a function, e.g.\ for index reduction or to compute an analytic Jacobian, the function can be differentiated analytically at least \lstinline!smoothOrder! times.
\end{nonnormative}

The optional argument \lstinline!normallyConstant! of \lstinline!smoothOrder! defines that the function argument \lstinline!IDENT! is usually constant.

\begin{nonnormative}
A tool might check whether the actual argument to \lstinline!IDENT! is a parameter expression at the place where the function is called. If this is the case, the derivative of the function might be constructed under the assumption that the corresponding argument is constant, to enhance efficiency. Typically, a tool would generate at most two different derivative functions of a function: One, under the assumption that all \lstinline!normallyConstant! arguments are actually constant. And one, under the assumption that all input arguments are time varying. Based on the actual arguments of the function call either of the two derivative functions is used.

This annotation is used by many functions of the \lstinline!Modelica.Fluid! library, such as\linebreak[4] \lstinline!Modelica.Fluid.Dissipation.PressureLoss.StraightPipe.dp_laminar_DP!, since geometric arguments to these functions are usually constant.
\end{nonnormative}
\end{semantics}
\end{annotationdefinition}

\section{Annotations for Simulations}\label{annotations-for-simulations}

Expand Down
53 changes: 49 additions & 4 deletions chapters/functions.tex
Expand Up @@ -1168,10 +1168,55 @@ \subsection{Casting to Record}\label{casting-to-record}

\section{Declaring Derivatives of Functions}\label{declaring-derivatives-of-functions}

Derivatives of functions can be declared explicitly using the \lstinline!derivative!
annotation, see \cref{using-the-derivative-annotation}, whereas a function can be defined as a
partial derivative of another function using the \lstinline!der!-operator in a short
function definition, see \cref{partial-derivatives-of-functions}.
The annotations listed below are related to differentiation of functions.
Partial derivatives are not provided via annotations, but using a certain type of short function definition described in \cref{partial-derivatives-of-functions}.
\begin{center}
\begin{tabular}{l|l l}
\hline
\tablehead{Annotation} & \tablehead{Description} & \tablehead{Details}\\
\hline
\hline
\lstinline!smoothOrder! & Function smoothness guarantee & \Cref{modelica:smoothOrder}\\
\lstinline!derivative! & Provide function derivative & \Cref{using-the-derivative-annotation}\\
\hline
\end{tabular}
\end{center}

\begin{annotationdefinition}[smoothOrder]
\begin{synopsis}[grammar]\begin{lstlisting}
"smoothOrder" "=" UNSIGNED-NUMBER
"smoothOrder"
"("
"normallyConstant" "=" IDENT
{ "," "normallyConstant" "=" IDENT }
")"
"=" UNSIGNED-NUMBER
\end{lstlisting}\end{synopsis}
\begin{semantics}
This annotation has only an effect within a function declaration.

\lstinline!smoothOrder! defines the number of differentiations of the function, in order that all of the differentiated outputs are continuous provided all input arguments and their derivatives up to order \lstinline!smoothOrder! are continuous.

\begin{nonnormative}
This means that the function is at least C\textsuperscript{smoothOrder}.
\lstinline!smoothOrder = 1! means that the function can be differentiated at least once in order that all output arguments are still continuous, provided the input arguments are continuous.
If a tool needs the derivative of a function, e.g.\ for index reduction or to compute an analytic Jacobian, the function can be differentiated analytically at least \lstinline!smoothOrder! times.
\end{nonnormative}

The optional argument \lstinline!normallyConstant! of \lstinline!smoothOrder! defines that the function argument \lstinline!IDENT! is usually constant.

\begin{nonnormative}
A tool might check whether the actual argument to \lstinline!IDENT! is a parameter expression at the place where the function is called.
If this is the case, the derivative of the function might be constructed under the assumption that the corresponding argument is constant, to enhance efficiency.
Typically, a tool would generate at most two different derivative functions of a function:
One, under the assumption that all \lstinline!normallyConstant! arguments are actually constant.
And one, under the assumption that all input arguments are time varying.
Based on the actual arguments of the function call either of the two derivative functions is used.

This annotation is used by many functions of the \lstinline!Modelica.Fluid! library, such as\linebreak[4] \lstinline!Modelica.Fluid.Dissipation.PressureLoss.StraightPipe.dp_laminar_DP!, since geometric arguments to these functions are usually constant.
\end{nonnormative}
\end{semantics}
\end{annotationdefinition}

\subsection{Using the Derivative Annotation}\label{using-the-derivative-annotation}

Expand Down

0 comments on commit 891f414

Please sign in to comment.