Skip to content

Commit

Permalink
Merge pull request #1872 from ibpsa/issue1576_heatPumpModelIntegratio…
Browse files Browse the repository at this point in the history
…n_strings

Removed use of string connectors.
Introduced boolean parameter to allow different device id.
  • Loading branch information
mwetter authored May 2, 2024
2 parents be08c48 + f02cce3 commit b0e18d3
Show file tree
Hide file tree
Showing 24 changed files with 96 additions and 185 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
within IBPSA.Fluid.Chillers.ModularReversible.BaseClasses;
model RefrigerantCycle "Refrigerant cycle model of a chiller"
extends IBPSA.Fluid.HeatPumps.ModularReversible.BaseClasses.PartialModularRefrigerantCycle;

parameter Boolean allowDifferentDeviceIdentifiers=false
"if use_rev=true, device data for cooling and heating need to entered. Set allowDifferentDeviceIdentifiers=true to allow different device identifiers devIde"
annotation(Dialog(enable=use_rev));

replaceable model RefrigerantCycleChillerCooling =
IBPSA.Fluid.Chillers.ModularReversible.RefrigerantCycle.BaseClasses.NoCooling(
useInChi=true)
Expand All @@ -25,26 +30,20 @@ model RefrigerantCycle "Refrigerant cycle model of a chiller"
annotation (Placement(transformation(extent={{-60,38},{-19,80}}, rotation=0)));

protected
IBPSA.Utilities.IO.Strings.StringPassThrough strPasThr
"String pass through to enable conditional string data";
IBPSA.Utilities.IO.Strings.Constant conStrSou(
final k=refCycChiCoo.datSou)
"Constant String data source";
parameter String devIde =
if use_rev then refCycChiHea.devIde else refCycChiCoo.devIde
"Data source for refrigerant cycle";

initial algorithm
assert(
strPasThr.y == refCycChiCoo.datSou,
"In " + getInstanceName() + ": Data sources for reversible operation are not equal.
Cooling data source is " + refCycChiCoo.datSou + ", heating data source is "
+ strPasThr.y + ". Only continue if this is intended.",
AssertionLevel.warning);
equation
if use_rev then
connect(refCycChiHea.datSouOut, strPasThr.u);
else
connect(conStrSou.y, strPasThr.u);
if not allowDifferentDeviceIdentifiers then
assert(
devIde == refCycChiCoo.devIde,
"In " + getInstanceName() + ": Device identifiers devIde for reversible operation are not equal.
Cooling device identifier is '" + refCycChiCoo.devIde + "' but heating is '"
+ devIde + "'. To allow this, set 'allowDifferentDeviceIdentifiers=true'.",
AssertionLevel.error);
end if;

equation
connect(pasTrhModSet.u, sigBus.coo);

