Skip to content

Commit

Permalink
Merge pull request #2960 from henrikt-ma/cleanup/constant-declaration…
Browse files Browse the repository at this point in the history
…-equation

Move and add reference to rule about constants having declaration equation
  • Loading branch information
HansOlsson committed Jun 23, 2021
2 parents 624e01e + 388081a commit a581d87
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions chapters/classes.tex
Expand Up @@ -358,6 +358,10 @@ \subsection{Component Variability Prefixes discrete, parameter, constant}\label{
not differentiable.
\end{itemize}

Components declared as \lstinline!constant! shall have an associated declaration equation with a constant expression, if the constant is directly in the simulation model, or used in the simulation model.
The value of a constant can be modified after it has been given a value, unless the constant is declared \lstinline!final! or modified with a \lstinline!final! modifier.
A constant without an associated declaration equation can be given one by using a modifier.

If a \lstinline!Real! variable is declared with the prefix \lstinline!discrete!\indexinline{discrete} it must in a simulation model be assigned in a \lstinline!when!-clause, either by an assignment or an equation.
The variable assigned in a \lstinline!when!-clause shall not be defined in a sub-component of \lstinline!model! or \lstinline!block! specialized class.
(This is to keep the property of balanced models.)
Expand Down
10 changes: 6 additions & 4 deletions chapters/equations.tex
Expand Up @@ -722,6 +722,7 @@ \section{Events and Synchronization}\label{events-and-synchronization}
verification already at compile time.
\end{nonnormative}


\section{Initialization, initial equation, and initial algorithm}\label{initialization-initial-equation-and-initial-algorithm}

Before any operation is carried out with a Modelica model (e.g., simulation or linearization), initialization takes place to assign consistent values for all variables present in the model.
Expand Down Expand Up @@ -772,16 +773,17 @@ \section{Initialization, initial equation, and initial algorithm}\label{initiali
Implicitly by using the \lstinline!start!-attribute for variables with \lstinline!fixed = true!. With \lstinline!start! given by \lstinline!startExpression!:
\begin{itemize}
\item
For a non-discrete-time \lstinline!Real! variable \lstinline!vc!, the equation \lstinline!vc = startExpression! is added to the initialization equations.
For a variable declared as \lstinline!constant! or \lstinline!parameter!, no equation is added to the initialization equations.
\item
For a discrete-time variable \lstinline!vd!, the equation \lstinline!pre(vd) = startExpression! is added to the initialization equations.
\item
For a variable declared as \lstinline!constant! or \lstinline!parameter!, no equation is added to the initialization equations.
For a non-discrete-time \lstinline!Real! variable \lstinline!vc!, the equation \lstinline!vc = startExpression! is added to the initialization equations.
\end{itemize}
\end{enumerate}

For constants and parameters, the attribute \lstinline!fixed! defaults to \lstinline!true!, which is the only allowed value for a constant. For other variables,
\lstinline!fixed! defaults to \lstinline!false!.
Constants shall be determined by declaration equations (see \cref{component-variability-prefixes-discrete-parameter-constant}), and \lstinline!fixed = false! is not allowed.
For parameters, \lstinline!fixed! defaults to \lstinline!true!.
For other variables, \lstinline!fixed! defaults to \lstinline!false!.

\lstinline!start!-values of variables having \lstinline!fixed = false! can be used as initial guesses, in case iterative solvers are used in the initialization phase.

Expand Down
2 changes: 0 additions & 2 deletions chapters/operatorsandexpressions.tex
Expand Up @@ -1436,8 +1436,6 @@ \subsection{Constant Expressions}\label{constant-expressions}
\end{itemize}
\end{itemize}

Components declared as \lstinline!constant! shall have an associated declaration equation with a constant expression, if the constant is directly in the simulation model, or used in the simulation model. The value of a constant can be modified after it has been given a value, unless the constant is declared \lstinline!final! or modified with a \lstinline!final! modifier. A constant without an associated declaration equation can be given one by using a modifier.

\subsection{Parameter Expressions}\label{parameter-expressions}

Parameter expressions\index{parameter expression}\index{expression variability!parameter}\index{parametric variability|see{parameter expression}} are:
Expand Down

0 comments on commit a581d87

Please sign in to comment.