From 3e4e74b7f4505fd94fc50136c55be6404fc7694a Mon Sep 17 00:00:00 2001 From: "fabian.wuellhorst" Date: Thu, 13 Oct 2022 16:12:38 +0200 Subject: [PATCH] Fix errors in OM by following the IBPSA changes and removing multiport in DHC models. For #1352. [skip-ci] --- .../Demands/OpenLoop/HeatPumpCarnot.mo | 2 +- .../Demands/OpenLoop/VarTSupplyDp.mo | 2 +- .../Demands/OpenLoop/VarTSupplyDpBypass.mo | 2 +- .../VarTSupplyDpFixedTempDifferenceBypass.mo | 2 +- .../DistrictHeatingCooling/Pipes/DHCPipe.mo | 84 ++---- .../Pipes/Examples/DHCPipe.mo | 18 +- .../Pipes/Examples/PlugFlowPipeEmbedded.mo | 3 +- .../Pipes/Examples/PlugFlowPipeZeta.mo | 3 +- .../Pipes/Examples/StaticPipe.mo | 5 +- .../Pipes/PlugFlowPipeEmbedded.mo | 11 +- .../Pipes/PlugFlowPipeZeta.mo | 33 ++- .../Pipes/StaticPipe.mo | 18 +- .../BaseClasses/PlugFlowCore.mo | 279 ------------------ .../BaseClasses/package.order | 1 - 14 files changed, 75 insertions(+), 388 deletions(-) delete mode 100644 AixLib/Fluid/FixedResistances/BaseClasses/PlugFlowCore.mo diff --git a/AixLib/Fluid/DistrictHeatingCooling/Demands/OpenLoop/HeatPumpCarnot.mo b/AixLib/Fluid/DistrictHeatingCooling/Demands/OpenLoop/HeatPumpCarnot.mo index 6e08aac203..2e179bc9c7 100644 --- a/AixLib/Fluid/DistrictHeatingCooling/Demands/OpenLoop/HeatPumpCarnot.mo +++ b/AixLib/Fluid/DistrictHeatingCooling/Demands/OpenLoop/HeatPumpCarnot.mo @@ -78,7 +78,7 @@ public extent={{10,10},{-10,-10}}, rotation=180, origin={-90,50}))); - Modelica.Blocks.Math.Gain gain(k=cp_default) + Modelica.Blocks.Math.Gain gain(k(unit="J/(kg.K)")=cp_default, y(unit="J/(kg.K)")) annotation (Placement(transformation(extent={{-32,40},{-12,60}}))); Modelica.Blocks.Math.Division hea2MasFlo annotation (Placement(transformation( extent={{-10,-10},{10,10}}, diff --git a/AixLib/Fluid/DistrictHeatingCooling/Demands/OpenLoop/VarTSupplyDp.mo b/AixLib/Fluid/DistrictHeatingCooling/Demands/OpenLoop/VarTSupplyDp.mo index 050ab1bc9c..40bc9ded68 100644 --- a/AixLib/Fluid/DistrictHeatingCooling/Demands/OpenLoop/VarTSupplyDp.mo +++ b/AixLib/Fluid/DistrictHeatingCooling/Demands/OpenLoop/VarTSupplyDp.mo @@ -61,7 +61,7 @@ public extent={{10,10},{-10,-10}}, rotation=180, origin={-90,46}))); - Modelica.Blocks.Math.Gain gain(k=cp_default) + Modelica.Blocks.Math.Gain gain(k(unit="J/(kg.K)")=cp_default, y(unit="J/(kg.K)")) annotation (Placement(transformation(extent={{-26,54},{-6,74}}))); Modelica.Blocks.Math.Division hea2MasFlo annotation (Placement(transformation( extent={{-10,-10},{10,10}}, diff --git a/AixLib/Fluid/DistrictHeatingCooling/Demands/OpenLoop/VarTSupplyDpBypass.mo b/AixLib/Fluid/DistrictHeatingCooling/Demands/OpenLoop/VarTSupplyDpBypass.mo index e3fa261ac2..e1b44bf712 100644 --- a/AixLib/Fluid/DistrictHeatingCooling/Demands/OpenLoop/VarTSupplyDpBypass.mo +++ b/AixLib/Fluid/DistrictHeatingCooling/Demands/OpenLoop/VarTSupplyDpBypass.mo @@ -64,7 +64,7 @@ public extent={{10,10},{-10,-10}}, rotation=180, origin={-90,46}))); - Modelica.Blocks.Math.Gain gain(k=cp_default) + Modelica.Blocks.Math.Gain gain(k(unit="J/(kg.K)")=cp_default, y(unit="J/(kg.K)")) annotation (Placement(transformation(extent={{-26,54},{-6,74}}))); Modelica.Blocks.Math.Division hea2MasFlo annotation (Placement(transformation( extent={{-10,-10},{10,10}}, diff --git a/AixLib/Fluid/DistrictHeatingCooling/Demands/OpenLoop/VarTSupplyDpFixedTempDifferenceBypass.mo b/AixLib/Fluid/DistrictHeatingCooling/Demands/OpenLoop/VarTSupplyDpFixedTempDifferenceBypass.mo index e08d00d5d3..0b9ee225f1 100644 --- a/AixLib/Fluid/DistrictHeatingCooling/Demands/OpenLoop/VarTSupplyDpFixedTempDifferenceBypass.mo +++ b/AixLib/Fluid/DistrictHeatingCooling/Demands/OpenLoop/VarTSupplyDpFixedTempDifferenceBypass.mo @@ -54,7 +54,7 @@ public annotation (Placement(transformation(extent={{-10,-10},{10,10}}, rotation=0, origin={80,0}))); - Modelica.Blocks.Math.Gain gain(k=cp_default) + Modelica.Blocks.Math.Gain gain(k(unit="J/(kg.K)")=cp_default, y(unit="J/(kg.K)")) annotation (Placement(transformation(extent={{-40,104},{-20,124}}))); Modelica.Blocks.Math.Division hea2MasFlo annotation (Placement(transformation( extent={{-10,-10},{10,10}}, diff --git a/AixLib/Fluid/DistrictHeatingCooling/Pipes/DHCPipe.mo b/AixLib/Fluid/DistrictHeatingCooling/Pipes/DHCPipe.mo index 3da3ace663..31ffec7140 100644 --- a/AixLib/Fluid/DistrictHeatingCooling/Pipes/DHCPipe.mo +++ b/AixLib/Fluid/DistrictHeatingCooling/Pipes/DHCPipe.mo @@ -1,6 +1,6 @@ within AixLib.Fluid.DistrictHeatingCooling.Pipes; model DHCPipe "Generic pipe model for DHC applications" - extends AixLib.Fluid.Interfaces.PartialTwoPortVector(show_T=true); + extends AixLib.Fluid.Interfaces.PartialTwoPortInterface(show_T=true); parameter Boolean use_zeta=false "= true HydraulicResistance is implemented, zeta value has to be given next" @@ -124,12 +124,15 @@ model DHCPipe "Generic pipe model for DHC applications" "Heat transfer to or from surroundings (heat loss from pipe results in a positive heat flow)" annotation (Placement(transformation(extent={{-10,90},{10,110}}))); - replaceable AixLib.Fluid.FixedResistances.BaseClasses.PlugFlowCore pipCor( + replaceable AixLib.Fluid.FixedResistances.PlugFlowPipe pipCor( redeclare final package Medium = Medium, final dh=dh, final v_nominal=v_nominal, final length=length, - final C=C, + dIns=dIns, + kIns=kIns, + cPip=cPip, + rhoPip=rhoPip, final R=R, final m_flow_small=m_flow_small, final m_flow_nominal=m_flow_nominal, @@ -144,27 +147,7 @@ model DHCPipe "Generic pipe model for DHC applications" final roughness=roughness, final allowFlowReversal=allowFlowReversal, final homotopyInitialization=homotopyInitialization, - final linearized=linearized) constrainedby Interfaces.PartialTwoPort( - redeclare package Medium = Medium, - dh=dh, - v_nominal=v_nominal, - length=length, - C=C, - R=R, - m_flow_small=m_flow_small, - m_flow_nominal=m_flow_nominal, - T_start_in=T_start_in, - T_start_out=T_start_out, - m_flow_start=m_flow_start, - initDelay=initDelay, - from_dp=from_dp, - fac=if not use_zeta then fac else 1.0, - ReC=ReC, - thickness=thickness, - roughness=roughness, - allowFlowReversal=allowFlowReversal, - homotopyInitialization=homotopyInitialization, - linearized=linearized) "Describing the pipe behavior" annotation (choices( + final linearized=linearized) constrainedby Interfaces.PartialTwoPort "Describing the pipe behavior" annotation (choices( choice(redeclare AixLib.Fluid.DistrictHeatingCooling.Pipes.BaseClassesStatic.StaticCore pipCor "Static core"), choice(redeclare @@ -181,7 +164,7 @@ model DHCPipe "Generic pipe model for DHC applications" redeclare final package Medium = Medium, final m_flow_nominal=m_flow_nominal, final V=if rho_default > 500 then VEqu else VEqu/1000, - final nPorts=nPorts + 1, + final nPorts=2, final T_start=T_start_out, final energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, final mSenFac = if rho_default > 500 then 1 else 10) @@ -220,7 +203,26 @@ model DHCPipe "Generic pipe model for DHC applications" T0=283.15) if use_soil annotation (Placement(transformation(extent={{-10,72},{10,92}}))); - + FixedResistances.HydraulicResistance hydRes( + diameter=dh, + m_flow_nominal=m_flow_nominal, + redeclare package Medium = Medium, + zeta=sum_zetas, + allowFlowReversal=allowFlowReversal, + from_dp=from_dp, + homotopyInitialization=homotopyInitialization, + linearized=linearized, + m_flow_start=m_flow_start) if use_zeta + annotation (Placement(transformation(extent={{-60,10},{-40,30}}))); + Modelica.Thermal.HeatTransfer.Components.ThermalCollector thePasThr(final m=1) + if not use_soil "Thermal pass through if there is no soil activated" + annotation (Placement(transformation( + extent={{-10,-10},{10,10}}, + rotation=180, + origin={-16,54}))); + Interfaces.PassThroughMedium pasThrMed(redeclare package Medium = Medium) + if not use_zeta + annotation (Placement(transformation(extent={{-60,-30},{-40,-10}}))); protected parameter Modelica.Units.SI.HeatCapacity CPip=length*((dh + 2*thickness)^2 - dh^2)*Modelica.Constants.pi/4*cPip*rhoPip "Heat capacity of pipe wall"; @@ -255,27 +257,7 @@ protected Modelica.Units.SI.Heat Q_gai(start=0.0, fixed=true) "Integrated heat gain of the pipe"; -public - FixedResistances.HydraulicResistance hydRes( - diameter=dh, - m_flow_nominal=m_flow_nominal, - redeclare package Medium = Medium, - zeta=sum_zetas, - allowFlowReversal=allowFlowReversal, - from_dp=from_dp, - homotopyInitialization=homotopyInitialization, - linearized=linearized, - m_flow_start=m_flow_start) if use_zeta - annotation (Placement(transformation(extent={{-60,10},{-40,30}}))); - Modelica.Thermal.HeatTransfer.Components.ThermalCollector thePasThr(final m=1) - if not use_soil "Thermal pass through if there is no soil activated" - annotation (Placement(transformation( - extent={{-10,-10},{10,10}}, - rotation=180, - origin={-16,54}))); - Interfaces.PassThroughMedium pasThrMed(redeclare package Medium = Medium) - if not use_zeta - annotation (Placement(transformation(extent={{-60,-30},{-40,-10}}))); + equation //calculation of the flow velocity of water in the pipes v_med = (4 * port_a.m_flow) / (Modelica.Constants.pi * rho_default * dh * dh); @@ -284,14 +266,12 @@ equation der(Q_los) = min(0, pipCor.heatPort.Q_flow); der(Q_gai) = max(0, pipCor.heatPort.Q_flow); - for i in 1:nPorts loop - connect(vol.ports[i + 1], ports_b[i]) - annotation (Line(points={{70,20},{72,20},{72,6},{72,0},{100,0}}, + connect(vol.ports[2], port_b) + annotation (Line(points={{71,20},{72,20},{72,6},{72,0},{100,0}}, color={0,127,255})); - end for; connect(pipCor.port_b, vol.ports[1]) - annotation (Line(points={{10,0},{70,0},{70,20}}, color={0,127,255})); + annotation (Line(points={{10,0},{69,0},{69,20}}, color={0,127,255})); connect(pipCor.heatPort, cylHeaTra1.port_a) annotation (Line(points={{0,10},{0,30}}, color={191,0,0}, pattern=LinePattern.Dash)); diff --git a/AixLib/Fluid/DistrictHeatingCooling/Pipes/Examples/DHCPipe.mo b/AixLib/Fluid/DistrictHeatingCooling/Pipes/Examples/DHCPipe.mo index 93b829a206..66fd0221d6 100644 --- a/AixLib/Fluid/DistrictHeatingCooling/Pipes/Examples/DHCPipe.mo +++ b/AixLib/Fluid/DistrictHeatingCooling/Pipes/Examples/DHCPipe.mo @@ -15,11 +15,9 @@ model DHCPipe "Simple example of DHCPipe and its four different modes" nPorts=1, p(displayUnit="Pa") = 101325) "Pressure boundary condition" annotation (Placement(transformation(extent={{72,40},{52,60}}))); - AixLib.Fluid.DistrictHeatingCooling.Pipes.DHCPipe pip( + AixLib.Fluid.DistrictHeatingCooling.Pipes.DHCPipe pip( redeclare package Medium = Medium, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, - redeclare BaseClassesStatic.StaticCore pipCor "Static core", - nPorts=1, dh=0.1, length=100, dIns=0.05, @@ -69,8 +67,6 @@ model DHCPipe "Simple example of DHCPipe and its four different modes" AixLib.Fluid.DistrictHeatingCooling.Pipes.DHCPipe pip1( redeclare package Medium = Medium, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, - redeclare FixedResistances.BaseClasses.PlugFlowCore pipCor "PlugFlow core", - nPorts=1, dh=0.1, length=100, dIns=0.05, @@ -117,8 +113,6 @@ model DHCPipe "Simple example of DHCPipe and its four different modes" redeclare package Medium = Medium, use_soil=true, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, - redeclare FixedResistances.BaseClasses.PlugFlowCore pipCor "PlugFlow core", - nPorts=1, dh=0.1, length=100, dIns=0.05, @@ -165,8 +159,6 @@ model DHCPipe "Simple example of DHCPipe and its four different modes" redeclare package Medium = Medium, sum_zetas=2.5, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, - redeclare FixedResistances.BaseClasses.PlugFlowCore pipCor "PlugFlow core", - nPorts=1, dh=0.1, length=100, dIns=0.05, @@ -203,7 +195,7 @@ equation connect(Tin.y, sou.T_in) annotation (Line(points={{-79,54},{-72,54}}, color={0,0,127})); - connect(pip.ports_b[1], senTemOut.port_a) + connect(pip.port_b, senTemOut.port_a) annotation (Line(points={{10,50},{20,50}}, color={0,127,255})); connect(senTemOut.port_b, sin.ports[1]) @@ -219,7 +211,7 @@ equation annotation (Line(points={{-80,90},{0,90},{0,20}}, color={191,0,0})); connect(Tin1.y, sou1.T_in) annotation (Line(points={{-79,14},{-72,14}}, color={0,0,127})); - connect(pip1.ports_b[1], senTemOut1.port_a) + connect(pip1.port_b, senTemOut1.port_a) annotation (Line(points={{10,10},{20,10}}, color={0,127,255})); connect(senTemOut1.port_b, sin1.ports[1]) annotation (Line(points={{40,10},{52,10}}, color={0,127,255})); @@ -231,7 +223,7 @@ equation annotation (Line(points={{-80,90},{0,90},{0,-22}}, color={191,0,0})); connect(Tin2.y, sou2.T_in) annotation (Line(points={{-79,-28},{-72,-28}}, color={0,0,127})); - connect(pip2.ports_b[1], senTemOut2.port_a) + connect(pip2.port_b, senTemOut2.port_a) annotation (Line(points={{10,-32},{20,-32}}, color={0,127,255})); connect(senTemOut2.port_b, sin2.ports[1]) annotation (Line(points={{40,-32},{52,-32}}, color={0,127,255})); @@ -243,7 +235,7 @@ equation annotation (Line(points={{-80,90},{0,90},{0,-60}}, color={191,0,0})); connect(Tin3.y, sou3.T_in) annotation (Line(points={{-79,-66},{-72,-66}}, color={0,0,127})); - connect(pip3.ports_b[1], senTemOut3.port_a) + connect(pip3.port_b, senTemOut3.port_a) annotation (Line(points={{10,-70},{20,-70}}, color={0,127,255})); connect(senTemOut3.port_b, sin3.ports[1]) annotation (Line(points={{40,-70},{52,-70}}, color={0,127,255})); diff --git a/AixLib/Fluid/DistrictHeatingCooling/Pipes/Examples/PlugFlowPipeEmbedded.mo b/AixLib/Fluid/DistrictHeatingCooling/Pipes/Examples/PlugFlowPipeEmbedded.mo index abb939f6e8..a9e75adf96 100644 --- a/AixLib/Fluid/DistrictHeatingCooling/Pipes/Examples/PlugFlowPipeEmbedded.mo +++ b/AixLib/Fluid/DistrictHeatingCooling/Pipes/Examples/PlugFlowPipeEmbedded.mo @@ -19,7 +19,6 @@ model PlugFlowPipeEmbedded "Simple example of PlugFlowPipeEmbedded" pip( redeclare package Medium = Medium, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyStateInitial, - nPorts=1, dh=0.1, length=100, dIns=0.05, @@ -60,7 +59,7 @@ equation color={191,0,0})); connect(Tin.y, sou.T_in) annotation (Line(points={{-71,4},{-62,4}}, color={0,0,127})); - connect(pip.ports_b[1], senTemOut.port_a) + connect(pip.port_b, senTemOut.port_a) annotation (Line(points={{20,0},{30,0}}, color={0,127,255})); connect(senTemOut.port_b, sin.ports[1]) annotation (Line(points={{50,0},{62,0}}, color={0,127,255})); diff --git a/AixLib/Fluid/DistrictHeatingCooling/Pipes/Examples/PlugFlowPipeZeta.mo b/AixLib/Fluid/DistrictHeatingCooling/Pipes/Examples/PlugFlowPipeZeta.mo index 581ef000c5..6a3d0babab 100644 --- a/AixLib/Fluid/DistrictHeatingCooling/Pipes/Examples/PlugFlowPipeZeta.mo +++ b/AixLib/Fluid/DistrictHeatingCooling/Pipes/Examples/PlugFlowPipeZeta.mo @@ -17,7 +17,6 @@ model PlugFlowPipeZeta "Simple example of PlugFlowPipe" annotation (Placement(transformation(extent={{82,-10},{62,10}}))); AixLib.Fluid.DistrictHeatingCooling.Pipes.PlugFlowPipeZeta pip( redeclare package Medium = Medium, - nPorts=1, dh=0.1, length=100, dIns=0.05, @@ -57,7 +56,7 @@ equation annotation (Line(points={{-20,70},{10,70},{10,10}}, color={191,0,0})); connect(Tin.y, sou.T_in) annotation (Line(points={{-71,4},{-62,4}}, color={0,0,127})); - connect(pip.ports_b[1], senTemOut.port_a) + connect(pip.port_b, senTemOut.port_a) annotation (Line(points={{20,0},{30,0}}, color={0,127,255})); connect(senTemOut.port_b, sin.ports[1]) annotation (Line(points={{50,0},{62,0}}, color={0,127,255})); diff --git a/AixLib/Fluid/DistrictHeatingCooling/Pipes/Examples/StaticPipe.mo b/AixLib/Fluid/DistrictHeatingCooling/Pipes/Examples/StaticPipe.mo index e274ce4d09..e772517988 100644 --- a/AixLib/Fluid/DistrictHeatingCooling/Pipes/Examples/StaticPipe.mo +++ b/AixLib/Fluid/DistrictHeatingCooling/Pipes/Examples/StaticPipe.mo @@ -11,13 +11,12 @@ model StaticPipe "Simple example of StaticPipe" annotation (Placement(transformation(extent={{-92,-6},{-72,14}}))); Sources.Boundary_pT sin( redeclare package Medium = Medium, - T=273.15 + 10, + T=323.15, nPorts=1, p(displayUnit="Pa") = 101325) "Pressure boundary condition" annotation (Placement(transformation(extent={{82,-10},{62,10}}))); AixLib.Fluid.DistrictHeatingCooling.Pipes.StaticPipe pip( redeclare package Medium = Medium, - nPorts=1, dh=0.1, length=100, dIns=0.05, @@ -57,7 +56,7 @@ equation annotation (Line(points={{-20,70},{10,70},{10,10}}, color={191,0,0})); connect(Tin.y, sou.T_in) annotation (Line(points={{-71,4},{-62,4}}, color={0,0,127})); - connect(pip.ports_b[1], senTemOut.port_a) + connect(pip.port_b, senTemOut.port_a) annotation (Line(points={{20,0},{30,0}}, color={0,127,255})); connect(senTemOut.port_b, sin.ports[1]) annotation (Line(points={{50,0},{62,0}}, color={0,127,255})); diff --git a/AixLib/Fluid/DistrictHeatingCooling/Pipes/PlugFlowPipeEmbedded.mo b/AixLib/Fluid/DistrictHeatingCooling/Pipes/PlugFlowPipeEmbedded.mo index 51b9f7f8c4..a5d95414c5 100644 --- a/AixLib/Fluid/DistrictHeatingCooling/Pipes/PlugFlowPipeEmbedded.mo +++ b/AixLib/Fluid/DistrictHeatingCooling/Pipes/PlugFlowPipeEmbedded.mo @@ -2,7 +2,7 @@ model PlugFlowPipeEmbedded "Embedded pipe model using spatialDistribution for temperature delay" - extends AixLib.Fluid.Interfaces.PartialTwoPortVector(show_T=true); + extends AixLib.Fluid.Interfaces.PartialTwoPortInterface(show_T=true); parameter Modelica.Fluid.Types.Dynamics energyDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial "Type of energy balance: dynamic (3 initialization options) or steady state" @@ -61,11 +61,11 @@ model PlugFlowPipeEmbedded parameter Modelica.Units.SI.Length thickness=0.0035 "Pipe wall thickness" annotation (Dialog(group="Material")); - parameter Modelica.Units.SI.Temperature T_start_in(start=Medium.T_default) = + parameter Modelica.Units.SI.Temperature T_start_in(start=Medium.T_default)= Medium.T_default "Initialization temperature at pipe inlet" annotation (Dialog(tab="Initialization")); - parameter Modelica.Units.SI.Temperature T_start_out(start=Medium.T_default) - = T_start_in "Initialization temperature at pipe outlet" + parameter Modelica.Units.SI.Temperature T_start_out(start=Medium.T_default)= + T_start_in "Initialization temperature at pipe outlet" annotation (Dialog(tab="Initialization")); parameter Boolean initDelay(start=false) = false "Initialize delay for a constant mass flow rate if true, otherwise start from 0" @@ -135,7 +135,6 @@ model PlugFlowPipeEmbedded final R=R, final fac=fac, final sum_zetas=sum_zetas, - nPorts=nPorts, final use_zeta=true) annotation (Placement(transformation(extent={{-10,-10},{10,10}}))); @@ -215,7 +214,7 @@ equation annotation (Line(points={{0,90.8},{0,104}}, color={191,0,0})); connect(port_a, plugFlowPipeZeta.port_a) annotation (Line(points={{-100,0},{-10,0}}, color={0,127,255})); - connect(plugFlowPipeZeta.ports_b, ports_b) annotation (Line(points={{10,0},{56, + connect(plugFlowPipeZeta.port_b, port_b) annotation (Line(points={{10,0},{56, 0},{56,0},{100,0}}, color={0,127,255})); annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={ Rectangle( diff --git a/AixLib/Fluid/DistrictHeatingCooling/Pipes/PlugFlowPipeZeta.mo b/AixLib/Fluid/DistrictHeatingCooling/Pipes/PlugFlowPipeZeta.mo index 534405568f..bf7da1e834 100644 --- a/AixLib/Fluid/DistrictHeatingCooling/Pipes/PlugFlowPipeZeta.mo +++ b/AixLib/Fluid/DistrictHeatingCooling/Pipes/PlugFlowPipeZeta.mo @@ -1,7 +1,7 @@ within AixLib.Fluid.DistrictHeatingCooling.Pipes; model PlugFlowPipeZeta "Pipe model using spatialDistribution for temperature delay and conditional HydraulicResistance" - extends AixLib.Fluid.Interfaces.PartialTwoPortVector(show_T=true); + extends AixLib.Fluid.Interfaces.PartialTwoPortInterface(show_T=true); parameter Boolean use_zeta=false "= true HydraulicResistance is implemented, zeta value has to be given next" @@ -56,11 +56,11 @@ model PlugFlowPipeZeta parameter Modelica.Units.SI.Length thickness=0.0035 "Pipe wall thickness" annotation (Dialog(group="Material")); - parameter Modelica.Units.SI.Temperature T_start_in(start=Medium.T_default) = + parameter Modelica.Units.SI.Temperature T_start_in(start=Medium.T_default)= Medium.T_default "Initialization temperature at pipe inlet" annotation (Dialog(tab="Initialization")); - parameter Modelica.Units.SI.Temperature T_start_out(start=Medium.T_default) - = T_start_in "Initialization temperature at pipe outlet" + parameter Modelica.Units.SI.Temperature T_start_out(start=Medium.T_default)= + T_start_in "Initialization temperature at pipe outlet" annotation (Dialog(tab="Initialization")); parameter Boolean initDelay(start=false) = false "Initialize delay for a constant mass flow rate if true, otherwise start from 0" @@ -95,12 +95,15 @@ model PlugFlowPipeZeta "Heat transfer to or from surroundings (heat loss from pipe results in a positive heat flow)" annotation (Placement(transformation(extent={{-10,90},{10,110}}))); - AixLib.Fluid.FixedResistances.BaseClasses.PlugFlowCore plugFlowCore( + FixedResistances.PlugFlowPipe plugFlowPipe( redeclare final package Medium = Medium, final dh=dh, final v_nominal=v_nominal, final length=length, - final C=C, + dIns=dIns, + kIns=kIns, + cPip=cPip, + rhoPip=rhoPip, final R=R, final m_flow_small=m_flow_small, final m_flow_nominal=m_flow_nominal, @@ -128,7 +131,7 @@ model PlugFlowPipeZeta redeclare final package Medium = Medium, final m_flow_nominal=m_flow_nominal, final V=if rho_default > 500 then VEqu else VEqu/1000, - final nPorts=nPorts + 1, + final nPorts=2, final T_start=T_start_out, final energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, final mSenFac = if rho_default > 500 then 1 else 10) @@ -178,25 +181,23 @@ equation //calculation of the flow velocity of medium in the pipes v_med = (4 * port_a.m_flow) / (Modelica.Constants.pi * rho_default * dh * dh); - for i in 1:nPorts loop - connect(vol.ports[i + 1], ports_b[i]) - annotation (Line(points={{70,20},{72,20},{72,6},{72,0},{100,0}}, + connect(vol.ports[2], port_b) + annotation (Line(points={{71,20},{72,20},{72,6},{72,0},{100,0}}, color={0,127,255})); - end for; - connect(plugFlowCore.heatPort, heatPort) + connect(plugFlowPipe.heatPort, heatPort) annotation (Line(points={{0,10},{0,10},{0,100}}, color={191,0,0})); - connect(plugFlowCore.port_b, vol.ports[1]) - annotation (Line(points={{10,0},{70,0},{70,20}}, color={0,127,255})); + connect(plugFlowPipe.port_b, vol.ports[1]) + annotation (Line(points={{10,0},{69,0},{69,20}}, color={0,127,255})); if use_zeta then - connect(hydraulicResistance.port_b, plugFlowCore.port_a) + connect(hydraulicResistance.port_b,plugFlowPipe. port_a) annotation (Line(points={{-40,20},{-20,20},{-20,0},{-10,0}}, color={0,127,255}, pattern=LinePattern.Dash)); connect(hydraulicResistance.port_a, port_a) annotation (Line(points={{-60,20},{-80,20},{-80,0},{-100,0}}, color={0,127,255}, pattern=LinePattern.Dash)); else - connect(port_a, plugFlowCore.port_a) + connect(port_a,plugFlowPipe. port_a) annotation (Line(points={{-100,0},{-80,0},{-80,-20},{-20,-20},{-20,0},{-10,0}}, color={0,127,255})); end if; diff --git a/AixLib/Fluid/DistrictHeatingCooling/Pipes/StaticPipe.mo b/AixLib/Fluid/DistrictHeatingCooling/Pipes/StaticPipe.mo index 09ae7f1ff5..5986218d4d 100644 --- a/AixLib/Fluid/DistrictHeatingCooling/Pipes/StaticPipe.mo +++ b/AixLib/Fluid/DistrictHeatingCooling/Pipes/StaticPipe.mo @@ -1,7 +1,7 @@ within AixLib.Fluid.DistrictHeatingCooling.Pipes; model StaticPipe "Static Pipe model using conditional HydraulicResistance" - extends AixLib.Fluid.Interfaces.PartialTwoPortVector(show_T=true); + extends AixLib.Fluid.Interfaces.PartialTwoPortInterface(show_T=true); parameter Boolean use_zeta=false "= true HydraulicResistance is implemented, zeta value has to be given next" @@ -56,11 +56,11 @@ model StaticPipe parameter Modelica.Units.SI.Length thickness=0.0035 "Pipe wall thickness" annotation (Dialog(group="Material")); - parameter Modelica.Units.SI.Temperature T_start_in(start=Medium.T_default) = + parameter Modelica.Units.SI.Temperature T_start_in(start=Medium.T_default)= Medium.T_default "Initialization temperature at pipe inlet" annotation (Dialog(tab="Initialization")); - parameter Modelica.Units.SI.Temperature T_start_out(start=Medium.T_default) - = T_start_in "Initialization temperature at pipe outlet" + parameter Modelica.Units.SI.Temperature T_start_out(start=Medium.T_default)= + T_start_in "Initialization temperature at pipe outlet" annotation (Dialog(tab="Initialization")); parameter Boolean initDelay(start=false) = false "Initialize delay for a constant mass flow rate if true, otherwise start from 0" @@ -129,7 +129,7 @@ model StaticPipe redeclare final package Medium = Medium, final m_flow_nominal=m_flow_nominal, final V=if rho_default > 500 then VEqu else VEqu/1000, - final nPorts=nPorts + 1, + final nPorts=2, final T_start=T_start_out, final energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, final mSenFac = if rho_default > 500 then 1 else 10) @@ -179,16 +179,14 @@ equation //calculation of the flow velocity of medium in the pipes v_med = (4 * port_a.m_flow) / (Modelica.Constants.pi * rho_default * dh * dh); - for i in 1:nPorts loop - connect(vol.ports[i + 1], ports_b[i]) - annotation (Line(points={{70,20},{72,20},{72,6},{72,0},{100,0}}, + connect(vol.ports[2], port_b) + annotation (Line(points={{71,20},{72,20},{72,6},{72,0},{100,0}}, color={0,127,255})); - end for; connect(staticCore.heatPort, heatPort) annotation (Line(points={{0,10},{0,10},{0,100}}, color={191,0,0})); connect(staticCore.port_b, vol.ports[1]) - annotation (Line(points={{10,0},{70,0},{70,20}}, color={0,127,255})); + annotation (Line(points={{10,0},{69,0},{69,20}}, color={0,127,255})); //Connect hydraulicResistance if use_zeta then connect(hydraulicResistance.port_b, staticCore.port_a) diff --git a/AixLib/Fluid/FixedResistances/BaseClasses/PlugFlowCore.mo b/AixLib/Fluid/FixedResistances/BaseClasses/PlugFlowCore.mo deleted file mode 100644 index 93efbe6a03..0000000000 --- a/AixLib/Fluid/FixedResistances/BaseClasses/PlugFlowCore.mo +++ /dev/null @@ -1,279 +0,0 @@ -within AixLib.Fluid.FixedResistances.BaseClasses; -model PlugFlowCore - "Pipe model using spatialDistribution for temperature delay with modified delay tracker" - extends AixLib.Fluid.Interfaces.PartialTwoPort; - - constant Boolean homotopyInitialization = true "= true, use homotopy method" - annotation(HideResult=true); - - parameter Modelica.Units.SI.Length dh - "Hydraulic diameter (assuming a round cross section area)"; - - parameter Modelica.Units.SI.Velocity v_nominal - "Velocity at m_flow_nominal (used to compute default value for hydraulic diameter dh)" - annotation(Dialog(group="Nominal condition")); - - parameter Modelica.Units.SI.Length length(min=0) "Pipe length"; - - parameter Modelica.Units.SI.MassFlowRate m_flow_nominal(min=0) - "Nominal mass flow rate" annotation (Dialog(group="Nominal condition")); - - parameter Modelica.Units.SI.MassFlowRate m_flow_small(min=0) = 1E-4*abs( - m_flow_nominal) "Small mass flow rate for regularization of zero flow" - annotation (Dialog(tab="Advanced")); - - parameter Modelica.Units.SI.Height roughness=2.5e-5 - "Average height of surface asperities (default: smooth steel pipe)" - annotation (Dialog(group="Geometry")); - - parameter Real R(unit="(m.K)/W") - "Thermal resistance per unit length from fluid to boundary temperature"; - - parameter Real C(unit="J/(K.m)") - "Thermal capacity per unit length of pipe"; - - parameter Real fac=1 - "Factor to take into account flow resistance of bends etc., fac=dp_nominal/dpStraightPipe_nominal"; - - - parameter Boolean from_dp=false - "= true, use m_flow = f(dp) else dp = f(m_flow)" - annotation (Evaluate=true, Dialog(tab="Advanced")); - parameter Modelica.Units.SI.Length thickness(min=0) "Pipe wall thickness"; - - parameter Modelica.Units.SI.Temperature T_start_in=Medium.T_default - "Initialization temperature at pipe inlet" - annotation (Dialog(tab="Initialization")); - parameter Modelica.Units.SI.Temperature T_start_out=Medium.T_default - "Initialization temperature at pipe outlet" - annotation (Dialog(tab="Initialization")); - parameter Boolean initDelay=false - "Initialize delay for a constant mass flow rate if true, otherwise start from 0" - annotation (Dialog(tab="Initialization")); - parameter Modelica.Units.SI.MassFlowRate m_flow_start=0 - annotation (Dialog(tab="Initialization", enable=initDelay)); - - parameter Real ReC=4000 - "Reynolds number where transition to turbulent starts"; - - parameter Boolean linearized = false - "= true, use linear relation between m_flow and dp for any flow rate" - annotation(Evaluate=true, Dialog(tab="Advanced")); - - AixLib.Fluid.FixedResistances.HydraulicDiameter res( - redeclare final package Medium = Medium, - final dh=dh, - final m_flow_nominal=m_flow_nominal, - final from_dp=from_dp, - final length=length, - final roughness=roughness, - final fac=fac, - final ReC=ReC, - final v_nominal=v_nominal, - final allowFlowReversal=allowFlowReversal, - final show_T=false, - final homotopyInitialization=homotopyInitialization, - final linearized=linearized, - dp(nominal=fac*200*length)) - "Pressure drop calculation for this pipe" - annotation (Placement(transformation(extent={{-20,-10},{0,10}}))); - - AixLib.Fluid.FixedResistances.BaseClasses.PlugFlow del( - redeclare final package Medium = Medium, - final m_flow_small=m_flow_small, - final dh=dh, - final length=length, - final allowFlowReversal=allowFlowReversal, - final T_start_in=T_start_in, - final T_start_out=T_start_out) - "Model for temperature wave propagation" - annotation (Placement(transformation(extent={{20,-10},{40,10}}))); - - AixLib.Fluid.FixedResistances.BaseClasses.PlugFlowHeatLoss heaLos_a( - redeclare final package Medium = Medium, - final C=C, - final R=R, - final m_flow_small=m_flow_small, - final T_start=T_start_in, - final m_flow_nominal=m_flow_nominal, - final m_flow_start=m_flow_start, - final show_T=false, - final show_V_flow=false) "Heat loss for flow from port_b to port_a" - annotation (Placement(transformation(extent={{-60,-10},{-80,10}}))); - - AixLib.Fluid.FixedResistances.BaseClasses.PlugFlowHeatLoss heaLos_b( - redeclare final package Medium = Medium, - final C=C, - final R=R, - final m_flow_small=m_flow_small, - final T_start=T_start_out, - final m_flow_nominal=m_flow_nominal, - final m_flow_start=m_flow_start, - final show_T=false, - final show_V_flow=false) "Heat loss for flow from port_a to port_b" - annotation (Placement(transformation(extent={{60,-10},{80,10}}))); - AixLib.Fluid.Sensors.MassFlowRate senMasFlo( - redeclare final package Medium = Medium) "Mass flow sensor" - annotation (Placement(transformation(extent={{-50,10},{-30,-10}}))); - AixLib.Fluid.FixedResistances.BaseClasses.PlugFlowTransportDelay timDel( - final length=length, - final dh=dh, - final rho=rho_default, - final initDelay=initDelay, - final m_flow_nominal=m_flow_nominal, - final m_flow_start=m_flow_start) "Time delay" - annotation (Placement(transformation(extent={{-10,-50},{10,-30}}))); - Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort - "Heat port to connect environment (positive heat flow for heat loss to surroundings)" - annotation (Placement(transformation(extent={{-10,90},{10,110}}))); - -protected - parameter Modelica.Units.SI.Density rho_default=Medium.density_pTX( - p=Medium.p_default, - T=Medium.T_default, - X=Medium.X_default) - "Default density (e.g., rho_liquidWater = 995, rho_air = 1.2)" - annotation (Dialog(group="Advanced")); - -initial equation - assert(homotopyInitialization, "In " + getInstanceName() + - ": The constant homotopyInitialization has been modified from its default value. This constant will be removed in future releases.", - level = AssertionLevel.warning); - -equation - connect(senMasFlo.m_flow, timDel.m_flow) annotation (Line( - points={{-40,-11},{-40,-40},{-12,-40}}, - color={0,0,127}, - smooth=Smooth.None)); - connect(heaLos_a.heatPort, heatPort) annotation (Line(points={{-70,10},{-70,40}, - {0,40},{0,100}}, color={191,0,0})); - connect(heaLos_b.heatPort, heatPort) annotation (Line(points={{70,10},{70,40}, - {0,40},{0,100}}, color={191,0,0})); - - connect(timDel.tauRev, heaLos_a.tau) annotation (Line(points={{11,-36},{50,-36}, - {50,28},{-64,28},{-64,10}}, color={0,0,127})); - connect(timDel.tau, heaLos_b.tau) annotation (Line(points={{11,-44},{54,-44}, - {54,28},{64,28},{64,10}}, color={0,0,127})); - - connect(port_a, heaLos_a.port_b) - annotation (Line(points={{-100,0},{-80,0}}, color={0,127,255})); - connect(heaLos_a.port_a, senMasFlo.port_a) - annotation (Line(points={{-60,0},{-50,0}}, color={0,127,255})); - connect(heaLos_b.port_b, port_b) - annotation (Line(points={{80,0},{100,0}}, color={0,127,255})); - connect(del.port_a, res.port_b) - annotation (Line(points={{20,0},{0,0}}, color={0,127,255})); - connect(senMasFlo.port_b, res.port_a) - annotation (Line(points={{-30,0},{-20,0}}, color={0,127,255})); - connect(heaLos_b.port_a, del.port_b) - annotation (Line(points={{60,0},{40,0}}, color={0,127,255})); - annotation ( - Line(points={{70,20},{72,20},{72,0},{100,0}}, color={0,127,255}), - Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100, - 100}})), - Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), - graphics={ - Rectangle( - extent={{-100,40},{100,-40}}, - lineColor={0,0,0}, - fillPattern=FillPattern.HorizontalCylinder, - fillColor={192,192,192}), - Rectangle( - extent={{-100,30},{100,-30}}, - lineColor={0,0,0}, - fillPattern=FillPattern.HorizontalCylinder, - fillColor={0,127,255}), - Rectangle( - extent={{-100,50},{100,40}}, - lineColor={175,175,175}, - fillColor={255,255,255}, - fillPattern=FillPattern.Backward), - Rectangle( - extent={{-100,-40},{100,-50}}, - lineColor={175,175,175}, - fillColor={255,255,255}, - fillPattern=FillPattern.Backward), - Polygon( - points={{0,100},{40,62},{20,62},{20,38},{-20,38},{-20,62},{-40,62},{0, - 100}}, - lineColor={0,0,0}, - fillColor={238,46,47}, - fillPattern=FillPattern.Solid), - Rectangle( - extent={{-30,30},{28,-30}}, - lineColor={0,0,0}, - fillPattern=FillPattern.HorizontalCylinder, - fillColor={215,202,187})}), - Documentation(revisions=" -",info=" -

