Skip to content

Commit

Permalink
Make inertia replaceable
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian.wuellhorst committed May 11, 2022
1 parent 3e96e3e commit 73e125a
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 85 deletions.
Empty file.
109 changes: 28 additions & 81 deletions IBPSA/Fluid/BaseClasses/PartialReversibleVapourCompressionMachine.mo
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ partial model PartialReversibleVapourCompressionMachine
extent={{-27,-26},{27,26}},
rotation=90,
origin={0,-1})));

replaceable model vapComIne =
VapourCompressionInertias.BaseClasses.PartialInertia
constrainedby VapourCompressionInertias.BaseClasses.PartialInertia "Model for the inertia between the stationary black box data outputs and the inputs into the heat exchangers."
annotation (choicesAllMatching=true, Dialog(group="Inertia"));
parameter Boolean use_rev=true "Is the vapour compression machine reversible?" annotation(choices(checkBox=true), Dialog(descriptionLabel=true));
parameter Boolean use_autoCalc=false
"Enable automatic estimation of volumes and mass flows?"
Expand All @@ -34,15 +37,7 @@ partial model PartialReversibleVapourCompressionMachine
"Nominal usable heat flow of the vapour compression machine (HP: Heating; Chiller: Cooling)"
annotation (Dialog(enable=use_autoCalc));
parameter Real scalingFactor=1 "Scaling-factor of vapour compression machine";
parameter Boolean use_refIne=true
"Consider the inertia of the refrigerant cycle"
annotation(choices(checkBox=true), Dialog(
group="Refrigerant inertia"));
parameter Modelica.Units.SI.Frequency refIneFre_constant
"Cut off frequency for inertia of refrigerant cycle" annotation (Dialog(
enable=use_refIne, group="Refrigerant inertia"), Evaluate=true);
parameter Integer nthOrder=3 "Order of refrigerant cycle interia" annotation (Dialog(enable=
use_refIne, group="Refrigerant inertia"));

parameter Boolean useBusConnectorOnly = false "Set true to use bus connector for modeSet, ySet and iceFac input"
annotation(choices(checkBox=true), Dialog(group="Input Connectors"));

Expand Down Expand Up @@ -198,12 +193,7 @@ partial model PartialReversibleVapourCompressionMachine
parameter Modelica.Media.Interfaces.Types.MassFraction XEva_start[Medium_eva.nX]=
Medium_eva.X_default "Start value of mass fractions m_i/m"
annotation (Evaluate=true,Dialog(tab="Initialization", group="Evaporator"));
parameter Real x_start[nthOrder]=zeros(nthOrder)
"Initial or guess values of states"
annotation (Dialog(tab="Initialization", group="Refrigerant inertia", enable=use_refIne));
parameter Real yRefIne_start=0 "Initial or guess value of output (= state)"
annotation (Dialog(tab="Initialization", group="Refrigerant inertia",enable=initType ==
Init.InitialOutput and use_refIne));

//Dynamics
parameter Modelica.Fluid.Types.Dynamics massDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial
"Type of mass balance: dynamic (3 initialization options) or steady state (only affects fluid-models)"
Expand Down Expand Up @@ -268,43 +258,6 @@ partial model PartialReversibleVapourCompressionMachine
final GOut=GEvaOut*scalingFactor,
final GInn=GEvaIns*scalingFactor) "Heat exchanger model for the evaporator"
annotation (Placement(transformation(extent={{16,-70},{-16,-102}})));
Modelica.Blocks.Continuous.CriticalDamping heatFlowIneEva(
final initType=initType,
final normalized=true,
final n=nthOrder,
final f=refIneFre_constant,
final x_start=x_start,
final y_start=yRefIne_start)
if use_refIne
"This n-th order block represents the inertia of the refrigerant cycle and delays the heat flow"
annotation (Placement(transformation(
extent={{6,6},{-6,-6}},
rotation=90,
origin={-14,-52})));
Modelica.Blocks.Routing.RealPassThrough realPassThroughySetCon
if not use_refIne
"Use default ySet value" annotation (Placement(transformation(
extent={{-6,-6},{6,6}},
rotation=90,
origin={16,58})));
Modelica.Blocks.Continuous.CriticalDamping heatFlowIneCon(
final initType=initType,
final normalized=true,
final n=nthOrder,
final f=refIneFre_constant,
final x_start=x_start,
final y_start=yRefIne_start)
if use_refIne
"This n-th order block represents the inertia of the refrigerant cycle and delays the heat flow"
annotation (Placement(transformation(
extent={{-6,-6},{6,6}},
rotation=90,
origin={-16,58})));
Modelica.Blocks.Routing.RealPassThrough realPassThroughySetEva if not use_refIne
"Use default ySet value" annotation (Placement(transformation(
extent={{6,-6},{-6,6}},
rotation=90,
origin={16,-52})));
Modelica.Blocks.Interfaces.RealInput iceFac_in if not useBusConnectorOnly
"Input signal for icing factor" annotation (Placement(transformation(
extent={{-16,-16},{16,16}},
Expand Down Expand Up @@ -432,6 +385,16 @@ partial model PartialReversibleVapourCompressionMachine
rotation=180,
origin={-66,-28})));


