Skip to content

Commit

Permalink
Improve control in all examples to avoid frequent switches and enable…
Browse files Browse the repository at this point in the history
… cooling
  • Loading branch information
FWuellhorst committed Feb 1, 2024
1 parent cfa9252 commit 2485150
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 102 deletions.
Original file line number Diff line number Diff line change
@@ -1,75 +1,80 @@
within IBPSA.Fluid.HeatPumps.ModularReversible.Examples.BaseClasses;
within IBPSA.Fluid.HeatPumps.ModularReversible.Examples.BaseClasses;
model OneRoomRadiatorHeatPumpControl
"Helper model for the control of the system"
extends Modelica.Blocks.Icons.Block;
parameter Boolean witCoo=true
"=true to simulate cooling behaviour";
parameter Modelica.Units.SI.Temperature TRooSetHea=293.15
"Room set temperature for heating";
parameter Modelica.Units.SI.Temperature TRooSetCoo=296.15
"Room set temperature for heating";
parameter Modelica.Units.SI.Temperature TRadMinSup=296.15
parameter Modelica.Units.SI.Temperature TRadMinSup=290.15
"Minimal radiator supply temperature to avoid condensation effects";
parameter Modelica.Units.SI.TemperatureDifference dTHysRoo=1
parameter Modelica.Units.SI.TemperatureDifference dTHysRoo=2
"Room set temperature for heating";
Modelica.Blocks.Logical.Hysteresis hysHea(
final uLow=TRooSetHea - dTHysRoo,
final uHigh=TRooSetHea + dTHysRoo,
final pre_y_start=false)
"Hysteresis controller for heating" annotation (Placement(transformation(
extent={{-10,-10},{10,10}}, origin={-70,20})));
extent={{-10,-10},{10,10}}, origin={-90,20})));
Modelica.Blocks.Logical.Hysteresis hysCoo(
final uLow=TRooSetCoo - dTHysRoo,
final uHigh=TRooSetCoo + dTHysRoo,
final pre_y_start=false)
if witCoo
"Hysteresis controller for cooling" annotation (Placement(transformation(
extent={{-10,-10},{10,10}}, origin={-70,-10})));
extent={{-10,-10},{10,10}}, origin={-90,-10})));
Modelica.Blocks.Sources.BooleanConstant conFal(final k=false)
if not witCoo
"No cooling if witCoo=false"
annotation (Placement(transformation(extent={{-60,-40},{-40,-20}})));
annotation (Placement(transformation(extent={{-80,-50},{-60,-30}})));
Modelica.Blocks.Logical.Not heaIsOn
"If lower than hysteresis, heating demand" annotation (Placement(
transformation(extent={{-10,-10},{10,10}}, origin={-36,20})));
Modelica.Blocks.Logical.Switch swiHeaCooYSet
transformation(extent={{-10,-10},{10,10}}, origin={-50,20})));
Modelica.Blocks.Logical.Switch swiHeaCooYSet if witCoo
"Switch ySet for heating and cooling" annotation (Placement(transformation(
extent={{-10,10},{10,-10}},
origin={40,70},
origin={30,70},
rotation=0)));
Modelica.Blocks.Continuous.LimPID PIDCoo(
controllerType=Modelica.Blocks.Types.SimpleController.PI,
k=0.03,
Ti=400,
k=0.01,
Ti=800,
yMax=1,
yMin=0.3) "PI control for cooling, inverse"
annotation (Placement(transformation(extent={{0,40},{20,60}})));
yMin=0.3,
I(use_reset=true, reset=hysCoo.y)) if witCoo
"PI control for cooling, inverse"
annotation (Placement(transformation(extent={{-20,60},{0,80}})));
Modelica.Blocks.Continuous.LimPID PIDHea(
controllerType=Modelica.Blocks.Types.SimpleController.PI,
k=0.03,
Ti=400,
k=0.01,
Ti=800,
yMax=1,
yMin=0.3) "PI control for heating"
annotation (Placement(transformation(extent={{-4,70},{16,90}})));
yMin=0.3,
I(use_reset=true, reset=hysHea.y))
"PI control for heating"
annotation (Placement(transformation(extent={{-58,80},{-38,100}})));
Modelica.Blocks.Sources.Constant constTSetRooHea(final k=TRooSetHea)
"Room set point temperature for heating"
annotation (Placement(transformation(extent={{-44,70},{-24,90}})));
Modelica.Blocks.Sources.Constant constTSetRooCoo(final k=TRooSetCoo)
annotation (Placement(transformation(extent={{-100,80},{-80,100}})));
Modelica.Blocks.Sources.Constant constTSetRooCoo(final k=TRooSetCoo) if witCoo
"Room set point temperature for cooling"
annotation (Placement(transformation(extent={{-60,40},{-40,60}})));
Modelica.Blocks.Sources.Constant constYSetZer(final k=0) "ySet equals zero"
annotation (Placement(transformation(extent={{0,-80},{20,-60}})));
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
rotation=180,
origin={70,-90})));
Modelica.Blocks.Logical.Switch swiYSet "If no demand, switch heat pump off"
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=0,
origin={70,40})));
origin={70,50})));
Modelica.Blocks.Logical.Switch swiSecForCoo
"If in cooling mode, heat pump can't operate below condensing temperature of 15 °C"
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=0,
origin={82,10})));
origin={90,-10})));
Modelica.Blocks.Logical.Hysteresis hysSecCoo(
final uLow=TRadMinSup,
final uHigh=TRadMinSup + 1,
Expand All @@ -78,93 +83,95 @@ model OneRoomRadiatorHeatPumpControl
"Hysteresis for avoiding temperatures below 15 °C when cooling"
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
origin={-70,-60},
origin={-90,-70},
rotation=0)));
Modelica.Blocks.Sources.BooleanConstant conTru(final k=true)
if not witCoo
"No cooling if witCoo=false, then no safety is necessary" annotation (
Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=0,
origin={-42,-80})));
origin={-50,-100})));
Modelica.Blocks.Interfaces.RealInput TRooMea(unit="K", displayUnit="degC")
"Room measurement temperature"
annotation (Placement(transformation(extent={{-140,-20},{-100,20}})));
annotation (Placement(transformation(extent={{-160,-20},{-120,20}})));
Modelica.Blocks.Interfaces.RealInput TRadSup(displayUnit="degC", unit="K")
"Radiator supply temperature"
annotation (Placement(transformation(extent={{-140,-90},{-100,-50}})));
annotation (Placement(transformation(extent={{-160,-90},{-120,-50}})));
Modelica.Blocks.Interfaces.RealOutput ySet "Heat pump set speed"
annotation (Placement(transformation(extent={{100,30},{120,50}})));
annotation (Placement(transformation(extent={{120,30},{140,50}})));
Modelica.Blocks.Interfaces.BooleanOutput hea if witCoo
"Heat pump in normal mode"
annotation (Placement(transformation(extent={{100,-70},{120,-50}})));
annotation (Placement(transformation(extent={{120,-70},{140,-50}})));
Modelica.Blocks.Logical.Or heaOrCooIsOn "Heating or cooling is on"
annotation (Placement(transformation(extent={{-10,-10},{10,10}}, origin={10,10})));
annotation (Placement(transformation(extent={{-10,-10},{10,10}}, origin={-10,10})));