- Pipe with heat loss using the time delay based heat losses and plug - flow for the transport delay of the fluid. -

-

- Implementation -

-

- The spatialDistribution operator is used for the - temperature wave propagation through the length of the pipe. This - operator is contained in BaseClasses.PlugFlow. -

-

- This model does not include thermal inertia of the pipe wall. The - wall inertia is implemented in PlugFlowPipe, - which uses this model.
- The removal of the thermal inertia with a mixing volume can be - desirable in the case where mixing volumes are added manually at the - pipe junctions. -

-

- The model - PlugFlowHeatLoss implements a heat loss in design direction, but - leaves the enthalpy unchanged in opposite flow direction. Therefore - it is used in front of and behind the time delay. -

-

- References -

-

- Full details on the model implementation and experimental validation - can be found in: -

-

- van der Heijde, B., Fuchs, M., Ribas Tugores, C., Schweiger, G., - Sartor, K., Basciotti, D., Müller, D., Nytsch-Geusen, C., Wetter, M. - and Helsen, L. (2017).
- Dynamic equation-based thermo-hydraulic pipe model for district - heating and cooling systems.
- Energy Conversion and Management, vol. 151, p. 158-169. - doi: - 10.1016/j.enconman.2017.08.072 . -

-")); -end PlugFlowCore; diff --git a/AixLib/Fluid/FixedResistances/BaseClasses/package.order b/AixLib/Fluid/FixedResistances/BaseClasses/package.order index 06493b07b5..3aabb3011a 100644 --- a/AixLib/Fluid/FixedResistances/BaseClasses/package.order +++ b/AixLib/Fluid/FixedResistances/BaseClasses/package.order @@ -2,4 +2,3 @@ PlugFlow PlugFlowHeatLoss PlugFlowPipe PlugFlowTransportDelay -PlugFlowCore