vapComIne vapComIneCon annotation(Placement(transformation(
extent={{-7,-6},{7,6}},
rotation=90,
origin={0,53})));
vapComIne vapComIneEva annotation (Placement(transformation(
extent={{-6,-6},{6,6}},
rotation=270,
origin={0,-50})));

protected
parameter Modelica.Units.SI.MassFlowRate autoCalc_mFlow_min=0.3
"Realistic mass flow minimum for simulation plausibility";
Expand Down Expand Up @@ -509,22 +472,6 @@ equation
extent={{-3,-6},{-3,-6}},
horizontalAlignment=TextAlignment.Right));

connect(innerCycle.QEva, realPassThroughySetEva.u) annotation (Line(
points={{-1.77636e-15,-30.7},{-1.77636e-15,-38},{16,-38},{16,-44.8}},
color={0,0,127},
pattern=LinePattern.Dash));
connect(innerCycle.QEva, heatFlowIneEva.u) annotation (Line(
points={{-1.77636e-15,-30.7},{-1.77636e-15,-38},{-14,-38},{-14,-44.8}},
color={0,0,127},
pattern=LinePattern.Dash));
connect(innerCycle.QCon, heatFlowIneCon.u) annotation (Line(
points={{1.77636e-15,28.7},{1.77636e-15,30},{0,30},{0,40},{-16,40},{-16,50.8}},
color={0,0,127},
pattern=LinePattern.Dash));
connect(innerCycle.QCon, realPassThroughySetCon.u) annotation (Line(
points={{1.77636e-15,28.7},{0,28.7},{0,40},{16,40},{16,50.8}},
color={0,0,127},
pattern=LinePattern.Dash));
connect(innerCycle.sigBus, sigBus) annotation (Line(
points={{-26.78,-0.73},{-54,-0.73},{-54,-43},{-105,-43}},
color={255,204,51},
Expand Down Expand Up @@ -575,18 +522,6 @@ equation
pattern=LinePattern.Dash));
connect(port_b2, port_b2) annotation (Line(points={{-100,-60},{-100,-60},{-100,
-60}}, color={0,127,255}));
connect(realPassThroughySetCon.y, con.QFlow_in) annotation (Line(
points={{16,64.6},{16,77.04},{0,77.04}},
color={0,0,127},
pattern=LinePattern.Dash));
connect(heatFlowIneCon.y, con.QFlow_in) annotation (Line(
points={{-16,64.6},{-16,77.04},{0,77.04}},
color={0,0,127},
pattern=LinePattern.Dash));
connect(realPassThroughySetEva.y, eva.QFlow_in) annotation (Line(points={{16,-58.6},
{16,-69.04},{0,-69.04}}, color={0,0,127}));
connect(heatFlowIneEva.y, eva.QFlow_in) annotation (Line(points={{-14,-58.6},{
-14,-69.04},{0,-69.04}}, color={0,0,127}));
connect(senT_a2.port_b, eva.port_a)
annotation (Line(points={{28,-86},{16,-86}}, color={0,127,255}));
connect(senT_b2.port_a, eva.port_b)
Expand Down Expand Up @@ -637,6 +572,18 @@ equation
index=1,
extent={{-6,3},{-6,3}},
horizontalAlignment=TextAlignment.Right));
connect(innerCycle.QEva, vapComIneEva.u) annotation (Line(points={{-1.77636e-15,
-30.7},{-1.77636e-15,-36.55},{1.33227e-15,-36.55},{1.33227e-15,-42.8}},
color={0,0,127}));
connect(eva.QFlow_in, vapComIneEva.y) annotation (Line(points={{1.11022e-16,-69.04},
{1.11022e-16,-64.92},{-1.11022e-15,-64.92},{-1.11022e-15,-56.6}},
color={0,0,127}));
connect(vapComIneCon.y, con.QFlow_in) annotation (Line(points={{3.33067e-16,60.7},
{3.33067e-16,65.77},{-1.11022e-16,65.77},{-1.11022e-16,77.04}}, color=
{0,0,127}));
connect(vapComIneCon.u, innerCycle.QCon) annotation (Line(points={{-3.33067e-16,
44.6},{-3.33067e-16,35.85},{1.77636e-15,35.85},{1.77636e-15,28.7}},
color={0,0,127}));
annotation (Icon(coordinateSystem(extent={{-100,-120},{100,120}}), graphics={
Rectangle(
extent={{-16,83},{16,-83}},
Expand Down
48 changes: 48 additions & 0 deletions IBPSA/Fluid/BaseClasses/VapourCompressionInertias.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
within IBPSA.Fluid.BaseClasses;
package VapourCompressionInertias
"Package with approaches to model inertia of vapour compression cycles"
model NoInertia "No inertia"
extends BaseClasses.PartialInertia;
equation
connect(u, y) annotation (Line(points={{-120,0},{110,0}}, color={0,0,127}));
annotation (Icon(graphics={Line(points={{-100,0},{102,0}}, color={0,0,127})}));
end NoInertia;

model VariableOrderInertia
"Inertia using a critical damper with variable order"
extends BaseClasses.PartialInertia;

parameter Modelica.Units.SI.Frequency refIneFre_constant
"Cut off frequency for inertia of refrigerant cycle" annotation (Dialog(
enable=use_refIne, group="Refrigerant inertia"), Evaluate=true);
parameter Integer nthOrder=3 "Order of refrigerant cycle interia" annotation (Dialog(enable=
use_refIne, group="Refrigerant inertia"));
parameter Real x_start[nthOrder]=zeros(nthOrder)
"Initial or guess values of states"
annotation (Dialog(tab="Initialization", group="Refrigerant inertia", enable=use_refIne));
parameter Real yRefIne_start=0 "Initial or guess value of output (= state)"
annotation (Dialog(tab="Initialization", group="Refrigerant inertia",enable=initType ==
Init.InitialOutput and use_refIne));
Modelica.Blocks.Continuous.CriticalDamping criticalDamping(
final n=nthOrder,
final f=refIneFre_constant,
final x_start=x_start)
annotation (Placement(transformation(extent={{-16,-16},{16,16}})));
equation
connect(u, criticalDamping.u)
annotation (Line(points={{-120,0},{-19.2,0}}, color={0,0,127}));
connect(criticalDamping.y, y)
annotation (Line(points={{17.6,0},{110,0}}, color={0,0,127}));
end VariableOrderInertia;

package BaseClasses
extends Modelica.Icons.BasesPackage;
partial model PartialInertia "Partial inertia model"
extends Modelica.Blocks.Interfaces.SISO;


annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
coordinateSystem(preserveAspectRatio=false)));
end PartialInertia;
end BaseClasses;
end VapourCompressionInertias;
1 change: 1 addition & 0 deletions IBPSA/Fluid/BaseClasses/package.order
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ FlowModels
Validation
PartialReversibleVapourCompressionMachine
PartialInnerCycle
VapourCompressionInertias
4 changes: 2 additions & 2 deletions IBPSA/Fluid/Chillers/Examples/Chiller.mo
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ model Chiller "Example for the reversible chiller model."
"Ramp signal for the temperature input of the sink side's ideal mass flow source"
annotation (Placement(transformation(extent={{-94,-76},{-74,-56}})));
IBPSA.Fluid.Chillers.Chiller chiller(
refIneFre_constant=1,
redeclare model vapComIne =
IBPSA.Fluid.BaseClasses.VapourCompressionInertias.NoInertia,
GConIns=0,
CEva=100,
GEvaOut=5,
Expand All @@ -43,7 +44,6 @@ model Chiller "Example for the reversible chiller model."
use_evaCap=false,
redeclare package Medium_con = Medium_sin,
redeclare package Medium_eva = Medium_sou,
use_refIne=false,
GEvaIns=0,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
redeclare model PerDataMainChi =
Expand Down
4 changes: 2 additions & 2 deletions IBPSA/Fluid/HeatPumps/Examples/HeatPump.mo
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ model HeatPump "Example for the reversible heat pump model."
rotation=-90,
origin={2,-76})));
IBPSA.Fluid.HeatPumps.HeatPump heatPump(
refIneFre_constant=1,
redeclare model vapComIne =
IBPSA.Fluid.BaseClasses.VapourCompressionInertias.NoInertia,
useBusConnectorOnly=true,
GConIns=0,
CEva=100,
Expand All @@ -46,7 +47,6 @@ model HeatPump "Example for the reversible heat pump model."
use_conCap=false,
redeclare package Medium_con = Medium_sin,
redeclare package Medium_eva = Medium_sou,
use_refIne=false,
use_rev=true,
GEvaIns=0,
redeclare model PerDataMainHP =
Expand Down

0 comments on commit 73e125a

Please sign in to comment.