Skip to content

Commit

Permalink
Clarify elsewhen initial
Browse files Browse the repository at this point in the history
Closes #2636
  • Loading branch information
HansOlsson committed Sep 4, 2020
1 parent acde0ad commit 75fbac2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion chapters/equations.tex
Expand Up @@ -748,7 +748,7 @@ \section{Initialization, initial equation, and initial algorithm}\label{initiali
(such as simulation or linearization).

The equations of a when-clause are active during initialization, if and only if they are explicitly enabled with \lstinline!initial()!, and only in one of the two forms
\lstinline!when initial() then! or \lstinline!when {$\ldots$, initial(), $\ldots$} then! (and similarly for algorithms see below). In this case, the when-clause equations remain active during the
\lstinline!when initial() then! or \lstinline!when {$\ldots$, initial(), $\ldots$} then! (and similarly for \lstinline!elsewhen! and algorithms see below). In this case, the when-clause equations remain active during the
whole initialization phase. In case of a \lstinline!reinit(x, expr)! being active during initialization (due to being inside \lstinline!when initial()!) this is interpreted as adding
\lstinline!x = expr! (the \lstinline!reinit!-equation) as an initial equation.

Expand All @@ -762,6 +762,15 @@ \section{Initialization, initial equation, and initial algorithm}\label{initiali
\lstinline!when initial() then! or \lstinline!when {$\ldots$, initial(), $\ldots$} then!. In this case, the algorithmic statements within the when-statement remain active during the whole
initialization phase.

An active when-clause inactivates the following \lstinline!elsewhen! (similarly as for when-clauses during simulation), but apart from that
the first \lstinline!elsewhen initial() then! or \lstinline!elsewhen {$\ldots$, initial(), $\ldots$} then! is similarly active during initialization as
\lstinline!when initial() then! or \lstinline!when {$\ldots$, initial(), $\ldots$} then!.

\begin{nonnormative}
That means that any subsequent \lstinline!elsewhen initial()! has no effect,
similarly as \lstinline!when false then!.
\end{nonnormative}

\begin{nonnormative}
There is no special handling of inactive when-statements during initialization, instead
variables assigned in when-statements are initialized using \lstinline!v := pre(v)!
Expand Down

0 comments on commit 75fbac2

Please sign in to comment.