Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Buildings/Fluid/Actuators/BaseClasses/PartialTwoWayValve.mo
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ partial model PartialTwoWayValve "Partial model for a two way valve"
parameter Real kFixed(unit="", min=0) = if dpFixed_nominal > Modelica.Constants.eps
then m_flow_nominal / sqrt(dpFixed_nominal) else 0
"Flow coefficient of fixed resistance that may be in series with valve, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2).";
Real kVal(unit="1", min=Modelica.Constants.small)
Real kVal(unit="", min=Modelica.Constants.small)
"Flow coefficient of valve, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2).";
Real k(unit="", min=Modelica.Constants.small)
"Flow coefficient of valve and pipe in series, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2).";
Expand Down Expand Up @@ -97,6 +97,11 @@ each valve opening characteristics has different parameters.
revisions="<html>
<ul>
<li>
March 31, 2026, by Michael Wetter:<br/>
Corrected unit propagation error that causes Dymola 2026x to not show certain units.<br/>
See <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/2100\">#2100</a>.
</li>
<li>
January 19, 2026, by Jelger Jansen:<br/>
Added unit 1 to parameter <code>kVal</code> to avoid FMU unit errors.<br/>
This is for <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/2074\">#2074</a>.
Expand Down
131 changes: 75 additions & 56 deletions Buildings/Fluid/CHPs/BaseClasses/EnergyConversion.mo
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ protected
annotation (Placement(transformation(extent={{110,30},{130,50}})));
Buildings.Fluid.CHPs.BaseClasses.EnergyConversionNormal opeModBas(final per=
per) "Typical energy conversion mode"
annotation (Placement(transformation(extent={{-20,-10},{0,10}})));
annotation (Placement(transformation(extent={{-20,-40},{0,-20}})));
Buildings.Fluid.CHPs.BaseClasses.EnergyConversionWarmUp opeModWarUpEngTem(
final per=per) if not per.warmUpByTimeDelay "Warm-up by engine temperature"
annotation (Placement(transformation(extent={{-20,-60},{0,-40}})));
annotation (Placement(transformation(extent={{-20,-80},{0,-60}})));
Buildings.Controls.OBC.CDL.Reals.Sources.Constant const(final k=0)
"Zero constant"
annotation (Placement(transformation(extent={{-100,60},{-80,80}})));
Expand All @@ -79,7 +79,7 @@ protected
annotation (Placement(transformation(extent={{-100,90},{-80,110}})));
Buildings.Controls.OBC.CDL.Reals.Switch switch2
"Switch between warm-up and normal value"
annotation (Placement(transformation(extent={{80,70},{100,90}})));
annotation (Placement(transformation(extent={{80,82},{100,102}})));
Buildings.Controls.OBC.CDL.Reals.Switch switch3
"Switch between warm-up and normal value"
annotation (Placement(transformation(extent={{80,10},{100,30}})));
Expand All @@ -92,34 +92,45 @@ protected
Buildings.Controls.OBC.CDL.Reals.Sources.Constant PEleTimeDel(final k=0)
if per.warmUpByTimeDelay
"Zero power output in case of warm-up by time delay"
annotation (Placement(transformation(extent={{-20,90},{0,110}})));
annotation (Placement(transformation(extent={{-20,110},{0,130}})));
Buildings.Controls.OBC.CDL.Logical.Sources.Constant delWarUp(
final k=per.warmUpByTimeDelay) "Warm-up by time delay"
annotation (Placement(transformation(extent={{-100,-120},{-80,-100}})));
annotation (Placement(transformation(extent={{-100,-130},{-80,-110}})));
Modelica.Blocks.Sources.BooleanExpression wamUpMod(
final y=opeMod == CHPs.BaseClasses.Types.Mode.WarmUp)
"Check whether warm-up mode is active"
annotation (Placement(transformation(extent={{-100,30},{-80,50}})));
Buildings.Controls.OBC.CDL.Logical.Not engTemWarUp
"Warm-up based on engine temperature"
annotation (Placement(transformation(extent={{-60,-120},{-40,-100}})));
annotation (Placement(transformation(extent={{-60,-130},{-40,-110}})));
Buildings.Controls.OBC.CDL.Logical.And and1
"True if warm-up mode and warm-up based on engine temperature"
annotation (Placement(transformation(extent={{-20,-90},{0,-70}})));
Buildings.Controls.OBC.CDL.Reals.Sources.Constant dumTimDel(
final k=0) if per.warmUpByTimeDelay
"Set dummy value in case of warm-up by time delay"
annotation (Placement(transformation(extent={{-20,30},{0,50}})));
annotation (Placement(transformation(extent={{-20,-122},{0,-102}})));
Buildings.Controls.OBC.CDL.Reals.Sources.Constant dumTimDelFue(
final k=0,
y(unit="kg/s"))
if per.warmUpByTimeDelay "Set dummy value in case of warm-up by time delay"
annotation (Placement(transformation(extent={{-20,52},{0,72}})));
Controls.OBC.CDL.Reals.Sources.Constant dumTimDelAir(
final k=0,
y(unit="kg/s"))
if per.warmUpByTimeDelay "Set dummy value in case of warm-up by time delay"
annotation (Placement(transformation(extent={{-20,20},{0,40}})));
Controls.OBC.CDL.Reals.Sources.Constant dumTimDelGen(
final k=0,
y(unit="W"))
if per.warmUpByTimeDelay "Set dummy value in case of warm-up by time delay"
annotation (Placement(transformation(extent={{-20,-10},{0,10}})));

