LIBRARY
Examples.BranchingDynamicPipes ​
Branching network of dynamic pipes with a pressure step at the upper boundary.
The topology, elevations, and pipe model structures follow Modelica.Fluid.Examples.BranchingDynamicPipes. This implementation uses the currently supported constant-property liquid-water medium, nominal laminar flow model, and constant heat-transfer correlation. Momentum is algebraically steady-state, while the energy balances remain dynamic.
Usage ​
FluidComponents.Examples.BranchingDynamicPipes(T_start=293.15, h_start=83680, pressure_step_time=2, p_boundary4_initial=100000, p_boundary4_final=200000, Q_flow_pipe2=200)
Parameters: ​
| Name | Description | Units | Default value |
|---|---|---|---|
medium_data | – | MediaCompon...WaterData() | |
nNodes | – | 5 | |
T_start | K | 293.15 | |
h_start | J/kg | 83680 | |
pressure_step_time | s | 2 | |
p_boundary4_initial | Pa | 100000 | |
p_boundary4_final | Pa | 200000 | |
Q_flow_pipe2 | W | 200 |
Variables ​
| Name | Description | Units |
|---|---|---|
p_boundary4 | Pa | |
m_flow_pipe1 | kg/s | |
m_flow_pipe2 | kg/s | |
m_flow_pipe3 | kg/s | |
m_flow_pipe4 | kg/s | |
p_split | Pa | |
p_merge | Pa | |
T_pipe2_out | K |
Behavior ​
Source ​
dyad
"""
Branching network of dynamic pipes with a pressure step at the upper boundary.
The topology, elevations, and pipe model structures follow
Modelica.Fluid.Examples.BranchingDynamicPipes. This implementation uses the
currently supported constant-property liquid-water medium, nominal laminar
flow model, and constant heat-transfer correlation. Momentum is algebraically
steady-state, while the energy balances remain dynamic.
"""
component BranchingDynamicPipes
"Fixed-pressure boundary below the pipe network."
boundary1 = FluidComponents.Sources.Boundary_pT(medium_data = medium_data, nPorts = 1, p = 150000, T = T_start) {
"Dyad": {"placement": {"diagram": {"x1": 30, "x2": 130, "y1": 240, "y2": 340}}}
}
"Lower common pipe."
pipe1 = FluidComponents.Pipes.DynamicPipe(medium_data = medium_data, nNodes = nNodes, modelStructure = FluidComponents.Types.ModelStructure.a_v_b(), allowFlowReversal = true, energyDynamics = FluidComponents.Types.Dynamics.DynamicFreeInitial(), massDynamics = FluidComponents.Types.Dynamics.SteadyStateInitial(), momentumDynamics = FluidComponents.Types.Dynamics.SteadyState(), p_a_start = 150000, p_b_start = 130000, use_T_start = true, T_start = T_start, h_start = h_start, m_flow_start = 0.02, nParallel = 1, dp_nominal = 20000, m_flow_nominal = 0.02, length = 50, isCircular = true, diameter = 0.0254, roughness = 2.5e-5, height_ab = 50, use_HeatTransfer = false, alpha0 = 0, k = 0, T_ambient = T_start) {
"Dyad": {"placement": {"diagram": {"x1": 160, "x2": 260, "y1": 240, "y2": 340}}}
}
"Heated branch with pressure states exposed at both ports."
pipe2 = FluidComponents.Pipes.DynamicPipe(medium_data = medium_data, nNodes = nNodes, modelStructure = FluidComponents.Types.ModelStructure.av_vb(), allowFlowReversal = true, energyDynamics = FluidComponents.Types.Dynamics.DynamicFreeInitial(), massDynamics = FluidComponents.Types.Dynamics.SteadyStateInitial(), momentumDynamics = FluidComponents.Types.Dynamics.SteadyState(), p_a_start = 130000, p_b_start = 120000, use_T_start = true, T_start = T_start, h_start = h_start, m_flow_start = 0.01, nParallel = 1, dp_nominal = 10000, m_flow_nominal = 0.01, length = 50, isCircular = true, diameter = 0.0254, roughness = 2.5e-5, height_ab = 25, use_HeatTransfer = true, alpha0 = 1000, k = 0, T_ambient = T_start) {
"Dyad": {"placement": {"diagram": {"x1": 290, "x2": 390, "y1": 120, "y2": 220}}}
}
"Unheated parallel branch."
pipe3 = FluidComponents.Pipes.DynamicPipe(medium_data = medium_data, nNodes = nNodes, modelStructure = FluidComponents.Types.ModelStructure.a_v_b(), allowFlowReversal = true, energyDynamics = FluidComponents.Types.Dynamics.DynamicFreeInitial(), massDynamics = FluidComponents.Types.Dynamics.SteadyStateInitial(), momentumDynamics = FluidComponents.Types.Dynamics.SteadyState(), p_a_start = 130000, p_b_start = 120000, use_T_start = true, T_start = T_start, h_start = h_start, m_flow_start = 0.01, nParallel = 1, dp_nominal = 10000, m_flow_nominal = 0.01, length = 25, isCircular = true, diameter = 0.0254, roughness = 2.5e-5, height_ab = 25, use_HeatTransfer = false, alpha0 = 0, k = 0, T_ambient = T_start) {
"Dyad": {"placement": {"diagram": {"x1": 290, "x2": 390, "y1": 240, "y2": 340}}}
}
"Upper common pipe."
pipe4 = FluidComponents.Pipes.DynamicPipe(medium_data = medium_data, nNodes = nNodes, modelStructure = FluidComponents.Types.ModelStructure.a_v_b(), allowFlowReversal = true, energyDynamics = FluidComponents.Types.Dynamics.DynamicFreeInitial(), massDynamics = FluidComponents.Types.Dynamics.SteadyStateInitial(), momentumDynamics = FluidComponents.Types.Dynamics.SteadyState(), p_a_start = 120000, p_b_start = 100000, use_T_start = true, T_start = T_start, h_start = h_start, m_flow_start = 0.02, nParallel = 1, dp_nominal = 20000, m_flow_nominal = 0.02, length = 50, isCircular = true, diameter = 0.0254, roughness = 2.5e-5, height_ab = 50, use_HeatTransfer = false, alpha0 = 0, k = 0, T_ambient = T_start) {
"Dyad": {"placement": {"diagram": {"x1": 420, "x2": 520, "y1": 240, "y2": 340}}}
}
"Signal-driven pressure boundary above the pipe network."
boundary4 = FluidComponents.Sources.Boundary_pT(medium_data = medium_data, nPorts = 1, use_p_in = true, p = p_boundary4_initial, T = T_start) {
"Dyad": {"placement": {"diagram": {"x1": 555, "x2": 655, "y1": 140, "y2": 240}}}
}
"Fixed heat-flow sources distributed over pipe2."
heat2 = [ThermalComponents.Sources.FixedHeatFlow(Q_flow = Q_flow_pipe2 * pipe2.dxs[i], T_ref = T_start, alpha = -0.01) for i in 1:nNodes] {
"Dyad": {"placement": {"diagram": {"x1": 160, "x2": 260, "y1": 20, "y2": 120}}}
}
# Concrete medium selected when the example is constructed [-]
structural parameter medium_data::MediaComponents.Interfaces.AbstractPartialMediumData = MediaComponents.Water.ConstantPropertyLiquidWaterData()
# Number of finite volumes in each pipe [-]
structural parameter nNodes::Integer(min = 2) = 5
# Initial fluid temperature [K]
parameter T_start::Temperature = 293.15
# Initial specific enthalpy [J/kg]
parameter h_start::MediaComponents.Types.SpecificEnthalpy = 83680
# Time of the upper-boundary pressure step [s]
parameter pressure_step_time::Time = 2
# Initial upper-boundary pressure [Pa]
parameter p_boundary4_initial::MediaComponents.Types.AbsolutePressure = 100000
# Final upper-boundary pressure [Pa]
parameter p_boundary4_final::MediaComponents.Types.AbsolutePressure = 200000
# Total fixed heat flow supplied along pipe2 [W]
parameter Q_flow_pipe2::HeatFlowRate = 200
# Upper-boundary pressure command [Pa]
variable p_boundary4::MediaComponents.Types.AbsolutePressure
# Mass flow through the lower common pipe [kg/s]
variable m_flow_pipe1::MediaComponents.Types.MassFlowRate
# Mass flow through the heated branch [kg/s]
variable m_flow_pipe2::MediaComponents.Types.MassFlowRate
# Mass flow through the unheated branch [kg/s]
variable m_flow_pipe3::MediaComponents.Types.MassFlowRate
# Mass flow through the upper common pipe [kg/s]
variable m_flow_pipe4::MediaComponents.Types.MassFlowRate
# Pressure at the branch split [Pa]
variable p_split::MediaComponents.Types.AbsolutePressure
# Pressure at the branch merge [Pa]
variable p_merge::MediaComponents.Types.AbsolutePressure
# Outlet temperature of the heated branch [K]
variable T_pipe2_out::Temperature
relations
connect(boundary1.ports[1], pipe1.port_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
connect(pipe1.port_b, pipe2.port_a) {
"Dyad": {
"edges": [{"S": 1, "M": [], "E": -1}, {"S": -1, "M": [{"x": 275, "y": 170}], "E": 2}],
"junctions": [{"x": 275, "y": 290}],
"path": {}
}
}
connect(pipe1.port_b, pipe3.port_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
connect(pipe2.port_b, pipe4.port_a) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 405, "y": 170}], "E": -1}, {"S": -1, "M": [], "E": 2}],
"junctions": [{"x": 405, "y": 290}],
"path": {}
}
}
connect(pipe3.port_b, pipe4.port_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
connect(pipe4.port_b, boundary4.ports[1]) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 670, "y": 290}, {"x": 670, "y": 190}], "E": 2}],
"path": {}
}
}
for i in 1:nNodes
connect(heat2[i].port, pipe2.heatPorts[i]) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 340.5, "y": 70}], "E": 2}], "path": {}}
}
end
for i in 1:nNodes
# Workaround: MTK selects stored energies during index reduction. Initializing
# their derivatives directly avoids non-isolated der(T) equations while
# retaining the steady-state energy initialization of the Modelica example.
initial der(pipe1.Us[i]) = 0
initial der(pipe2.Us[i]) = 0
initial der(pipe3.Us[i]) = 0
initial der(pipe4.Us[i]) = 0
end
p_boundary4 = time < pressure_step_time ? p_boundary4_initial : p_boundary4_final
boundary4.p_in = p_boundary4
m_flow_pipe1 = pipe1.port_a.m_flow
m_flow_pipe2 = pipe2.port_a.m_flow
m_flow_pipe3 = pipe3.port_a.m_flow
m_flow_pipe4 = pipe4.port_a.m_flow
p_split = pipe1.port_b.p
p_merge = pipe4.port_a.p
T_pipe2_out = pipe2.mediums[nNodes].T
endFlattened Source
dyad
"""
Branching network of dynamic pipes with a pressure step at the upper boundary.
The topology, elevations, and pipe model structures follow
Modelica.Fluid.Examples.BranchingDynamicPipes. This implementation uses the
currently supported constant-property liquid-water medium, nominal laminar
flow model, and constant heat-transfer correlation. Momentum is algebraically
steady-state, while the energy balances remain dynamic.
"""
component BranchingDynamicPipes
"Fixed-pressure boundary below the pipe network."
boundary1 = FluidComponents.Sources.Boundary_pT(medium_data = medium_data, nPorts = 1, p = 150000, T = T_start) {
"Dyad": {"placement": {"diagram": {"x1": 30, "x2": 130, "y1": 240, "y2": 340}}}
}
"Lower common pipe."
pipe1 = FluidComponents.Pipes.DynamicPipe(medium_data = medium_data, nNodes = nNodes, modelStructure = FluidComponents.Types.ModelStructure.a_v_b(), allowFlowReversal = true, energyDynamics = FluidComponents.Types.Dynamics.DynamicFreeInitial(), massDynamics = FluidComponents.Types.Dynamics.SteadyStateInitial(), momentumDynamics = FluidComponents.Types.Dynamics.SteadyState(), p_a_start = 150000, p_b_start = 130000, use_T_start = true, T_start = T_start, h_start = h_start, m_flow_start = 0.02, nParallel = 1, dp_nominal = 20000, m_flow_nominal = 0.02, length = 50, isCircular = true, diameter = 0.0254, roughness = 2.5e-5, height_ab = 50, use_HeatTransfer = false, alpha0 = 0, k = 0, T_ambient = T_start) {
"Dyad": {"placement": {"diagram": {"x1": 160, "x2": 260, "y1": 240, "y2": 340}}}
}
"Heated branch with pressure states exposed at both ports."
pipe2 = FluidComponents.Pipes.DynamicPipe(medium_data = medium_data, nNodes = nNodes, modelStructure = FluidComponents.Types.ModelStructure.av_vb(), allowFlowReversal = true, energyDynamics = FluidComponents.Types.Dynamics.DynamicFreeInitial(), massDynamics = FluidComponents.Types.Dynamics.SteadyStateInitial(), momentumDynamics = FluidComponents.Types.Dynamics.SteadyState(), p_a_start = 130000, p_b_start = 120000, use_T_start = true, T_start = T_start, h_start = h_start, m_flow_start = 0.01, nParallel = 1, dp_nominal = 10000, m_flow_nominal = 0.01, length = 50, isCircular = true, diameter = 0.0254, roughness = 2.5e-5, height_ab = 25, use_HeatTransfer = true, alpha0 = 1000, k = 0, T_ambient = T_start) {
"Dyad": {"placement": {"diagram": {"x1": 290, "x2": 390, "y1": 120, "y2": 220}}}
}
"Unheated parallel branch."
pipe3 = FluidComponents.Pipes.DynamicPipe(medium_data = medium_data, nNodes = nNodes, modelStructure = FluidComponents.Types.ModelStructure.a_v_b(), allowFlowReversal = true, energyDynamics = FluidComponents.Types.Dynamics.DynamicFreeInitial(), massDynamics = FluidComponents.Types.Dynamics.SteadyStateInitial(), momentumDynamics = FluidComponents.Types.Dynamics.SteadyState(), p_a_start = 130000, p_b_start = 120000, use_T_start = true, T_start = T_start, h_start = h_start, m_flow_start = 0.01, nParallel = 1, dp_nominal = 10000, m_flow_nominal = 0.01, length = 25, isCircular = true, diameter = 0.0254, roughness = 2.5e-5, height_ab = 25, use_HeatTransfer = false, alpha0 = 0, k = 0, T_ambient = T_start) {
"Dyad": {"placement": {"diagram": {"x1": 290, "x2": 390, "y1": 240, "y2": 340}}}
}
"Upper common pipe."
pipe4 = FluidComponents.Pipes.DynamicPipe(medium_data = medium_data, nNodes = nNodes, modelStructure = FluidComponents.Types.ModelStructure.a_v_b(), allowFlowReversal = true, energyDynamics = FluidComponents.Types.Dynamics.DynamicFreeInitial(), massDynamics = FluidComponents.Types.Dynamics.SteadyStateInitial(), momentumDynamics = FluidComponents.Types.Dynamics.SteadyState(), p_a_start = 120000, p_b_start = 100000, use_T_start = true, T_start = T_start, h_start = h_start, m_flow_start = 0.02, nParallel = 1, dp_nominal = 20000, m_flow_nominal = 0.02, length = 50, isCircular = true, diameter = 0.0254, roughness = 2.5e-5, height_ab = 50, use_HeatTransfer = false, alpha0 = 0, k = 0, T_ambient = T_start) {
"Dyad": {"placement": {"diagram": {"x1": 420, "x2": 520, "y1": 240, "y2": 340}}}
}
"Signal-driven pressure boundary above the pipe network."
boundary4 = FluidComponents.Sources.Boundary_pT(medium_data = medium_data, nPorts = 1, use_p_in = true, p = p_boundary4_initial, T = T_start) {
"Dyad": {"placement": {"diagram": {"x1": 555, "x2": 655, "y1": 140, "y2": 240}}}
}
"Fixed heat-flow sources distributed over pipe2."
heat2 = [ThermalComponents.Sources.FixedHeatFlow(Q_flow = Q_flow_pipe2 * pipe2.dxs[i], T_ref = T_start, alpha = -0.01) for i in 1:nNodes] {
"Dyad": {"placement": {"diagram": {"x1": 160, "x2": 260, "y1": 20, "y2": 120}}}
}
# Concrete medium selected when the example is constructed [-]
structural parameter medium_data::MediaComponents.Interfaces.AbstractPartialMediumData = MediaComponents.Water.ConstantPropertyLiquidWaterData()
# Number of finite volumes in each pipe [-]
structural parameter nNodes::Integer(min = 2) = 5
# Initial fluid temperature [K]
parameter T_start::Temperature = 293.15
# Initial specific enthalpy [J/kg]
parameter h_start::MediaComponents.Types.SpecificEnthalpy = 83680
# Time of the upper-boundary pressure step [s]
parameter pressure_step_time::Time = 2
# Initial upper-boundary pressure [Pa]
parameter p_boundary4_initial::MediaComponents.Types.AbsolutePressure = 100000
# Final upper-boundary pressure [Pa]
parameter p_boundary4_final::MediaComponents.Types.AbsolutePressure = 200000
# Total fixed heat flow supplied along pipe2 [W]
parameter Q_flow_pipe2::HeatFlowRate = 200
# Upper-boundary pressure command [Pa]
variable p_boundary4::MediaComponents.Types.AbsolutePressure
# Mass flow through the lower common pipe [kg/s]
variable m_flow_pipe1::MediaComponents.Types.MassFlowRate
# Mass flow through the heated branch [kg/s]
variable m_flow_pipe2::MediaComponents.Types.MassFlowRate
# Mass flow through the unheated branch [kg/s]
variable m_flow_pipe3::MediaComponents.Types.MassFlowRate
# Mass flow through the upper common pipe [kg/s]
variable m_flow_pipe4::MediaComponents.Types.MassFlowRate
# Pressure at the branch split [Pa]
variable p_split::MediaComponents.Types.AbsolutePressure
# Pressure at the branch merge [Pa]
variable p_merge::MediaComponents.Types.AbsolutePressure
# Outlet temperature of the heated branch [K]
variable T_pipe2_out::Temperature
relations
connect(boundary1.ports[1], pipe1.port_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
connect(pipe1.port_b, pipe2.port_a) {
"Dyad": {
"edges": [{"S": 1, "M": [], "E": -1}, {"S": -1, "M": [{"x": 275, "y": 170}], "E": 2}],
"junctions": [{"x": 275, "y": 290}],
"path": {}
}
}
connect(pipe1.port_b, pipe3.port_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
connect(pipe2.port_b, pipe4.port_a) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 405, "y": 170}], "E": -1}, {"S": -1, "M": [], "E": 2}],
"junctions": [{"x": 405, "y": 290}],
"path": {}
}
}
connect(pipe3.port_b, pipe4.port_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
connect(pipe4.port_b, boundary4.ports[1]) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 670, "y": 290}, {"x": 670, "y": 190}], "E": 2}],
"path": {}
}
}
for i in 1:nNodes
connect(heat2[i].port, pipe2.heatPorts[i]) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 340.5, "y": 70}], "E": 2}], "path": {}}
}
end
for i in 1:nNodes
# Workaround: MTK selects stored energies during index reduction. Initializing
# their derivatives directly avoids non-isolated der(T) equations while
# retaining the steady-state energy initialization of the Modelica example.
initial der(pipe1.Us[i]) = 0
initial der(pipe2.Us[i]) = 0
initial der(pipe3.Us[i]) = 0
initial der(pipe4.Us[i]) = 0
end
p_boundary4 = time < pressure_step_time ? p_boundary4_initial : p_boundary4_final
boundary4.p_in = p_boundary4
m_flow_pipe1 = pipe1.port_a.m_flow
m_flow_pipe2 = pipe2.port_a.m_flow
m_flow_pipe3 = pipe3.port_a.m_flow
m_flow_pipe4 = pipe4.port_a.m_flow
p_split = pipe1.port_b.p
p_merge = pipe4.port_a.p
T_pipe2_out = pipe2.mediums[nNodes].T
metadata {}
endTest Cases ​
No test cases defined.
Related ​
Examples
Experiments
Analyses