Skip to content

Commit 2bfbb3b

Browse files
authored
Merge pull request #2002 from ibpsa/issue2001_computeFlowResistance
add option to advanced tab. Change one example to indicate if the cha…
2 parents b59a602 + d2e0bd7 commit 2bfbb3b

File tree

3 files changed

+92
-15
lines changed

3 files changed

+92
-15
lines changed

IBPSA/Fluid/FixedResistances/HydraulicDiameter.mo

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ within IBPSA.Fluid.FixedResistances;
22
model HydraulicDiameter "Fixed flow resistance with hydraulic diameter and m_flow as parameter"
33
extends IBPSA.Fluid.FixedResistances.PressureDrop(
44
final deltaM = eta_default*dh/4*Modelica.Constants.pi*ReC/m_flow_nominal_pos,
5-
final dp_nominal=fac*dpStraightPipe_nominal);
5+
final dp_nominal=fac*dpStraightPipe_nominal,
6+
final disableComputeFlowResistance_internal=disableComputeFlowResistance);
67

78
parameter Modelica.Units.SI.Length dh=sqrt(4*m_flow_nominal/rho_default/
89
v_nominal/Modelica.Constants.pi)
@@ -24,6 +25,10 @@ model HydraulicDiameter "Fixed flow resistance with hydraulic diameter and m_flo
2425
parameter Real fac(min=1) = 2
2526
"Factor to take into account resistance of bends etc., fac=dp_nominal/dpStraightPipe_nominal";
2627