connect(sigBus,refCycChiHea.sigBus) annotation (Line(
Expand Down Expand Up @@ -152,7 +151,13 @@ equation
fillPattern=FillPattern.HorizontalCylinder,
fillColor={0,127,255},
textString="%name")}), Diagram(coordinateSystem(preserveAspectRatio=false)),
Documentation(revisions="<html><ul>
Documentation(revisions="<html>
<ul>
<li>
May 2, 2024, by Michael Wetter:<br/>
Refactored check for device identifiers.<br/>
This is for <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1576\">IBPSA, #1576</a>.
</li>
<li>
<i>May 22, 2019,</i> by Julian Matthes:<br/>
First implementation (see issue <a href=
Expand Down
1 change: 1 addition & 0 deletions IBPSA/Fluid/Chillers/ModularReversible/CarnotWithLosses.mo
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ model CarnotWithLosses
TAppCon_nominal=TAppCon_nominal,
TAppEva_nominal=TAppEva_nominal,
etaCarnot_nominal=etaCarnot_nominal),
final allowDifferentDeviceIdentifiers=false,
redeclare model RefrigerantCycleInertia =
IBPSA.Fluid.HeatPumps.ModularReversible.RefrigerantCycle.Inertias.VariableOrder
(
Expand Down
1 change: 1 addition & 0 deletions IBPSA/Fluid/Chillers/ModularReversible/Examples/Modular.mo
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ model Modular
redeclare package MediumCon = MediumCon,
redeclare package MediumEva = MediumEva,
use_rev=true,
allowDifferentDeviceIdentifiers=true,
QCoo_flow_nominal=-30000,
redeclare model RefrigerantCycleInertia =
IBPSA.Fluid.HeatPumps.ModularReversible.RefrigerantCycle.Inertias.VariableOrder
Expand Down
14 changes: 10 additions & 4 deletions IBPSA/Fluid/Chillers/ModularReversible/Modular.mo
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ model Modular
mCon_flow_nominal=(PEle_nominal - QCoo_flow_nominal)/(dTCon_nominal*cpCon),
use_rev=false,
redeclare final IBPSA.Fluid.Chillers.ModularReversible.BaseClasses.RefrigerantCycle refCyc(
redeclare model RefrigerantCycleChillerCooling =
RefrigerantCycleChillerCooling, redeclare model
RefrigerantCycleChillerHeating = RefrigerantCycleChillerHeating));
redeclare model RefrigerantCycleChillerCooling = RefrigerantCycleChillerCooling,
redeclare model RefrigerantCycleChillerHeating = RefrigerantCycleChillerHeating,
final allowDifferentDeviceIdentifiers=allowDifferentDeviceIdentifiers));
parameter Modelica.Units.SI.HeatFlowRate QCoo_flow_nominal(max=0)
"Nominal cooling capcaity"
annotation(Dialog(group="Nominal condition"));
Expand Down Expand Up @@ -104,7 +104,13 @@ equation
horizontalAlignment=TextAlignment.Right));
annotation (Icon(coordinateSystem(extent={{-100,-100},{100,100}})),
Diagram(coordinateSystem(extent={{-140,-160},{140,160}})),
Documentation(revisions="<html><ul>
Documentation(revisions="<html>
<ul>
<li>
May 2, 2024, by Michael Wetter:<br/>
Refactored check for device identifiers.<br/>
This is for <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1576\">IBPSA, #1576</a>.
</li>
<li>
<i>May 22, 2019,</i> by Julian Matthes:<br/>
First implementation (see issue <a href=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ model NoCooling
redeclare final
IBPSA.Fluid.HeatPumps.ModularReversible.RefrigerantCycle.Frosting.NoFrosting
iceFacCal,
datSou="",
devIde="NoCooling",
QCoo_flow_nominal=0);

Modelica.Blocks.Sources.Constant const(final k=0) "Zero energy flows"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ model ConstantCarnotEffectiveness "Carnot EER with a constant Carnot effectivene
IBPSA.Fluid.Chillers.ModularReversible.RefrigerantCycle.BaseClasses.PartialChillerCycle(
useInChi=true,
PEle_nominal=-QCoo_flow_nominal/EER_nominal,
datSou="ConstantCarnotEffectiveness");
devIde="ConstantCarnotEffectiveness");
extends
IBPSA.Fluid.HeatPumps.ModularReversible.RefrigerantCycle.BaseClasses.PartialCarnot(
TAppCon_nominal=if cpCon < 1500 then 5 else 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ model TableData2D
"Performance data based on condenser outlet and evaporator inlet temperature"
extends
IBPSA.Fluid.Chillers.ModularReversible.RefrigerantCycle.BaseClasses.PartialChillerCycle(
final datSou=datTab.devIde,
final devIde=datTab.devIde,
PEle_nominal=Modelica.Blocks.Tables.Internal.getTable2DValueNoDer2(
tabIdePEle,
TEva_nominal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ partial model PartialReversibleRefrigerantMachine
parameter Boolean use_rev=true
"=true if the chiller or heat pump is reversible"
annotation(choices(checkBox=true));
parameter Boolean allowDifferentDeviceIdentifiers=false
"if use_rev=true, device data for cooling and heating need to entered. Set allowDifferentDeviceIdentifiers=true to allow different device identifiers devIde"
annotation(Dialog(tab="Advanced", enable=use_rev));

//Condenser
parameter Modelica.Units.SI.Time tauCon=30
Expand Down Expand Up @@ -685,6 +688,11 @@ equation
fillPattern=FillPattern.Solid)}),
Diagram(coordinateSystem(extent={{-140,-160},{140,160}})),
Documentation(revisions="<html><ul>
<li>
May 2, 2024, by Michael Wetter:<br/>
Refactored check for device identifiers.<br/>
This is for <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1576\">IBPSA, #1576</a>.
</li>
<li>
<i>October 2, 2022</i> by Fabian Wuellhorst:<br/>
Adjusted based on the discussion in this issue <a href=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ within IBPSA.Fluid.HeatPumps.ModularReversible.BaseClasses;
model RefrigerantCycle
"Refrigerant cycle model of a heat pump"
extends IBPSA.Fluid.HeatPumps.ModularReversible.BaseClasses.PartialModularRefrigerantCycle;

parameter Boolean allowDifferentDeviceIdentifiers=false
"if use_rev=true, device data for cooling and heating need to entered. Set allowDifferentDeviceIdentifiers=true to allow different device identifiers devIde"
annotation(Dialog(enable=use_rev));

replaceable model RefrigerantCycleHeatPumpHeating =
IBPSA.Fluid.HeatPumps.ModularReversible.RefrigerantCycle.BaseClasses.NoHeating(
useInHeaPum=true)
Expand All @@ -26,26 +31,21 @@ model RefrigerantCycle
annotation (Placement(transformation(extent={{-60,40},{-19,80}}, rotation=0)));

protected
IBPSA.Utilities.IO.Strings.StringPassThrough strPasThr
"String pass through to enable conditional string data";
IBPSA.Utilities.IO.Strings.Constant conStrSou(
final k=refCycHeaPumHea.datSou)
"Constant String data source";
parameter String devIde =
if use_rev then refCycHeaPumCoo.devIde else refCycHeaPumHea.devIde
"Data source for refrigerant cycle";

initial algorithm
assert(
strPasThr.y == refCycHeaPumHea.datSou,
"In " + getInstanceName() + ": Data sources for reversible operation are not equal.
Heating data source is " + refCycHeaPumHea.datSou + ", cooling data source is "
+ strPasThr.y + ". Only continue if this is intended.",
AssertionLevel.warning);
if not allowDifferentDeviceIdentifiers then
assert(
devIde == refCycHeaPumHea.devIde,
"In " + getInstanceName() + ": Device identifiers devIde for reversible operation are not equal.
Heating device identifier is '" + refCycHeaPumHea.devIde + "' but cooling is '"
+ devIde + "'. To allow this, set 'allowDifferentDeviceIdentifiers=true'.",
AssertionLevel.error);
end if;

equation
if use_rev then
connect(refCycHeaPumCoo.datSouOut, strPasThr.u);
else
connect(conStrSou.y, strPasThr.u);
end if;
connect(pasTrhModSet.u, sigBus.hea);

connect(sigBus,refCycHeaPumCoo.sigBus) annotation (Line(
Expand Down Expand Up @@ -84,8 +84,9 @@ equation
-53.1667,38.3333},{-53.1667,-8},{-58,-8}}, color={0,0,127}));
connect(refCycHeaPumCoo.PEle, swiPEle.u3) annotation (Line(points={{-39.5,
38.3333},{-39.5,-48},{-8,-48},{-8,-58}}, color={0,0,127}));
connect(refCycHeaPumHea.PEle, swiPEle.u1) annotation (Line(points={{40,38.3333},
{40,-48},{8,-48},{8,-58}}, color={0,0,127}));
connect(refCycHeaPumHea.PEle, swiPEle.u1) annotation (Line(points={{40,
38.3333},{40,-48},{8,-48},{8,-58}},
color={0,0,127}));

annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={
Ellipse(
Expand Down Expand Up @@ -148,6 +149,11 @@ equation
textString="%name")}),
Diagram(coordinateSystem(preserveAspectRatio=false)),
Documentation(revisions="<html><ul>
<li>
May 2, 2024, by Michael Wetter:<br/>
Refactored check for device identifiers.<br/>
This is for <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1576\">IBPSA, #1576</a>.
</li>
<li>
<i>October 2, 2022</i> by Fabian Wuellhorst:<br/>
Adjusted based on the discussion in this issue <a href=
Expand Down
6 changes: 6 additions & 0 deletions IBPSA/Fluid/HeatPumps/ModularReversible/CarnotWithLosses.mo
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ model CarnotWithLosses
etaCarnot_nominal=etaCarnot_nominal,
TAppCon_nominal=TAppCon_nominal,
TAppEva_nominal=TAppEva_nominal),
final allowDifferentDeviceIdentifiers=false,
final use_evaCap,
final use_conCap,
redeclare model RefrigerantCycleInertia =
Expand Down Expand Up @@ -89,6 +90,11 @@ initial algorithm
</p>
</html>", revisions="<html>
<ul>
<li>
May 2, 2024, by Michael Wetter:<br/>
Refactored check for device identifiers.<br/>
This is for <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1576\">IBPSA, #1576</a>.
</li>
<li>
<i>October 2, 2022</i> by Fabian Wuellhorst:<br/>
First implementation (see issue <a href=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ model LargeScaleWaterToWater_OneRoomRadiator
redeclare IBPSA.Fluid.Movers.Data.Pumps.Wilo.VeroLine80slash115dash2comma2slash2 per));

