Skip to content

Commit

Permalink
Say just 'inStream' instead of 'the inStream operator'
Browse files Browse the repository at this point in the history
Similarly also for actualSteram.
  • Loading branch information
henrikt-ma committed Jun 2, 2020
1 parent adb76ee commit 12e5f46
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 38 deletions.
20 changes: 9 additions & 11 deletions chapters/derivationofstream.tex
Expand Up @@ -47,11 +47,10 @@ \section{Reasons for avoiding the actual mixing enthalpy in connector definition
\end{center}
\end{figure}

\section{Rationale for the formulation of the inStream() operator}\doublelabel{rationale-for-the-formulation-of-the-instream-operator}
\section{Rationale for the formulation of \lstinline!inStream!}\doublelabel{rationale-for-the-formulation-of-the-instream-operator}

For simplicity, the derivation of the inStream() operator is shown at
hand of 3 model components that are connected together. The case for N
connections follows correspondingly.
For simplicity, the derivation of \lstinline!inStream! is shown at hand of 3 model components that are connected together.
The case for $N$ connections follows correspondingly.

The energy and mass balance equations for the connection set for 3
components are (see above):
Expand Down Expand Up @@ -150,9 +149,9 @@ \section{Rationale for the formulation of the inStream() operator}\doublelabel{r
inStream(h_{outflow,i})=\frac{\sum_{j=1,...,n;j\neq i}\text{max}(-\dot{m}_j,0)h_{outflow,j}}{\sum_{j=1,...,n;j\neq i}\text{max}(-\dot{m}_j,0)}
\end{equation*}

\section{Special cases covered by the inStream() operator definition}\doublelabel{special-cases-covered-by-the-instream-operator-definition}
\subsection{Stream connector is not connected (N=1):}\doublelabel{stream-connector-is-not-connected-n-1}
For this case, the return value of the \lstinline!inStream()! operator is arbitrary.
\section{Special cases covered by \lstinline!inStream! definition}\doublelabel{special-cases-covered-by-the-instream-operator-definition}
\subsection{Stream connector is not connected ($N = 1$):}\doublelabel{stream-connector-is-not-connected-n-1}
For this case, the return value of \lstinline!inStream! is arbitrary.
Therefore, it is set to the outflow value.

\subsection{Connection of 2 stream connectors, one to one connections (N=2):}\doublelabel{connection-of-2-stream-connectors-one-to-one-connections-n-2}
Expand All @@ -162,7 +161,7 @@ \subsection{Connection of 2 stream connectors, one to one connections (N=2):}\do
inStream(h_{outflow,2})&=&\frac{\text{max}(-\dot{m}_1,0)h_{outflow,1}}{\text{max}(-\dot{m}_1,0)}=h_{outflow,1}
\end{eqnarray*}

In this case, \lstinline!inStream()! is continuous (contrary to $h_{mix}$) and does not
In this case, \lstinline!inStream! is continuous (contrary to $h_{mix}$) and does not
depend on flow rates. The latter result means that this transformation
may remove nonlinear systems of equations, which requires that either
simplifications of the form $a * b / a = b$ must be provided, or that this
Expand Down Expand Up @@ -232,14 +231,13 @@ \subsection{Connection of 3 stream connectors where two mass flow rates are posi
inStream(h_{outflow,1})=\frac{\text{max}(-\dot{m}_2,0)h_{outflow,2}+\text{max}(-\dot{m}_3,0)h_{outflow,3}}{\text{max}(-\dot{m}_2,0)+\text{max}(-\dot{m}_3,0)}=\frac{0}{0}
\end{equation*}

The \lstinline!inStream()! operator cannot be evaluated for a connector, on which
\lstinline!inStream! cannot be evaluated for a connector, on which
the mass flow rate has to be negative by definition. The reason is that
the value is arbitrary, which is why it is defined as follows.
\begin{equation*}
inStream(h_{outflow,1}):=h_{outflow,1}
\end{equation*}
For the remaining connectors the inStream() operator reduces to a simple
result.
For the remaining connectors, \lstinline!inStream! reduces to a simple result.
\begin{eqnarray*}
inStream(h_{outflow,2})&=\frac{\text{max}(-\dot{m}_1,0)h_{outflow,1}+\text{max}(-\dot{m}_3,0)h_{outflow,3}}{\text{max}(-\dot{m}_1,0)+\text{max}(-\dot{m}_3,0)}=h_{outflow,1}\\
inStream(h_{outflow,3})&=\frac{\text{max}(-\dot{m}_1,0)h_{outflow,1}+\text{max}(-\dot{m}_2,0)h_{outflow,2}}{\text{max}(-\dot{m}_1,0)+\text{max}(-\dot{m}_2,0)}=h_{outflow,1}
Expand Down
46 changes: 19 additions & 27 deletions chapters/stream.tex
Expand Up @@ -51,10 +51,8 @@ \section{Definition of Stream Connectors}\doublelabel{definition-of-stream-conne
For inside connectors (see \autoref{inside-and-outside-connectors}), variables
with the \lstinline!stream! prefix do not lead to connection equations.
\item
Connection equations with stream variables are generated in a model
when using the \lstinline!inStream()! operator or the
\lstinline!actualStream()! operator, see \autoref{stream-operator-instream-and-connection-equations}
and \autoref{stream-operator-actualstream}.
Connection equations with stream variables are generated in a model when using \lstinline!inStream! or \lstinline!actualStream!,
see \autoref{stream-operator-instream-and-connection-equations} and \autoref{stream-operator-actualstream}.
\end{itemize}

\begin{example}
Expand All @@ -76,16 +74,15 @@ \section{Definition of Stream Connectors}\doublelabel{definition-of-stream-conne
\lstinline!X_outflow! are the stream properties inside the component close to the
boundary, when fluid flows out of the component into the connection
point. The stream properties for the other flow direction can be
inquired with the built-in operator \lstinline!inStream()!. The value of
inquired with the built-in \lstinline!inStream!. The value of
the stream variable corresponding to the actual flow direction can be
inquired through the built-in operator \lstinline!actualStream()!, see
inquired through the built-in \lstinline!actualStream!, see
\autoref{stream-operator-actualstream}.
\end{example}

\section{Stream Operator inStream and Connection Equations}\doublelabel{stream-operator-instream-and-connection-equations}

In combination with the stream variables of a connector, the
\lstinline!inStream()! operator is designed to describe in a numerically
In combination with the stream variables of a connector, \lstinline!inStream! is designed to describe in a numerically
reliable way the bi-directional transport of specific quantities carried
by a flow of matter.

Expand Down Expand Up @@ -152,13 +149,11 @@ \section{Stream Operator inStream and Connection Equations}\doublelabel{stream-o
0 = sum($m_{j}$.c.m_flow for j in 1:N) + sum(-$c_{k}$.m_flow for k in 1:M);
\end{lstlisting}

Whenever the \lstinline!inStream()! operator is applied to a stream
variable of an inside connector, the balance equation of the transported
property must be added under the assumption of flow going into the
connector
Whenever \lstinline!inStream! is applied to a stream variable of an inside connector, the balance equation of the transported
property must be added under the assumption of flow going into the connector

\begin{lstlisting}[language=modelica,mathescape=true]
// Implicit definition of the inStream() operator applied to inside connector $i$
// Implicit definition of inStream applied to inside connector $i$
0 =
sum($m_{j}$.c.m_flow *
(if $m_{j}$.c.m_flow > 0 or $j$==$i$ then $\mathit{h\_mix\_in}_{i}$ else $m_{j}$.c.h_outflow)
Expand Down Expand Up @@ -220,8 +215,8 @@ \section{Stream Operator inStream and Connection Equations}\doublelabel{stream-o
to compute it.
\end{nonnormative}

If the argument of \lstinline!inStream()! is an array, the implicit
equation system holds elementwise, i.e., \lstinline!inStream()! is
If the argument of \lstinline!inStream! is an array, the implicit
equation system holds elementwise, i.e., \lstinline!inStream! is
vectorizable.

The stream connection equations have singularities and/or multiple
Expand All @@ -233,11 +228,8 @@ \section{Stream Operator inStream and Connection Equations}\doublelabel{stream-o
For example, assume that \lstinline[mathescape=true]!$m_{j}$.c.m_flow = $c_{k}$.m_flow = 0!, then all equations above are identically fulfilled and \lstinline!inStream(..)! can have any value.
\end{nonnormative}

However, specific optimizations may be applied to avoid the regularization if the
flow through one port is zero or non-negative, see \autoref{derivation-of-stream-equations}. It is
required that the \lstinline!inStream()! operator is appropriately
approximated when regularization is needed and the approximation must
fulfill the following requirements:
However, specific optimizations may be applied to avoid the regularization if the flow through one port is zero or non-negative, see \autoref{derivation-of-stream-equations}.
It is required that \lstinline!inStream! is appropriately approximated when regularization is needed and the approximation must fulfill the following requirements:
\begin{enumerate}
\item
\lstinline[mathescape=true]!inStream($m_{i}$.c.h_outflow)! and
Expand Down Expand Up @@ -333,7 +325,7 @@ \section{Stream Operator inStream and Connection Equations}\doublelabel{stream-o
values.
\end{itemize}

Trivial implementation of \lstinline!positiveMax! guarantees continuity of \lstinline!inStream()!:
Trivial implementation of \lstinline!positiveMax! guarantees continuity of \lstinline!inStream!:
\begin{lstlisting}[language=modelica,mathescape=true]
postiveMax(-$m_j$.c.m_flow, $s_i$) = max(-$m_j$.c.m_flow, $\mathit{eps1}$); // so $s_i$ is not needed
\end{lstlisting}
Expand All @@ -355,7 +347,7 @@ \section{Stream Operator inStream and Connection Equations}\doublelabel{stream-o
The derivation of this implementation is discussed in
\autoref{derivation-of-stream-equations}. Note that in the cases N = 1, M =0 (unconnected port,
physically corresponding to a plugged-up flange), and N = 2, M=0
(one-to-one connection), the result of \lstinline!inStream()! is trivial
(one-to-one connection), the result of \lstinline!inStream! is trivial
and no non-linear equations are left in the model, despite the fact that
the original definition equations are nonlinear.

Expand Down Expand Up @@ -419,9 +411,9 @@ \section{Stream Operator actualStream}\doublelabel{stream-operator-actualstream}
der(U) = c.m_flow*actualStream(c.h_outflow); // (1) energy balance equation
h_c = actualStream(c.h); // (2) monitoring the enthalpy at port c
\end{lstlisting}
In the case of equation (1), although the \lstinline!actualStream()! operator
In the case of equation (1), although \lstinline!actualStream!
is discontinuous, the product with the flow variable is not, because
\lstinline!actualStream()! is discontinuous when the flow is zero by construction.
\lstinline!actualStream! is discontinuous when the flow is zero by construction.
Therefore, a tool might infer that the expression is \lstinline!smooth(0, ...)!
automatically, and decide whether or not to generate an event. If a user
wants to avoid events entirely, he/she may enclose the right-hand side
Expand All @@ -433,10 +425,10 @@ \section{Stream Operator actualStream}\doublelabel{stream-operator-actualstream}
see the change due to flow reversal at the exact instant, so an event
should be generated. If the user doesn't bother, then he/she should
enclose the right-hand side of (2) with \lstinline!noEvent()!. Since the output of
\lstinline!actualStream()! will be discontinuous, it should not be used by itself to
\lstinline!actualStream! will be discontinuous, it should not be used by itself to
model physical behaviour (e.g., to compute densities used in momentum
balances) --- \lstinline!inStream()! should be used for this purpose. The operator
\lstinline!actualStream()! should be used to model physical behaviour only when
balances) --- \lstinline!inStream! should be used for this purpose.
\lstinline!actualStream! should be used to model physical behaviour only when
multiplied by the corresponding flow variable (like in the above energy
balance equation), because this removes the discontinuity.
\end{nonnormative}

0 comments on commit 12e5f46

Please sign in to comment.