equation
connect(opeModBas.mWat_flow, mWat_flow) annotation (Line(points={{-22,0},{-120,
0},{-120,20},{-160,20}}, color={0,0,127}));
connect(opeModBas.TWatIn, TWatIn) annotation (Line(points={{-22,-6},{-100,-6},
connect(opeModBas.mWat_flow, mWat_flow) annotation (Line(points={{-22,-30},{-110,
-30},{-110,20},{-160,20}}, color={0,0,127}));
connect(opeModBas.TWatIn, TWatIn) annotation (Line(points={{-22,-36},{-100,-36},
{-100,-20},{-160,-20}},color={0,0,127}));
connect(opeModWarUpEngTem.TEng, TEng) annotation (Line(points={{-22,-58},{-110,
-58},{-110,-90},{-160,-90}}, color={0,0,127}));
connect(opeModWarUpEngTem.TWatIn, TWatIn) annotation (Line(points={{-22,-47},{
-100,-47},{-100,-20},{-160,-20}},
connect(opeModWarUpEngTem.TEng, TEng) annotation (Line(points={{-22,-78},{-110,
-78},{-110,-90},{-160,-90}}, color={0,0,127}));
connect(opeModWarUpEngTem.TWatIn, TWatIn) annotation (Line(points={{-22,-67},{
-100,-67},{-100,-20},{-160,-20}},
color={0,0,127}));
connect(const.y, switch.u3) annotation (Line(points={{-78,70},{-70,70},{-70,
92},{-62,92}},
Expand All @@ -130,62 +141,65 @@ equation
connect(booExp.y, switch.u2) annotation (Line(points={{-79,100},{-62,100}},
color={255,0,255}));
connect(switch.y, opeModBas.PEle) annotation (Line(points={{-38,100},{-30,100},
{-30,6},{-22,6}}, color={0,0,127}));
connect(opeModWarUpEngTem.PEleNet, switch2.u1) annotation (Line(points={{2,-42},
{20,-42},{20,88},{78,88}}, color={0,0,127}));
connect(switch2.y, PEleNet) annotation (Line(points={{102,80},{160,80}},
{-30,-24},{-22,-24}},
color={0,0,127}));
connect(opeModWarUpEngTem.PEleNet, switch2.u1) annotation (Line(points={{2,-62},
{20,-62},{20,100},{78,100}},
color={0,0,127}));
connect(switch2.y, PEleNet) annotation (Line(points={{102,92},{120,92},{120,80},
{160,80}},
color={0,0,127}));
connect(switch3.y, mFue_flow) annotation (Line(points={{102,20},{160,20}},
color={0,0,127}));
connect(switch4.y, mAir_flow) annotation (Line(points={{102,-40},{160,-40}},
color={0,0,127}));
connect(switch5.y, QGen_flow)
annotation (Line(points={{102,-100},{160,-100}}, color={0,0,127}));
connect(opeModBas.mFue_flow, switch3.u3) annotation (Line(points={{2,6},{60,6},
{60,12},{78,12}}, color={0,0,127}));
connect(opeModWarUpEngTem.mFue_flow, switch3.u1) annotation (Line(points={{2,-47},
{26,-47},{26,28},{78,28}}, color={0,0,127}));
connect(opeModBas.mAir_flow, switch4.u3) annotation (Line(points={{2,0},{60,0},
{60,-48},{78,-48}}, color={0,0,127}));
connect(opeModWarUpEngTem.mAir_flow, switch4.u1) annotation (Line(points={{2,-53},
{40,-53},{40,-32},{78,-32}}, color={0,0,127}));
connect(opeModWarUpEngTem.QGen_flow, switch5.u1) annotation (Line(points={{2,-58},
{32,-58},{32,-92},{78,-92}}, color={0,0,127}));
connect(opeModBas.QGen_flow, switch5.u3) annotation (Line(points={{2.2,-6},{54,
-6},{54,-108},{78,-108}}, color={0,0,127}));
connect(opeModBas.mFue_flow, switch3.u3) annotation (Line(points={{2,-24},{60,
-24},{60,12},{78,12}},color={0,0,127}));
connect(opeModWarUpEngTem.mFue_flow, switch3.u1) annotation (Line(points={{2,-67},
{26,-67},{26,28},{78,28}}, color={0,0,127}));
connect(opeModBas.mAir_flow, switch4.u3) annotation (Line(points={{2,-30},{60,
-30},{60,-48},{78,-48}}, color={0,0,127}));
connect(opeModWarUpEngTem.mAir_flow, switch4.u1) annotation (Line(points={{2,-73},
{40,-73},{40,-32},{78,-32}}, color={0,0,127}));
connect(opeModWarUpEngTem.QGen_flow, switch5.u1) annotation (Line(points={{2,-78},
{32,-78},{32,-92},{78,-92}}, color={0,0,127}));
connect(opeModBas.QGen_flow, switch5.u3) annotation (Line(points={{2.2,-36},{54,
-36},{54,-108},{78,-108}}, color={0,0,127}));
connect(mWat_flow, opeModWarUpEngTem.mWat_flow) annotation (Line(points={{-160,20},
{-120,20},{-120,-42},{-22,-42}}, color={0,0,127}));
{-110,20},{-110,-62},{-22,-62}}, color={0,0,127}));
connect(switch3.y, assFue.mFue_flow) annotation (Line(points={{102,20},{104,20},
{104,40},{108,40}}, color={0,0,127}));
connect(PEleTimeDel.y, switch2.u1) annotation (Line(points={{2,100},{60,100},{
60,88},{78,88}}, color={0,0,127}));
connect(PEleTimeDel.y, switch2.u1) annotation (Line(points={{2,120},{60,120},{
60,100},{78,100}},
color={0,0,127}));
connect(switch.y, switch2.u3) annotation (Line(points={{-38,100},{-30,100},{-30,
72},{78,72}}, color={0,0,127}));
84},{78,84}}, color={0,0,127}));
connect(TRoo, opeModWarUpEngTem.TRoo) annotation (Line(points={{-160,-60},{-120,
-60},{-120,-53},{-22,-53}}, color={0,0,127}));
-60},{-120,-73},{-22,-73}}, color={0,0,127}));
connect(delWarUp.y, engTemWarUp.u)
annotation (Line(points={{-78,-110},{-62,-110}}, color={255,0,255}));
connect(engTemWarUp.y, and1.u2) annotation (Line(points={{-38,-110},{-30,-110},
{-30,-88},{-22,-88}}, color={255,0,255}));
connect(wamUpMod.y, and1.u1) annotation (Line(points={{-79,40},{-60,40},{-60,
-80},{-22,-80}},
annotation (Line(points={{-78,-120},{-62,-120}}, color={255,0,255}));
connect(engTemWarUp.y, and1.u2) annotation (Line(points={{-38,-120},{-22,-120}},
color={255,0,255}));
connect(wamUpMod.y, and1.u1) annotation (Line(points={{-79,40},{-60,40},{-60,-100},
{-30,-100},{-30,-112},{-22,-112}},
color={255,0,255}));
connect(and1.y, switch3.u2) annotation (Line(points={{2,-80},{70,-80},{70,20},
connect(and1.y, switch3.u2) annotation (Line(points={{2,-112},{70,-112},{70,20},
{78,20}}, color={255,0,255}));
connect(and1.y, switch4.u2) annotation (Line(points={{2,-80},{70,-80},{70,-40},
connect(and1.y, switch4.u2) annotation (Line(points={{2,-112},{70,-112},{70,-40},
{78,-40}}, color={255,0,255}));
connect(and1.y, switch5.u2) annotation (Line(points={{2,-80},{70,-80},{70,-100},
connect(and1.y, switch5.u2) annotation (Line(points={{2,-112},{70,-112},{70,-100},
{78,-100}}, color={255,0,255}));
connect(wamUpMod.y, switch2.u2) annotation (Line(points={{-79,40},{-60,40},{
-60,80},{78,80}},
color={255,0,255}));
connect(dumTimDel.y, switch3.u1) annotation (Line(points={{2,40},{26,40},{26,28},
{78,28}}, color={0,0,127}));
connect(dumTimDel.y, switch4.u1) annotation (Line(points={{2,40},{40,40},{40,-32},
{78,-32}}, color={0,0,127}));
connect(dumTimDel.y, switch5.u1) annotation (Line(points={{2,40},{32,40},{32,-92},
{78,-92}}, color={0,0,127}));
connect(wamUpMod.y, switch2.u2) annotation (Line(points={{-79,40},{-60,40},{-60,
92},{78,92}}, color={255,0,255}));
connect(dumTimDelFue.y, switch3.u1) annotation (Line(points={{2,62},{26,62},{26,
28},{78,28}}, color={0,0,127}));

connect(switch4.u1, dumTimDelAir.y) annotation (Line(points={{78,-32},{40,-32},
{40,30},{2,30}}, color={0,0,127}));
connect(switch5.u1, dumTimDelGen.y) annotation (Line(points={{78,-92},{32,-92},
{32,0},{2,0}}, color={0,0,127}));
annotation (
defaultComponentName="eneCon",
Diagram(coordinateSystem(extent={{-140,-140},{140,140}})),
Expand All @@ -208,6 +222,11 @@ combustion engines).
</html>", revisions="<html>
<ul>
<li>
March 31, 2026, by Michael Wetter:<br/>
Corrected unit propagation error that causes Dymola 2026x to not show certain units.<br/>
See <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/2100\">#2100</a>.
</li>
<li>
April 8, 2020, by Antoine Gautier:<br/>
Refactored implementation.
</li>
Expand Down
10 changes: 9 additions & 1 deletion Buildings/Fluid/Examples/Performance/BaseClasses/Example1.mo
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ partial model Example1 "Example 1 partial model"
annotation (Placement(transformation(extent={{-20,20},{0,40}})));
Modelica.Blocks.Sources.Pulse pulse(period=1000) "Pulse input"
annotation (Placement(transformation(extent={{-60,70},{-40,90}})));
Modelica.Blocks.Math.Gain gain(k=m_flow_nominal) "Gain for m_flow_nominal"
Modelica.Blocks.Math.Gain gain(
k=m_flow_nominal,
u(unit="1"),
y(unit="kg/s")) "Gain for m_flow_nominal"
annotation (Placement(transformation(extent={{0,70},{20,90}})));
Buildings.Fluid.Actuators.Valves.ThreeWayLinear val(
redeclare package Medium = Medium,
Expand Down Expand Up @@ -109,6 +112,11 @@ and is created to avoid errors in the implementation of the two depending exampl
</html>", revisions="<html>
<ul>
<li>
March 31, 2026, by Michael Wetter:<br/>
Corrected unit propagation error that causes Dymola 2026x to not show certain units.<br/>
See <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/2100\">#2100</a>.
</li>
<li>
May 8, 2017, by Michael Wetter:<br/>
Updated heater model.<br/>
This is for
Expand Down
35 changes: 30 additions & 5 deletions Buildings/Fluid/Examples/ResistanceVolumeFlowReversal.mo
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ model ResistanceVolumeFlowReversal
annotation (Placement(transformation(extent={{-40,-30},{-20,-10}})));
Modelica.Blocks.Sources.Pulse pulse(period=1000) "Pulse input"
annotation (Placement(transformation(extent={{-80,40},{-60,60}})));
Modelica.Blocks.Math.Gain gain(k=m_flow_nominal) "Gain for m_flow_nominal"
Modelica.Blocks.Math.Gain gain(
k=m_flow_nominal,
u(unit="1"),
y(unit="kg/s")) "Gain for m_flow_nominal"
annotation (Placement(transformation(extent={{-40,40},{-20,60}})));
Buildings.Fluid.Actuators.Valves.ThreeWayLinear val(
redeclare package Medium = Medium,
Expand Down Expand Up @@ -59,6 +62,13 @@ model ResistanceVolumeFlowReversal
each energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState,
each allowFlowReversal=true) "Mixing volumes for enthalpy circuit"
annotation (Placement(transformation(extent={{60,-66},{40,-46}})));
Buildings.Fluid.Sensors.TemperatureTwoPort senTem[nRes.k](
redeclare final package Medium = Medium,
each final m_flow_nominal=m_flow_nominal/nRes.k,
each initType=Modelica.Blocks.Types.Init.SteadyState) "Temperature sensor"
annotation (Placement(transformation(extent={{10,-10},{-10,10}},
rotation=0,
origin={20,-70})));
equation
connect(bou.ports[1],hea. port_a) annotation (Line(
points={{-60,-20},{-40,-20}},
Expand Down Expand Up @@ -89,12 +99,15 @@ equation
points={{40,-20},{56,-20}},
color={0,127,255}));
connect(res[i].port_b, vol[i].ports[1]) annotation (Line(
points={{76,-20},{80,-20},{80,-70},{52,-70},{52,-66}},
color={0,127,255}));
connect(vol[i].ports[2], val.port_3) annotation (Line(
points={{48,-66},{48,-70},{0,-70},{0,-30}},
points={{76,-20},{80,-20},{80,-70},{51,-70},{51,-66}},
color={0,127,255}));
connect(vol[i].ports[2], senTem[i].port_a) annotation (Line(
points={{49,-66},{49,-70},{30,-70}},
color={0,127,255}));
connect(senTem[i].port_b, val.port_3) annotation (Line(
points={{10,-70},{0,-70},{0,-30}}, color={0,127,255}));
end for;

annotation (experiment(
Tolerance=1e-6, StopTime=10000),
__Dymola_Commands(file="modelica://Buildings/Resources/Scripts/Dymola/Fluid/Examples/ResistanceVolumeFlowReversal.mos"
Expand Down Expand Up @@ -153,6 +166,18 @@ Sizes after manipulation of the nonlinear systems: {1, 9, <b>1</b>}
</html>", revisions="<html>
<ul>
<li>
March 31, 2026, by Michael Wetter:<br/>
Corrected unit propagation error that causes Dymola 2026x to not show certain units.<br/>
See <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/2100\">#2100</a>.
</li>
<li>
July 18, 2025, by Hongxiang Fu:<br/>
Added two-port temperature sensors to replace <code>vol[:].T</code>
from reference results.<br/>
This is for
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/4276\">#4276</a>.
</li>
<li>
September 21, 2017, by Michael Wetter:<br/>
Corrected parameterization to be independent of <code>k</code>.<br/>
This is for
Expand Down
32 changes: 26 additions & 6 deletions Buildings/Fluid/FixedResistances/PressureDrop.mo
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@ model PressureDrop
m_flow_nominal_pos / sqrt(dp_nominal_pos) else 0
"Flow coefficient, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2)";
protected
final parameter Boolean computeFlowResistance=(dp_nominal_pos > Modelica.Constants.eps)
parameter Boolean disableComputeFlowResistance_internal=false
"=false to disable computation of flow resistance"
annotation(Evaluate=true);
final parameter Boolean computeFlowResistance=
(dp_nominal_pos > Modelica.Constants.eps) and not disableComputeFlowResistance_internal
"Flag to enable/disable computation of flow resistance"
annotation(Evaluate=true);
final parameter Real coeff=
final parameter Real coeM(final unit="kg/(s.Pa)")=
if linearized and computeFlowResistance
then if from_dp then k^2/m_flow_nominal_pos else m_flow_nominal_pos/k^2
else 0
then k^2/m_flow_nominal_pos else 0
"Precomputed coefficient to avoid division by parameter";
final parameter Real coeP(final unit="s.Pa/kg")=
if linearized and computeFlowResistance
then m_flow_nominal_pos/k^2 else 0
"Precomputed coefficient to avoid division by parameter";
initial equation
if computeFlowResistance then
Expand All @@ -33,9 +40,9 @@ equation
if computeFlowResistance then
if linearized then
if from_dp then
m_flow = dp*coeff;
m_flow = dp*coeM;
else
dp = m_flow*coeff;
dp = m_flow*coeP;
end if;
else
if homotopyInitialization then
Expand Down Expand Up @@ -125,6 +132,9 @@ then the pressure drop is computed as a linear function of the
mass flow rate.
</p>
<p>
To disable any pressure drop calculation, set <code>dp_nominal = 0</code>.
</p>
<p>
Setting <code>allowFlowReversal=false</code> can lead to simpler
equations. However, this should only be set to <code>false</code>
if one can guarantee that the flow never reverses its direction.
Expand Down Expand Up @@ -177,6 +187,16 @@ This leads to simpler equations.
</html>", revisions="<html>
<ul>
<li>
March 31, 2026, by Michael Wetter:<br/>
Corrected unit propagation error that causes Dymola 2026x to not show certain units.<br/>
See <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/2100\">#2100</a>.
</li>
<li>
April 25, 2025, by Fabian Wuelhorst and Michael Wetter:<br/>
Add option to disable <code>computeFlowResistance</code> for extending classes.<br/>
See <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/2001\">#2001</a>.
</li>
<li>
September 21, 2018, by Michael Wetter:<br/>
Decrease value of <code>deltaM(min=...)</code> attribute.
See <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1026\">#1026</a>.
Expand Down
Loading
Loading