TwoPortsTwoPorts Icon

TwoPorts

A base model for generic two-port fluid dynamic components.

This partial component establishes the common interface and conservation laws for elements with two fluid connection ports. It defines the pressure difference across these ports, denoted as $\Delta p$, and ensures the conservation of mass flow. Key relationships include:

Mass Conservation:

\[port\_a.m\_flow + port\_b.m\_flow = 0\]

This equation signifies that the sum of mass flow rates at the two ports is zero, adhering to the convention where flow into the component is positive at one port and negative (outflow) at the other, or vice-versa.

Pressure Difference:

\[\Delta p = port\_a.p - port\_b.p\]

This defines the pressure drop from port_a to port_b.

Additionally, a continuity relation (continuity(port_a.medium, port_b.medium)) ensures that the medium properties are consistent between the ports. Being a partial component, it is designed as a base for more specialized two-port device models.

Usage

HydraulicComponents.TwoPorts()

Connectors

Variables

NameDescriptionUnits
ΔpPressure difference across the component, defined as porta.p - portb.pPa
m_flowOverall mass flow rate through the componentkg/s

Source

"""
A base model for generic two-port fluid dynamic components.

This partial component establishes the common interface and conservation laws for elements with two fluid connection ports.
It defines the pressure difference across these ports, denoted as $\Delta p$, and ensures the conservation of mass flow.
Key relationships include:

Mass Conservation:

math port_a.m_flow + port_b.m_flow = 0

This equation signifies that the sum of mass flow rates at the two ports is zero, adhering to the convention where flow into the component is positive at one port and negative (outflow) at the other, or vice-versa.

Pressure Difference:

math \Delta p = port_a.p - port_b.p

This defines the pressure drop from `port_a` to `port_b`.

Additionally, a `continuity` relation (`continuity(port_a.medium, port_b.medium)`) ensures that the medium properties are consistent between the ports.
Being a `partial` component, it is designed as a base for more specialized two-port device models.
"""</span>
<span class="hljs-keyword">partial</span> <span class="hljs-keyword">component</span> TwoPorts
&nbsp;&nbsp;<span class="hljs-comment">"The first fluid port of the component"</span>
&nbsp;&nbsp;<span class="hljs-symbol">port_a</span> = <span class="hljs-link"><a href="https://help.juliahub.com/dyad/dev/stdlib/HydraulicComponents/connectors/Port.html">Port</a></span>() {
&nbsp;&nbsp;&nbsp;&nbsp;"Dyad": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"placement": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"diagram": {"x1": -20, "x2": 20, "y1": 480, "y2": 520, "sh": 1, "sw": 1, "rot": 0}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}
&nbsp;&nbsp;<span class="hljs-comment">"The second fluid port of the component"</span>
&nbsp;&nbsp;<span class="hljs-symbol">port_b</span> = <span class="hljs-link"><a href="https://help.juliahub.com/dyad/dev/stdlib/HydraulicComponents/connectors/Port.html">Port</a></span>() {
&nbsp;&nbsp;&nbsp;&nbsp;"Dyad": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"placement": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"diagram": {"x1": 980, "x2": 1020, "y1": 480, "y2": 520, "sh": 0.04, "sw": 0.04, "rot": 0}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}
&nbsp;&nbsp;<span class="hljs-comment">"Pressure difference across the component, defined as port_a.p - port_b.p"</span>
&nbsp;&nbsp;<span class="hljs-keyword">variable</span> <span class="hljs-symbol">Δp</span>::<span class="hljs-link"><a href="https://help.juliahub.com/dyad/dev/stdlib/Dyad/types/AbsolutePressure.html">AbsolutePressure</a></span>
&nbsp;&nbsp;<span class="hljs-comment">"Overall mass flow rate through the component"</span>
&nbsp;&nbsp;<span class="hljs-keyword">variable</span> <span class="hljs-symbol">m_flow</span>::<span class="hljs-link"><a href="https://help.juliahub.com/dyad/dev/stdlib/Dyad/types/MassFlowRate.html">MassFlowRate</a></span>
<span class="hljs-keyword">relations</span>
&nbsp;&nbsp;<span class="hljs-built_in">continuity</span>(port_a.medium, port_b.medium)
&nbsp;&nbsp;port_a.m_flow + port_b.m_flow = 0
&nbsp;&nbsp;Δp = port_a.p - port_b.p
<span class="hljs-keyword">end</span></code></pre>
Flattened Source
"""
A base model for generic two-port fluid dynamic components.

This partial component establishes the common interface and conservation laws for elements with two fluid connection ports.
It defines the pressure difference across these ports, denoted as $\Delta p$, and ensures the conservation of mass flow.
Key relationships include:

Mass Conservation:

math port_a.m_flow + port_b.m_flow = 0

This equation signifies that the sum of mass flow rates at the two ports is zero, adhering to the convention where flow into the component is positive at one port and negative (outflow) at the other, or vice-versa.

Pressure Difference:

math \Delta p = port_a.p - port_b.p

This defines the pressure drop from `port_a` to `port_b`.

Additionally, a `continuity` relation (`continuity(port_a.medium, port_b.medium)`) ensures that the medium properties are consistent between the ports.
Being a `partial` component, it is designed as a base for more specialized two-port device models.
"""</span>
<span class="hljs-keyword">partial</span> <span class="hljs-keyword">component</span> TwoPorts
&nbsp;&nbsp;<span class="hljs-comment">"The first fluid port of the component"</span>
&nbsp;&nbsp;<span class="hljs-symbol">port_a</span> = <span>Port</span>() {
&nbsp;&nbsp;&nbsp;&nbsp;"Dyad": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"placement": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"diagram": {"x1": -20, "x2": 20, "y1": 480, "y2": 520, "sh": 1, "sw": 1, "rot": 0}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}
&nbsp;&nbsp;<span class="hljs-comment">"The second fluid port of the component"</span>
&nbsp;&nbsp;<span class="hljs-symbol">port_b</span> = <span>Port</span>() {
&nbsp;&nbsp;&nbsp;&nbsp;"Dyad": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"placement": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"diagram": {"x1": 980, "x2": 1020, "y1": 480, "y2": 520, "sh": 0.04, "sw": 0.04, "rot": 0}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}
&nbsp;&nbsp;<span class="hljs-comment">"Pressure difference across the component, defined as port_a.p - port_b.p"</span>
&nbsp;&nbsp;<span class="hljs-keyword">variable</span> <span class="hljs-symbol">Δp</span>::<span>AbsolutePressure</span>
&nbsp;&nbsp;<span class="hljs-comment">"Overall mass flow rate through the component"</span>
&nbsp;&nbsp;<span class="hljs-keyword">variable</span> <span class="hljs-symbol">m_flow</span>::<span>MassFlowRate</span>
<span class="hljs-keyword">relations</span>
&nbsp;&nbsp;<span class="hljs-built_in">continuity</span>(port_a.medium, port_b.medium)
&nbsp;&nbsp;port_a.m_flow + port_b.m_flow = 0
&nbsp;&nbsp;Δp = port_a.p - port_b.p
<span class="hljs-keyword">metadata</span> {}
<span class="hljs-keyword">end</span></code></pre>


Test Cases

No test cases defined.

  • Examples
  • Experiments
  • Analyses