IBPSA.Fluid.HeatPumps.ModularReversible.LargeScaleWaterToWater heaPum(
allowDifferentDeviceIdentifiers=true,
QHea_flow_nominal=Q_flow_nominal,
use_intSafCtr=true,
TConHea_nominal=TRadSup_nominal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ model Modular_OneRoomRadiator
redeclare package MediumCon = MediumWat,
redeclare package MediumEva = MediumAir,
use_rev=true,
allowDifferentDeviceIdentifiers=true,
QHea_flow_nominal=Q_flow_nominal,
redeclare model RefrigerantCycleInertia =
IBPSA.Fluid.HeatPumps.ModularReversible.RefrigerantCycle.Inertias.NoInertia,
Expand Down Expand Up @@ -105,6 +106,11 @@ equation
</p>
</html>", revisions="<html>
<ul>
<li>
May 2, 2024, by Michael Wetter:<br/>
Refactored check for device identifiers.<br/>
This is for <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1576\">IBPSA, #1576</a>.
</li>
<li>
<i>October 2, 2022</i> by Fabian Wuellhorst:<br/>
First implementation (see issue <a href=
Expand Down
8 changes: 7 additions & 1 deletion IBPSA/Fluid/HeatPumps/ModularReversible/Modular.mo
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ model Modular
redeclare model RefrigerantCycleHeatPumpHeating =
RefrigerantCycleHeatPumpHeating,
redeclare model RefrigerantCycleHeatPumpCooling =
RefrigerantCycleHeatPumpCooling));
RefrigerantCycleHeatPumpCooling,
final allowDifferentDeviceIdentifiers=allowDifferentDeviceIdentifiers));
parameter Modelica.Units.SI.HeatFlowRate QHea_flow_nominal(min=Modelica.Constants.eps)
"Nominal heating capacity"
annotation (Dialog(group="Nominal condition"));
Expand Down Expand Up @@ -99,6 +100,11 @@ equation
Documentation(revisions="
<html>
<ul>
<li>
May 2, 2024, by Michael Wetter:<br/>
Refactored check for device identifiers.<br/>
This is for <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1576\">IBPSA, #1576</a>.
</li>
<li>
<i>October 2, 2022</i> by Fabian Wuellhorst:<br/>
Adjusted based on the discussion in this issue <a href=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ model NoHeating
redeclare final
IBPSA.Fluid.HeatPumps.ModularReversible.RefrigerantCycle.Frosting.NoFrosting
iceFacCal,
datSou="",
devIde="NoHeating",
QHea_flow_nominal=0);
Modelica.Blocks.Sources.Constant constZer(final k=0)
"No heating, hence, zero"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ partial model PartialRefrigerantCycle
parameter Modelica.Units.SI.Temperature TEva_nominal
"Nominal temperature at secondary evaporator side"
annotation (Dialog(group="Nominal condition"));
parameter String datSou=""
parameter String devIde=""
"Indicates the data source, used to warn users
about different data sources in reversible models";
about different vapor compression devices in reversible models";

