Skip to content

Commit

Permalink
Attempt at defining initialization, and simulation. (modelica#3146)
Browse files Browse the repository at this point in the history
* Attempt at defining initialization, simulation, and avoid defining transient analysis.
* Move definition to 'Some definitions'.
* Define transient analysis and initialization.
* Do not use IVP here.
* Also define translation, since that ties together the simulation with the rest.
* Use 'transient analysis' when appropriate.
* Add more detailed description of well-determined initialization problem.
* Apply suggestions from code review
* Split non-normative paragraphs to make them closer to specific definitions.

Co-authored-by: Elena Shmoylova <eshmoylova@users.noreply.github.com>
Co-authored-by: Henrik Tidefelt <henrikt@wolfram.com>
  • Loading branch information
3 people committed Apr 28, 2022
1 parent e98a86b commit 540cfbe
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 12 deletions.
7 changes: 4 additions & 3 deletions chapters/classes.tex
Expand Up @@ -351,13 +351,14 @@ \subsection{Acyclic Bindings of Constants and Parameters}\label{acyclic-bindings

\subsection{Component Variability Prefixes}\label{component-variability-prefixes-discrete-parameter-constant}

The prefixes \lstinline!discrete!, \lstinline!parameter!, \lstinline!constant! of a component declaration are called \firstuse[variability!prefix]{variability prefixes}\index{component variability}\index{declared variability}\index{variability!declared|see{declared variability}} and define in which situation the variable values of a component are initialized (see \cref{events-and-synchronization} and \cref{initialization-initial-equation-and-initial-algorithm}) and when they are changed in transient analysis (= solution of initial value problem of the hybrid DAE):
The prefixes \lstinline!discrete!, \lstinline!parameter!, \lstinline!constant! of a component declaration are called \firstuse[variability!prefix]{variability prefixes}\index{component variability}\index{declared variability}\index{variability!declared|see{declared variability}} and define in which situation the variable values of a component are initialized (see \cref{events-and-synchronization} and \cref{initialization-initial-equation-and-initial-algorithm}) and when they are changed during simulation:
\begin{itemize}
\item
A variable \lstinline!vc! declared with \lstinline!constant!\indexinline{constant} prefix remains constant during transient analysis, with a value that is unaffected by the initialization problem.
A variable \lstinline!vc! declared with \lstinline!constant!\indexinline{constant} prefix remains constant during simulation, with a value that is unaffected even by the initialization problem.
This is called a \firstuse[---]{constant}, or \firstuse[constant!variable]{constant variable}\index{component variability!constant}.
\item
A variable \lstinline!vc! declared with the \lstinline!parameter!\indexinline{parameter} prefix remains constant during transient analysis, with a value determined by the initialization problem.
A variable \lstinline!vc! declared with the \lstinline!parameter!\indexinline{parameter} prefix has a value determined at initialization, and keeps that value during the entire simulation.
Thus it is known and non-changing during transient analysis.
This is called a \firstuse[---]{parameter}, or \firstuse[parameter!variable]{parameter variable}\index{component variability!parameter}.
\item
A \firstuse[discrete-time!variable]{discrete-time variable}\index{component variability!discrete-time} \lstinline!vd! is a variable that is discrete-valued (that is, not of \lstinline!Real! type) or assigned in a \lstinline!when!-clause.
Expand Down
6 changes: 4 additions & 2 deletions chapters/dae.tex
Expand Up @@ -98,10 +98,12 @@ \chapter{Modelica DAE Representation}\label{modelica-dae-representation}
\end{example}

The generated set of equations is used for simulation and other analysis activities.
Simulation means that an initial value problem is solved, i.e., initial values have to be provided for the states $x$, \cref{initialization-initial-equation-and-initial-algorithm}.
Simulation proceeds as follows.
First, initialization takes place, during which initial values for the states $x$ are found, \cref{initialization-initial-equation-and-initial-algorithm}.
Given those initial values the equations are simulated forward in time; this is the transient analysis.
The equations define a DAE\index{DAE} (Differential Algebraic Equations) which may have discontinuities, a variable structure and/or which are controlled by a discrete-event system.
Such types of systems are called \firstuse[hybrid DAE]{hybrid DAEs}.
Simulation is performed in the following way:
After initialization, simulation proceeds with transient analysis in the following way:
\begin{enumerate}
\item\label{perform-simulation-integrate}
The DAE \eqref{eq:dae} is solved by a numerical integration method.
Expand Down
9 changes: 5 additions & 4 deletions chapters/equations.tex
Expand Up @@ -898,9 +898,9 @@ \section{Initialization, initial equation, and initial algorithm}\label{initiali
\subsection{Equations Needed for Initialization}\label{the-number-of-equations-needed-for-initialization}\label{equations-needed-for-initialization}

\begin{nonnormative}
In general, for the case of a pure (first order) ordinary differential equation (ODE) system with $n$ state variables and $m$ output variables, we will have $n+m$ unknowns in the simulation problem.
In general, for the case of a pure (first order) ordinary differential equation (ODE) system with $n$ state variables and $m$ output variables, we will have $n+m$ unknowns during transient analysis.
The ODE initialization problem has $n$ additional unknowns corresponding to the derivative variables.
At initialization of an ODE we will need to find the values of $2n+m$ variables, in contrast to just $n+m$ variables to be solved for during simulation.
During initialization of an ODE we will need to find the values of $2n+m$ variables, in contrast to just $n+m$ variables to be solved for during transient analysis.
\end{nonnormative}

\begin{example}
Expand All @@ -912,8 +912,9 @@ \subsection{Equations Needed for Initialization}\label{the-number-of-equations-n
\end{lstlisting}

Here we have three variables with unknown values: two dynamic variables that also are state variables, \lstinline!x1! and \lstinline!x2!, i.e., $n=2$, one output variable \lstinline!y!, i.e., $m=1$, and one input variable \lstinline!u! with known value.
A consistent solution of the initial value problem providing initial values for \lstinline!x1!, \lstinline!x2!, \lstinline!der(x1)!, \lstinline!der(x2)!, and \lstinline!y! needs to be found.
Two additional initial equations thus need to be provided to solve the initialization problem.
A consistent solution of the initialization problem requires finding initial values for \lstinline!x1!, \lstinline!x2!, \lstinline!der(x1)!, \lstinline!der(x2)!, and \lstinline!y!.
Two additional initial equations thus need to be provided to obtain a globally balanced initialization problem.
Additionally, those two initial equations must be chosen with care to ensure that they, in combination with the dynamic equations, give a well-determined initialization problem.

Regarding DAEs, only that at most $n$ additional equations are needed to arrive at $2n+m$ equations in the initialization system.
The reason is that in a higher index DAE problem the number of dynamic continuous-time state variables might be less than the number of state variables $n$.
Expand Down
35 changes: 32 additions & 3 deletions chapters/introduction.tex
Expand Up @@ -68,12 +68,41 @@ \section{Some Definitions}\label{some-definitions}
\end{definition}

\begin{definition}[Flattening]\index{flattening}
The translation of a model described in Modelica to the corresponding model described as a hybrid DAE, involving expansion of inherited base classes, parameterization of base classes, local classes
and components, and generation of connection equations from \lstinline!connect!-equations (basically, mapping the hierarchical structure of a model into a set of differential, algebraic and discrete equations together with the corresponding variable declarations and function definitions from the model).
The translation of a model described in Modelica to the corresponding model described as a hybrid DAE (see \cref{modelica-dae-representation}), involving expansion of inherited base classes, parameterization of base classes, local classes and components, and generation of connection equations from \lstinline!connect!-equations.
In other words, mapping the hierarchical structure of a model into a set of differential, algebraic and discrete equations together with the corresponding variable declarations and function definitions from the model.
\end{definition}

\begin{definition}[Initialization]\index{initialization}
Simulation starts with solving the initialization problem at the starting time, resulting in values for all variables that are consistent with the result of the flattening.
\end{definition}

\begin{definition}[Transient analysis]\index{transient analysis}\index{initial value problem!see{transient analysis}}
Starting from the result of the initialization problem, the model is simulated forward in time.
This uses numerical methods for handling the hybrid DAE, resulting in solution trajectories for the model's variables, i.e., the value of the variables as a function of time.
\end{definition}

\begin{nonnormative}
In the numerical literature transient analysis is often called solving the \firstuse{initial value problem}, but that term is not used here to avoid confusion with the initialization problem.
\end{nonnormative}

\begin{definition}[Simulation]\index{simulation}
Simulation is the combination of initialization followed by transient analysis.
\end{definition}

\begin{nonnormative}
The model can be analyzed in ways other than simulation, e.g., linearization, and parameter estimation, but they are not described in the specification.
\end{nonnormative}

\begin{definition}[Translation]\index{translation}
Translation is the process of preparing a Modelica simulation model for simulation, starting with flattening but not including the simulation itself.
\end{definition}

\begin{nonnormative}
Typically, in addition to flattening, translation involves symbolic manipulation of the hybrid DAE and transforming the result into computer code that can simulate the model.
\end{nonnormative}


% More terms that would be useful to define here:
% - translation (for phrases such as "during translation")
% - deprecated
% - quality of implementation

Expand Down

0 comments on commit 540cfbe

Please sign in to comment.