28+
parameter Boolean disableComputeFlowResistance=false
29+
"=false to disable computation of flow resistance"
30+
annotation(Dialog(tab="Advanced"), Evaluate=true);
31+
2732
final parameter Modelica.Units.SI.PressureDifference dpStraightPipe_nominal(
2833
displayUnit="Pa") =
2934
Modelica.Fluid.Pipes.BaseClasses.WallFriction.Detailed.pressureLoss_m_flow(
@@ -125,6 +130,13 @@ then the pressure drop is computed as a linear function of the
125130
mass flow rate.
126131
</p>
127132
<p>
133+
If the parameter <code>disableComputeFlowResistance</code> is set to <code>true</code>,
134+
then the pressure drop is not computed. This allows to aggregate <code>dp_nominal</code>
135+
in other components such as in an actuator using its parameter <code>dpFixed_nominal</code>.
136+
See <a href=\"modelica://IBPSA.Fluid.Actuators.UsersGuide\">IBPSA.Fluid.Actuators.UsersGuide</a>
137+
for further information on <code>dpFixed_nominal</code>.
138+
</p>
139+
<p>
128140
Setting <code>allowFlowReversal=false</code> can lead to simpler
129141
equations. However, this should only be set to <code>false</code>
130142
if one can guarantee that the flow never reverses its direction.
@@ -177,6 +189,11 @@ This leads to simpler equations.
177189
</html>", revisions="<html>
178190
<ul>
179191
<li>
192+
May 07, 2025, by Fabian Wuelhorst and Michael Wetter:<br/>
193+
Add option to <code>disableComputeFlowResistance</code>.<br/>
194+
See <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/2001\">#2001</a>.
195+
</li>
196+
<li>
180197
September 21, 2021, by Michael Wetter:<br/>
181198
Corrected typo in comments.<br/>
182199
This is for

IBPSA/Fluid/FixedResistances/PressureDrop.mo

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ model PressureDrop
1414
m_flow_nominal_pos / sqrt(dp_nominal_pos) else 0
1515
"Flow coefficient, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2)";
1616
protected
17-
final parameter Boolean computeFlowResistance=(dp_nominal_pos > Modelica.Constants.eps)
17+
parameter Boolean disableComputeFlowResistance_internal=false
18+
"=false to disable computation of flow resistance"
19+
annotation(Evaluate=true);
20+
final parameter Boolean computeFlowResistance=
21+
(dp_nominal_pos > Modelica.Constants.eps) and not disableComputeFlowResistance_internal
1822
"Flag to enable/disable computation of flow resistance"
1923
annotation(Evaluate=true);
2024
final parameter Real coeff=
@@ -125,6 +129,9 @@ then the pressure drop is computed as a linear function of the
125129
mass flow rate.
126130
</p>
127131
<p>
132+
To disable any pressure drop calculation, set <code>dp_nominal = 0</code>.
133+
</p>
134+
<p>
128135
Setting <code>allowFlowReversal=false</code> can lead to simpler
129136
equations. However, this should only be set to <code>false</code>
130137
if one can guarantee that the flow never reverses its direction.
@@ -177,6 +184,11 @@ This leads to simpler equations.
177184
</html>", revisions="<html>
178185
<ul>
179186
<li>
187+
April 25, 2025, by Fabian Wuelhorst and Michael Wetter:<br/>
188+
Add option to disable <code>computeFlowResistance</code> for extending classes.<br/>
189+
See <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/2001\">#2001</a>.
190+
</li>
191+
<li>
180192
September 21, 2018, by Michael Wetter:<br/>
181193
Decrease value of <code>deltaM(min=...)</code> attribute.
182194
See <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1026\">#1026</a>.

IBPSA/Fluid/FixedResistances/Validation/PressureDropsParallel.mo

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ model PressureDropsParallel
33
"Test with multiple resistances in parallel"
44
extends Modelica.Icons.Example;
55

6-
package Medium = IBPSA.Media.Water "Medium model";
6+
package Medium = IBPSA.Media.Water "Medium model";
77

8-
Modelica.Blocks.Sources.Ramp P(
8+
Modelica.Blocks.Sources.Ramp P(
99
duration=1,
1010
height=20,
1111
offset=101315) "Signal source"
@@ -22,19 +22,18 @@ model PressureDropsParallel
2222

2323
IBPSA.Fluid.Sources.Boundary_pT sou1(
2424
redeclare package Medium = Medium,
25-
nPorts=2,
25+
nPorts=3,
2626
use_p_in=true,
2727
T=293.15) "Pressure boundary condition"
2828
annotation (Placement(transformation(extent={{-60,28},
2929
{-40,48}})));
3030

3131
IBPSA.Fluid.Sources.Boundary_pT sin1(
3232
redeclare package Medium = Medium,
33-
nPorts=2,
33+
nPorts=3,
3434
p(displayUnit="Pa") = 101325,
3535
T=283.15) "Pressure boundary condition"
36-
annotation (Placement(transformation(extent={{80,28},
37-
{60,48}})));
36+
annotation (Placement(transformation(extent={{80,30},{60,50}})));
3837

3938
IBPSA.Fluid.FixedResistances.PressureDrop res2(
4039
redeclare package Medium = Medium,
@@ -52,12 +51,40 @@ model PressureDropsParallel
5251
message="Inputs differ, check that lossless pipe is correctly implemented.",
5352
threShold=1E-4)
5453
"Assert equality of the two mass flow rates"
55-
annotation (Placement(transformation(extent={{40,60},{60,80}})));
54+
annotation (Placement(transformation(extent={{70,60},{90,80}})));
5655

5756
IBPSA.Fluid.Sensors.MassFlowRate masFlo1(redeclare package Medium = Medium)
5857
"Mass flow rate sensor" annotation (Placement(transformation(extent={{20,30},
5958
{40,50}})));
6059

60+
IBPSA.Fluid.FixedResistances.PressureDrop res3(
61+
redeclare package Medium = Medium,
62+
m_flow_nominal=5,
63+
dp_nominal=10,
64+
deltaM=0.3,
65+
linearized=false,
66+
from_dp=true) "Flow resistance"
67+
annotation (Placement(transformation(extent={{-28,-90},{-8,-70}})));
68+
IBPSA.Fluid.Sensors.MassFlowRate masFlo3(redeclare package Medium = Medium)
69+
"Mass flow rate sensor" annotation (Placement(transformation(extent={{0,-90},
70+
{20,-70}})));
71+
IBPSA.Utilities.Diagnostics.AssertEquality assEqu1(
72+
message="Inputs differ, check that lossless pipe is correctly implemented.",
73+
threShold=1E-4)
74+
"Assert equality of the two mass flow rates"
75+
annotation (Placement(transformation(extent={{70,-40},{90,-20}})));
76+
IBPSA.Fluid.FixedResistances.HydraulicDiameter noRes(
77+
redeclare package Medium = Medium,
78+
m_flow_nominal=5,
79+
linearized=false,
80+
from_dp=true,
81+
length=10,
82+
disableComputeFlowResistance=true)
83+
"Flow resistance with computeFlowResistance set to false" annotation (
84+
Placement(transformation(
85+
extent={{-10,-10},{10,10}},
86+
rotation=90,
87+
origin={-32,-42})));
6188
equation
6289
connect(P.y, sou1.p_in) annotation (Line(points={{-71,46},{-62,46}},
6390
color={0,0,127}));
@@ -67,33 +94,54 @@ equation
6794
connect(res1.port_b, masFlo1.port_a)
6895
annotation (Line(points={{-8,40},{20,40}},color={0,127,255}));
6996
connect(sou1.ports[1], res1.port_a) annotation (Line(
70-
points={{-40,40},{-28,40}},
97+
points={{-40,36.6667},{-34,36.6667},{-34,40},{-28,40}},
7198
color={0,127,255}));
7299
connect(sou1.ports[2], res2.port_a) annotation (Line(
73-
points={{-40,36},{-34,36},{-34,6.10623e-16},{-28,6.10623e-16}},
100+
points={{-40,38},{-34,38},{-34,0},{-28,0}},
74101
color={0,127,255}));
75102
connect(sin1.ports[1], masFlo1.port_b) annotation (Line(
76-
points={{60,40},{40,40}},
103+
points={{60,38.6667},{50,38.6667},{50,40},{40,40}},
77104
color={0,127,255}));
78105
connect(sin1.ports[2], masFlo2.port_b) annotation (Line(
79-
points={{60,36},{52,36},{52,6.10623e-16},{20,6.10623e-16}},
106+
points={{60,40},{52,40},{52,0},{20,0}},
80107
color={0,127,255}));
81108
connect(masFlo2.m_flow, assEqu.u1) annotation (Line(
82-
points={{10,11},{10,76},{38,76}},
109+
points={{10,11},{10,20},{46,20},{46,76},{68,76}},
83110
color={0,0,127}));
84111
connect(masFlo1.m_flow, assEqu.u2) annotation (Line(
85-
points={{30,51},{30,64},{38,64}},
112+
points={{30,51},{30,64},{68,64}},
86113
color={0,0,127}));
87114

115+
connect(sou1.ports[3], noRes.port_b) annotation (Line(points={{-40,39.3333},{
116+
-40,38},{-32,38},{-32,-32}},
117+
color={0,127,255}));
118+
connect(noRes.port_a, res3.port_a) annotation (Line(points={{-32,-52},{-32,-80},
119+
{-28,-80}}, color={0,127,255}));
120+
connect(res3.port_b, masFlo3.port_a)
121+
annotation (Line(points={{-8,-80},{0,-80}}, color={0,127,255}));
122+
connect(masFlo3.port_b, sin1.ports[3]) annotation (Line(points={{20,-80},{56,
123+
-80},{56,41.3333},{60,41.3333}},
124+
color={0,127,255}));
125+
connect(masFlo2.m_flow, assEqu1.u1) annotation (Line(points={{10,11},{10,20},
126+
{46,20},{46,-24},{68,-24}},color={0,0,127}));
127+
connect(masFlo3.m_flow, assEqu1.u2)
128+
annotation (Line(points={{10,-69},{10,-36},{68,-36}}, color={0,0,127}));
88129
annotation (experiment(Tolerance=1e-6, StopTime=1.0),
89130
__Dymola_Commands(file="modelica://IBPSA/Resources/Scripts/Dymola/Fluid/FixedResistances/Validation/PressureDropsParallel.mos" "Simulate and plot"),
90131
Documentation(info="<html>
91132
<p>
92133
This model tests two resistances in parallel.
134+
The flow path at the bottom of the model also has one additional hydraulic diameter
135+
model, but it has <code>noRes.disableComputeFlowResistance=true</code>, thereby
136+
removing the calculation of the flow resistance in that model.
93137
</p>
94138
</html>", revisions="<html>
95139
<ul>
96140
<li>
141+
April 25, 2025, by Michael Wetter and Fabian Wuellhorst:<br/>
142+
Expanded model to include a component with <code>disableComputeFlowResistance=true</code>.
143+
</li>
144+
<li>
97145
July 20, 2007 by Michael Wetter:<br/>
98146
First implementation.
99147
</li>

0 commit comments

Comments
 (0)