Skip to content

Commit

Permalink
Fix errors in OM by following the IBPSA changes and removing multipor…
Browse files Browse the repository at this point in the history
…t in DHC models. For #1352. [skip-ci]
  • Loading branch information
fabian.wuellhorst committed Oct 13, 2022
1 parent 6ddb4c9 commit 3e4e74b
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 388 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}},
Expand Down
84 changes: 32 additions & 52 deletions AixLib/Fluid/DistrictHeatingCooling/Pipes/DHCPipe.mo
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand All @@ -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));
Expand Down
18 changes: 5 additions & 13 deletions AixLib/Fluid/DistrictHeatingCooling/Pipes/Examples/DHCPipe.mo
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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])
Expand All @@ -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}));
Expand All @@ -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}));
Expand All @@ -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}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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}})));

Expand Down Expand Up @@ -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(
Expand Down
Loading

0 comments on commit 3e4e74b

Please sign in to comment.