replaceable IBPSA.Fluid.HeatPumps.ModularReversible.RefrigerantCycle.Frosting.NoFrosting iceFacCal
constrainedby
IBPSA.Fluid.HeatPumps.ModularReversible.RefrigerantCycle.Frosting.BaseClasses.PartialIcingFactor
Expand Down Expand Up @@ -62,13 +63,7 @@ partial model PartialRefrigerantCycle
rotation=270,
origin={-30,-90})));

IBPSA.Utilities.IO.Strings.StringOutput datSouOut
"String output of data source";
protected
IBPSA.Utilities.IO.Strings.Constant conStrSou(final k=datSou)
"Constant String with data source as output";
equation
connect(conStrSou.y, datSouOut);
connect(proRedQEva.y, QEva_flow) annotation (Line(points={{-30,-101},{-30,-108},
{80,-108},{80,-130}},color={0,0,127}));
connect(proRedQEva.y, redQCon.u1) annotation (Line(points={{-30,-101},{-30,-108},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ model ConstantCarnotEffectiveness "Carnot COP with a constant Carnot effectivene
IBPSA.Fluid.HeatPumps.ModularReversible.RefrigerantCycle.BaseClasses.PartialHeatPumpCycle(
useInHeaPum=true,
PEle_nominal=QHea_flow_nominal / COP_nominal,
datSou="ConstantCarnotEffectiveness");
devIde="ConstantCarnotEffectiveness");
extends
IBPSA.Fluid.HeatPumps.ModularReversible.RefrigerantCycle.BaseClasses.PartialCarnot(
TAppCon_nominal=if cpCon < 1500 then 5 else 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ within IBPSA.Fluid.HeatPumps.ModularReversible.RefrigerantCycle;
model TableData2D "Performance data based on condenser outlet and evaporator inlet temperature"
extends
IBPSA.Fluid.HeatPumps.ModularReversible.RefrigerantCycle.BaseClasses.PartialHeatPumpCycle(
final datSou=datTab.devIde,
final devIde=datTab.devIde,
PEle_nominal=Modelica.Blocks.Tables.Internal.getTable2DValueNoDer2(
tabIdePEle,
TCon_nominal,
Expand Down
Loading

0 comments on commit b0e18d3

Please sign in to comment.