This information is part of the Modelica Standard Library maintained by the Modelica Association.
Returns the mixing value of a stream variable if it flows into the component where the inStream operator is used.
For an introduction into stream variables and an example for the inStream(..) operator, see stream.
IDENT must be a variable reference in a connector component declared with the
In combination with the stream variables of a connector, the inStream() operator is designed to describe in a numerically reliable way the bi-directional transport of specific quantities carried by a flow of matter. inStream(v) is only allowed on stream variables v and is informally the value the stream variable has, assuming that the flow is from the connection point into the component. This value is computed from the stream connection equations of the flow variables and of the stream variables. For the following definition it is assumed that N inside connectors mj.c (j=1,2,...,N) and M outside connectors ck(k=1,2,...,M) belonging to the same connection set are connected together and a stream variable h_outflow is associated with a flow variable m_flow in connector c.
connector FluidPort ... flow Real m_flow "Flow of matter; m_flow > 0 if flow into component"; stream Real h_outflow "Specific variable in component if m_flow < 0" end FluidPort; model FluidSystem ... FluidComponent m1, m2, ..., mN; FluidPort c1, c2, ..., cM; equation connect(m1.c, m2.c); connect(m1.c, m3.c); ... connect(m1.c, mN.c); connect(m1.c, c1); connect(m1.c, c2); ... connect(m1.c, cM); ... end FluidSystem;
With these prerequisites, the semantics of the expression
is given implicitly by defining an additional variable h_mix_ini, and by adding to the model the conservation equations for mass and energy corresponding to the infinitesimally small volume spanning the connection set. The connect equation for the flow variables has already been added to the system according to the connection semantics of flow variables:
// Standard connection equation for flow variables 0 = sum(mj.c.m_flow for j in 1:N) + sum(-ck.m_flow for k in 1:M);
Whenever the 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
// Implicit definition of the inStream() operator applied to inside connector i 0 = sum(mj.c.m_flow*(if mj.c.m_flow > 0 or j==i then h_mix_ini else mj.c.h_outflow) for j in 1:N) + sum(-ck.m_flow* (if ck.m_flow > 0 then h_mix_ini else inStream(ck.h_outflow) for k in 1:M); inStream(mi.c.h_outflow) = h_mix_ini;
Note that the result of the inStream(mi.c.h_outflow) operator is different for each port i, because the assumption of flow entering the port is different for each of them. Additional equations need to be generated for the stream variables of outside connectors.
// Additional connection equations for outside connectors for q in 1:M loop 0 = sum(mj.c.m_flow*(if mj.c.m_flow > 0 then h_mix_outq else mj.c.h_outflow) for j in 1:N) + sum(-ck.m_flow* (if ck.m_flow > 0 or k==q then h_mix_outq else inStream(ck.h_outflow) for k in 1:M); cq.h_outflow = h_mix_outq; end for;
Neglecting zero flow conditions, the above implicit equations can be analytically solved for the inStream(..) operators. The details are given in Section 15.2 of the Modelica Language Specification version 3.2 Revision 1. The stream connection equations have singularities and/or multiple solutions if one or more of the flow variables become zero. When all the flows are zero, a singularity is always present, so it is necessary to approximate the solution in an open neighborhood of that point. [For example assume that mj.c.m_flow = ck.m_flow = 0, then all equations above are identically fulfilled and inStream(..) can have any value]. It is required that the inStream() operator is appropriately approximated in that case and the approximation must fulfill the following requirements:
In Section 15.2 a recommended implementation of the solution of the implicit equation system is given, that fulfills the above requirements.