Modelica.Blocks.Logical.Or cooValOrHea
"Cooling safety control is used only when the device is not heating" annotation (
Placement(transformation(extent={{-10,-10},{10,10}}, origin={10,-40})));
Placement(transformation(extent={{-10,-10},{10,10}}, origin={-10,-90})));
equation
connect(hysHea.y, heaIsOn.u)
annotation (Line(points={{-59,20},{-48,20}}, color={255,0,255}));
annotation (Line(points={{-79,20},{-62,20}}, color={255,0,255}));
connect(swiHeaCooYSet.u2, hysCoo.y)
annotation (Line(points={{28,70},{28,-10},{-59,-10}}, color={255,0,255}));
connect(swiYSet.u2, heaOrCooIsOn.y) annotation (Line(points={{58,40},{24,40},{
24,10},{21,10}}, color={255,0,255}));
connect(heaIsOn.y, heaOrCooIsOn.u1) annotation (Line(points={{-25,20},{-2,20},
{-2,10}}, color={255,0,255}));
annotation (Line(points={{18,70},{10,70},{10,-10},{-79,-10}},
color={255,0,255}));
connect(swiYSet.u2, heaOrCooIsOn.y) annotation (Line(points={{58,50},{44,50},{44,
10},{1,10}}, color={255,0,255}));
connect(heaIsOn.y, heaOrCooIsOn.u1) annotation (Line(points={{-39,20},{-30,20},{
-30,10},{-22,10}}, color={255,0,255}));
connect(PIDHea.u_s,constTSetRooHea. y)
annotation (Line(points={{-6,80},{-23,80}}, color={0,0,127}));
connect(PIDHea.y, swiHeaCooYSet.u3) annotation (Line(points={{17,80},{18,80},{
18,78},{28,78}}, color={0,0,127}));
connect(constTSetRooCoo.y,PIDCoo. u_m) annotation (Line(points={{-39,50},{-14,
50},{-14,32},{10,32},{10,38}}, color={0,0,127}));
connect(swiSecForCoo.u3, constYSetZer.y) annotation (Line(points={{70,2},{50,2},
{50,-70},{21,-70}}, color={0,0,127}));
connect(constYSetZer.y, swiYSet.u3) annotation (Line(points={{21,-70},{50,-70},
{50,32},{58,32}}, color={0,0,127}));
connect(hysCoo.u, TRooMea) annotation (Line(points={{-82,-10},{-88,-10},{-88,0},
{-120,0}}, color={0,0,127}));
connect(TRooMea, hysHea.u) annotation (Line(points={{-120,0},{-88,0},{-88,20},
{-82,20}}, color={0,0,127}));
connect(swiSecForCoo.y, ySet) annotation (Line(points={{93,10},{96,10},{96,40},
{110,40}}, color={0,0,127}));
annotation (Line(points={{-60,90},{-79,90}}, color={0,0,127}));
connect(PIDHea.y, swiHeaCooYSet.u3) annotation (Line(points={{-37,90},{18,90},{18,
78}}, color={0,0,127}));
connect(constTSetRooCoo.y,PIDCoo. u_m) annotation (Line(points={{-39,50},{-10,50},
{-10,58}}, color={0,0,127}));
connect(swiSecForCoo.u3, constYSetZer.y) annotation (Line(points={{78,-18},{50,-18},
{50,-90},{59,-90}}, color={0,0,127}));
connect(constYSetZer.y, swiYSet.u3) annotation (Line(points={{59,-90},{50,-90},{
50,42},{58,42}}, color={0,0,127}));
connect(hysCoo.u, TRooMea) annotation (Line(points={{-102,-10},{-108,-10},{-108,
0},{-140,0}}, color={0,0,127}));
connect(TRooMea, hysHea.u) annotation (Line(points={{-140,0},{-108,0},{-108,20},
{-102,20}}, color={0,0,127}));
connect(swiSecForCoo.y, ySet) annotation (Line(points={{101,-10},{110,-10},{110,
40},{130,40}},
color={0,0,127}));
connect(hysSecCoo.u, TRadSup)
annotation (Line(points={{-82,-60},{-92,-60},{-92,-70},{-120,-70}},
color={0,0,127}));
connect(swiYSet.y, swiSecForCoo.u1) annotation (Line(points={{81,40},{86,40},{
86,26},{58,26},{58,18},{70,18}}, color={0,0,127}));
connect(PIDCoo.u_s, TRooMea) annotation (Line(points={{-2,50},{-6,50},{-6,66},{
-94,66},{-94,0},{-120,0}}, color={0,0,127}));
connect(PIDHea.u_m, TRooMea) annotation (Line(points={{6,68},{6,66},{-94,66},{
-94,0},{-120,0}}, color={0,0,127}));
connect(PIDCoo.y, swiHeaCooYSet.u1) annotation (Line(points={{21,50},{21,54},
{28,54},{28,62}}, color={0,0,127}));
connect(swiHeaCooYSet.y, swiYSet.u1) annotation (Line(points={{51,70},{56,70},
{56,52},{54,52},{54,48},{58,48}}, color={0,0,127}));
connect(heaOrCooIsOn.u2, conFal.y) annotation (Line(points={{-2,2},{-28,2},{-28,
-30},{-39,-30}}, color={255,0,255}));
connect(hysCoo.y, heaOrCooIsOn.u2) annotation (Line(points={{-59,-10},{-28,-10},
{-28,2},{-2,2}}, color={255,0,255}));
connect(heaIsOn.y, hea) annotation (Line(points={{-25,20},{-16,20},{-16,-30},
{80,-30},{80,-60},{110,-60}}, color={255,0,255}));
connect(cooValOrHea.y, swiSecForCoo.u2) annotation (Line(points={{21,-40},{36,
-40},{36,10},{70,10}}, color={255,0,255}));
connect(cooValOrHea.u2, conTru.y) annotation (Line(points={{-2,-48},{-16,-48},{
-16,-80},{-31,-80}}, color={255,0,255}));
connect(cooValOrHea.u2, hysSecCoo.y) annotation (Line(points={{-2,-48},{-16,-48},
{-16,-60},{-59,-60}}, color={255,0,255}));
connect(heaIsOn.y, cooValOrHea.u1) annotation (Line(points={{-25,20},{-16,20},
{-16,-40},{-2,-40}}, color={255,0,255}));
connect(conFal.y, swiHeaCooYSet.u2) annotation (Line(points={{-39,-30},{-28,-30},
{-28,-10},{28,-10},{28,70}}, color={255,0,255}));
annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={
Rectangle(
extent={{-100,100},{100,-100}},
lineColor={28,108,200},
fillColor={255,255,255},
fillPattern=FillPattern.Solid)}), Diagram(
coordinateSystem(preserveAspectRatio=false)),
annotation (Line(points={{-102,-70},{-140,-70}},color={0,0,127}));
connect(swiYSet.y, swiSecForCoo.u1) annotation (Line(points={{81,50},{86,50},{86,
26},{58,26},{58,-2},{78,-2}}, color={0,0,127}));
connect(PIDCoo.u_s, TRooMea) annotation (Line(points={{-22,70},{-30,70},{-30,66},
{-108,66},{-108,0},{-140,0}},
color={0,0,127}));
connect(PIDHea.u_m, TRooMea) annotation (Line(points={{-48,78},{-48,66},{-108,66},
{-108,0},{-140,0}},color={0,0,127}));
connect(PIDCoo.y, swiHeaCooYSet.u1) annotation (Line(points={{1,70},{6,70},{6,62},
{18,62}}, color={0,0,127}));
connect(swiHeaCooYSet.y, swiYSet.u1) annotation (Line(points={{41,70},{50,70},{50,
58},{58,58}}, color={0,0,127}));
connect(heaOrCooIsOn.u2, conFal.y) annotation (Line(points={{-22,2},{-26,2},{-26,
-10},{-50,-10},{-50,-40},{-59,-40}},
color={255,0,255}));
connect(hysCoo.y, heaOrCooIsOn.u2) annotation (Line(points={{-79,-10},{-26,-10},
{-26,2},{-22,2}},color={255,0,255}));
connect(heaIsOn.y, hea) annotation (Line(points={{-39,20},{-30,20},{-30,-60},{130,
-60}}, color={255,0,255}));
connect(cooValOrHea.y, swiSecForCoo.u2) annotation (Line(points={{1,-90},{36,-90},
{36,-10},{78,-10}}, color={255,0,255}));
connect(cooValOrHea.u2, conTru.y) annotation (Line(points={{-22,-98},{-32,-98},{
-32,-100},{-39,-100}}, color={255,0,255}));
connect(cooValOrHea.u2, hysSecCoo.y) annotation (Line(points={{-22,-98},{-32,-98},
{-32,-70},{-79,-70}}, color={255,0,255}));
connect(heaIsOn.y, cooValOrHea.u1) annotation (Line(points={{-39,20},{-30,20},{-30,
-90},{-22,-90}}, color={255,0,255}));
if not witCoo then
connect(PIDHea.y, swiYSet.u1) annotation (Line(
points={{-37,90},{50,90},{50,58},{58,58}},
color={0,0,127},
pattern=LinePattern.Dash));
end if;
annotation ( Diagram(
coordinateSystem(extent={{-120,-120},{120,120}})),
Documentation(info="<html>
<p>
Helper control model for the example
Expand All @@ -185,5 +192,17 @@ equation
\"https://github.com/ibpsa/modelica-ibpsa/issues/1576\">#1576</a>)
</li>
</ul>
</html>"));
</html>"),
Icon(coordinateSystem(extent={{-120,-120},{120,120}}), graphics={
Text(
extent={{-153,163},{147,123}},
textColor={0,0,255},
fillPattern=FillPattern.HorizontalCylinder,
fillColor={0,127,255},
textString="%name"),
Rectangle(
extent={{-120,120},{120,-120}},
lineColor={0,0,0},
fillColor={255,255,255},
fillPattern=FillPattern.Solid)}));
end OneRoomRadiatorHeatPumpControl;
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,11 @@ equation
{-132,-140},{-132,-180},{-122,-180}}, color={255,0,255}));
connect(conPumAlwOn.y, booToReaPumCon.u) annotation (Line(points={{-143,-140},
{-132,-140},{-132,-110},{-122,-110}}, color={255,0,255}));
connect(oneRooRadHeaPumCtr.TRadSup, temSup.T) annotation (Line(points={{-162,-77},
{-188,-77},{-188,-20},{-81,-20}}, color={0,
connect(oneRooRadHeaPumCtr.TRadSup, temSup.T) annotation (Line(points={{
-161.667,-75.8333},{-188,-75.8333},{-188,-20},{-81,-20}}, color={0,
0,127}));
connect(oneRooRadHeaPumCtr.TRooMea, temRoo.T) annotation (Line(points={{-162,-70},
{-180,-70},{-180,30},{-49,30}}, color={0,0,127}));
connect(oneRooRadHeaPumCtr.TRooMea, temRoo.T) annotation (Line(points={{
-161.667,-70},{-180,-70},{-180,30},{-49,30}}, color={0,0,127}));
annotation (Documentation(info="<html>
<p>
Motivated by the example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ model LargeScaleWaterToWater_OneRoomRadiator
Q_flow_nominal=200000,
sin(nPorts=1),
booToReaPumEva(realTrue=heaPum.mEva_flow_nominal),
oneRooRadHeaPumCtr(PIDHea(Ti=10)),
pumHeaPum(
redeclare IBPSA.Fluid.Movers.Data.Pumps.Wilo.VeroLine80slash115dash2comma2slash2 per),
pumHeaPumSou(
Expand Down Expand Up @@ -42,7 +41,8 @@ equation
connect(heaPum.port_a1, temRet.port_b) annotation (Line(points={{20,-144},{60,
-144},{60,-30}}, color={0,127,255}));
connect(oneRooRadHeaPumCtr.ySet, heaPum.ySet) annotation (Line(
points={{-139,-66},{-62,-66},{-62,-76},{21.2,-76},{21.2,-148}}, color={
points={{-139.167,-66.6667},{26,-66.6667},{26,-148},{21.2,-148}},
color={
0,0,127}));
annotation (
__Dymola_Commands(file=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ model ReversibleAirToWater2D_OneRoomRadiator
sin(nPorts=1, redeclare package Medium = MediumAir),
booToReaPumEva(realTrue=heaPum.mEva_flow_nominal),
pumHeaPumSou(redeclare package Medium = MediumAir),
sou(redeclare package Medium = MediumAir));
sou(use_T_in=true,
redeclare package Medium = MediumAir));

IBPSA.Fluid.HeatPumps.ModularReversible.ReversibleAirToWaterTableData2D
heaPum(
redeclare package MediumCon = MediumWat,
redeclare package MediumEva = MediumAir,
TCon_start=TRadSup_nominal,
QHea_flow_nominal=Q_flow_nominal,
use_intSafCtr=true,
TCon_nominal=TRadSup_nominal,
Expand All @@ -32,10 +34,21 @@ model ReversibleAirToWater2D_OneRoomRadiator
safCtrParEurNor(
use_minOnTime=false,
use_minOffTime=true,
minOffTime=300,
use_maxCycRat=true)) "Reversible heat pump based on 2D table data"
annotation (Placement(transformation(extent={{20,-160},{0,-140}})));
extends Modelica.Icons.Example;

Modelica.Blocks.Sources.Pulse TAirSouSte(
amplitude=20,
width=10,
period=86400,
offset=283.15,
startTime=86400/2) if witCoo "Air source temperature step for cooling phase"
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=0,
origin={-150,-210})));
equation
connect(heaPum.port_b2, sin.ports[1]) annotation (Line(points={{20,-156},{38,
-156},{38,-200},{60,-200}}, color={0,127,255}));
Expand All @@ -46,11 +59,13 @@ equation
connect(heaPum.port_a1, temRet.port_b) annotation (Line(points={{20,-144},{60,
-144},{60,-30}}, color={0,127,255}));
connect(oneRooRadHeaPumCtr.ySet, heaPum.ySet) annotation (Line(
points={{-139,-66},{21.2,-66},{21.2,-148}}, color=
points={{-139.167,-66.6667},{21.2,-66.6667},{21.2,-148}}, color=
{0,0,127}));
connect(heaPum.hea, oneRooRadHeaPumCtr.hea) annotation (Line(
points={{21.1,-151.9},{24,-151.9},{24,-152},{26,-152},{26,-76},{-139,-76}},
color={255,0,255}));
points={{21.1,-151.9},{24,-151.9},{24,-152},{26,-152},{26,-75},{-139.167,
-75}}, color={255,0,255}));
connect(TAirSouSte.y, sou.T_in) annotation (Line(points={{-139,-210},{-94,-210},
{-94,-196},{-82,-196}}, color={0,0,127}));
annotation (
__Dymola_Commands(file=
"modelica://IBPSA/Resources/Scripts/Dymola/Fluid/HeatPumps/ModularReversible/Examples/ReversibleAirToWater2D_OneRoomRadiator.mos"
Expand Down
Loading

0 comments on commit 2485150

Please sign in to comment.