Skip to content

Commit

Permalink
Merge pull request #1795 from ibpsa/issue1794_revertPortPlacement
Browse files Browse the repository at this point in the history
Revert most of the changes from #1782
  • Loading branch information
mwetter authored Sep 22, 2023
2 parents 386a90a + 78acfb2 commit 4f6e0df
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 99 deletions.
31 changes: 4 additions & 27 deletions IBPSA/Fluid/Interfaces/PartialFourPort.mo
Original file line number Diff line number Diff line change
Expand Up @@ -34,44 +34,26 @@ partial model PartialFourPort "Partial model with four ports"
m_flow(min=if allowFlowReversal1 then -Modelica.Constants.inf else 0),
h_outflow(start = Medium1.h_default, nominal = Medium1.h_default))
"Fluid connector a1 (positive design flow direction is from port_a1 to port_b1)"
annotation (Placement(transformation(extent={{port_a1_x-10,port_a1_y-10},{port_a1_x+10,port_a1_y+10}})));
annotation (Placement(transformation(extent={{-110,50},{-90,70}})));
Modelica.Fluid.Interfaces.FluidPort_b port_b1(
redeclare final package Medium = Medium1,
m_flow(max=if allowFlowReversal1 then +Modelica.Constants.inf else 0),
h_outflow(start = Medium1.h_default, nominal = Medium1.h_default))
"Fluid connector b1 (positive design flow direction is from port_a1 to port_b1)"
annotation (Placement(transformation(extent={{port_b1_x-10,port_b1_y-10},{port_b1_x+10,port_b1_y+10}})));
annotation (Placement(transformation(extent={{110,50},{90,70}})));

Modelica.Fluid.Interfaces.FluidPort_a port_a2(
redeclare final package Medium = Medium2,
m_flow(min=if allowFlowReversal2 then -Modelica.Constants.inf else 0),
h_outflow(start = Medium2.h_default, nominal = Medium2.h_default))
"Fluid connector a2 (positive design flow direction is from port_a2 to port_b2)"
annotation (Placement(transformation(extent={{port_a2_x-10,port_a2_y-10},{port_a2_x+10,port_a2_y+10}})));
annotation (Placement(transformation(extent={{90,-70},{110,-50}})));
Modelica.Fluid.Interfaces.FluidPort_b port_b2(
redeclare final package Medium = Medium2,
m_flow(max=if allowFlowReversal2 then +Modelica.Constants.inf else 0),
h_outflow(start = Medium2.h_default, nominal = Medium2.h_default))
"Fluid connector b2 (positive design flow direction is from port_a2 to port_b2)"
annotation (Placement(transformation(extent={{port_b2_x-10,port_b2_y-10},{port_b2_x+10,port_b2_y+10}})));

protected
constant Integer port_a1_x = -100
"x-coordinate of port_a1 center";
constant Integer port_a1_y = 60
"y-coordinate of port_a1 center";
constant Integer port_b1_x = 100
"x-coordinate of port_b1 center";
constant Integer port_b1_y = 60
"y-coordinate of port_b1 center";
constant Integer port_a2_x = 100
"x-coordinate of port_a2 center";
constant Integer port_a2_y = -60
"y-coordinate of port_a2 center";
constant Integer port_b2_x = -100
"x-coordinate of port_b2 center";
constant Integer port_b2_y = -60
"y-coordinate of port_b2 center";
annotation (Placement(transformation(extent={{-90,-70},{-110,-50}})));

annotation (
preferredView="info",
Expand Down Expand Up @@ -101,11 +83,6 @@ are not implemented.
</html>", revisions="<html>
<ul>
<li>
September 1, 2023, by Antoine Gautier:<br/>
Added constants for parameterization of port placement.
See <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1781\">#1781</a>.
</li>
<li>
April 6, 2020, by Filip Jorissen:<br/>
Added arrows to the icon indicating the intended flow direction
when <code>allowFlowReversal=false</code>.
Expand Down
19 changes: 2 additions & 17 deletions IBPSA/Fluid/Interfaces/PartialTwoPort.mo
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,13 @@ partial model PartialTwoPort "Partial component with two ports"
m_flow(min=if allowFlowReversal then -Modelica.Constants.inf else 0),
h_outflow(start = Medium.h_default, nominal = Medium.h_default))
"Fluid connector a (positive design flow direction is from port_a to port_b)"
annotation (Placement(transformation(extent={{port_a_x-10,port_a_y-10},{port_a_x+10,port_a_y+10}})));
annotation (Placement(transformation(extent={{-110,-10},{-90,10}})));
Modelica.Fluid.Interfaces.FluidPort_b port_b(
redeclare final package Medium = Medium,
m_flow(max=if allowFlowReversal then +Modelica.Constants.inf else 0),
h_outflow(start = Medium.h_default, nominal = Medium.h_default))
"Fluid connector b (positive design flow direction is from port_a to port_b)"
annotation (Placement(transformation(extent={{port_b_x-10,port_b_y-10},{port_b_x+10,port_b_y+10}})));

protected
constant Integer port_a_x = -100
"x-coordinate of port_a center";
constant Integer port_a_y = 0
"y-coordinate of port_a center";
constant Integer port_b_x = 100
"x-coordinate of port_b center";
constant Integer port_b_y = 0
"y-coordinate of port_b center";
annotation (Placement(transformation(extent={{110,-10},{90,10}})));

annotation (
Documentation(info="<html>
Expand All @@ -58,11 +48,6 @@ users have not used this global definition to assign parameters.
</html>", revisions="<html>
<ul>
<li>
September 1, 2023, by Antoine Gautier:<br/>
Added constants for parameterization of port placement.
See <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1781\">#1781</a>.
</li>
<li>
January 18, 2019, by Jianjun Hu:<br/>
Limited the media choice.
See <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1050\">#1050</a>.
Expand Down
21 changes: 2 additions & 19 deletions IBPSA/Fluid/Interfaces/PartialTwoPortVector.mo
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ partial model PartialTwoPortVector "Partial component with two ports, one of whi
property_T=293.15,
X_a=0.40)
"Propylene glycol water, 40% mass fraction")));

parameter Integer nPorts "Number of ports"
annotation(Evaluate=true, Dialog(connectorSizing=true, tab="General",group="Ports"));
parameter Boolean allowFlowReversal=true
Expand All @@ -23,14 +22,14 @@ partial model PartialTwoPortVector "Partial component with two ports, one of whi
m_flow(min=if allowFlowReversal then -Modelica.Constants.inf else 0),
h_outflow(start=Medium.h_default, nominal=Medium.h_default))
"Fluid connector a (positive design flow direction is from port_a to ports_b)"
annotation (Placement(transformation(extent={{port_a_x-10,port_a_y-10},{port_a_x+10,port_a_y+10}})));
annotation (Placement(transformation(extent={{-110,-10},{-90,10}})));

Modelica.Fluid.Interfaces.FluidPorts_b ports_b[nPorts](
redeclare each package Medium = Medium,
each m_flow(max=if allowFlowReversal then +Modelica.Constants.inf else 0),
each h_outflow(start=Medium.h_default, nominal=Medium.h_default))
"Fluid connectors b (positive design flow direction is from port_a to ports_b)"
annotation (Placement(transformation(extent={{port_b_x-10,port_b_y-40},{port_b_x+10,port_b_y+40}})));
annotation (Placement(transformation(extent={{90,-40},{110,40}})));

// Diagnostics
parameter Boolean show_T = false
Expand All @@ -50,17 +49,6 @@ partial model PartialTwoPortVector "Partial component with two ports, one of whi
noEvent(actualStream(ports_b.h_outflow)),
noEvent(actualStream(ports_b.Xi_outflow)))
if show_T "Medium properties in ports_b";

protected
constant Integer port_a_x = -100
"x-coordinate of port_a center";
constant Integer port_a_y = 0
"y-coordinate of port_a center";
constant Integer port_b_x = 100
"x-coordinate of port_b center";
constant Integer port_b_y = 0
"y-coordinate of port_b center";

annotation (
Documentation(info="<html>
<p>
Expand All @@ -85,11 +73,6 @@ users have not used this global definition to assign parameters.
</html>", revisions="<html>
<ul>
<li>
September 1, 2023, by Antoine Gautier:<br/>
Added constants for parameterization of port placement.
See <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1781\">#1781</a>.
</li>
<li>
March 30, 2021, by Michael Wetter:<br/>
Added annotation <code>HideResult=true</code>.<br/>
This is for
Expand Down
20 changes: 10 additions & 10 deletions IBPSA/Fluid/Storage/BaseClasses/IndirectTankHeatExchanger.mo
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ equation
color={191,0,0},
smooth=Smooth.None));
connect(vol[1].ports[1],senMasFlo.port_b) annotation (Line(
points={{-24,-40},{-24,-50},{-60,-50}},
points={{-23,-40},{-23,-50},{-60,-50}},
color={0,127,255},
smooth=Smooth.None));
connect(cap.port,HexToTan.solid) annotation (Line(
Expand All @@ -185,7 +185,7 @@ equation
color={191,0,0},
smooth=Smooth.None));
connect(temSenHex.T, hAPipIns.T) annotation (Line(
points={{-10,-70},{0,-70},{0,-76},{9,-76}},
points={{-9,-70},{0,-70},{0,-76},{9,-76}},
color={0,0,127},
smooth=Smooth.None));
connect(hAPipIns.hA, htfToHex.Gc) annotation (Line(
Expand All @@ -202,20 +202,20 @@ equation
smooth=Smooth.None));
connect(temSenSur.T, hANatCyl.TSur)
annotation (Line(
points={{20,52},{20,70},{-40,70},{-40,114},{-2,114}},
points={{20,53},{20,70},{-40,70},{-40,114},{-2,114}},
color={0,0,127},
smooth=Smooth.None));
connect(hANatCyl.TFlu, temSenWat.T)
annotation (Line(
points={{-2,106},{-36,106},{-36,76},{68,76},{68,50}},
points={{-2,106},{-36,106},{-36,76},{68,76},{68,51}},
color={0,0,127},
smooth=Smooth.None));
connect(port_a, senMasFlo.port_a) annotation (Line(
points={{-100,0},{-90,0},{-90,-50},{-80,-50}},
color={0,127,255},
smooth=Smooth.None));
connect(vol[nSeg].ports[2], res.port_a) annotation (Line(
points={{-20,-40},{-20,-50},{46,-50}},
points={{-21,-40},{-21,-50},{46,-50}},
color={0,127,255},
smooth=Smooth.None));
connect(res.port_b, port_b) annotation (Line(
Expand All @@ -238,7 +238,7 @@ equation
-150},{100,150}}), graphics), Icon(coordinateSystem(
preserveAspectRatio=false, extent={{-100,-150},{100,150}}), graphics={
Rectangle(
extent={{-66,64},{74,-96}},
extent={{-70,64},{70,-96}},
lineColor={0,0,255},
pattern=LinePattern.None,
fillColor={95,95,95},
Expand All @@ -250,25 +250,25 @@ equation
fillColor={0,0,255},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{-66,-12},{74,-18}},
extent={{-70,-12},{70,-18}},
lineColor={0,0,255},
pattern=LinePattern.None,
fillColor={0,0,0},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{-36,64},{-32,-96}},
extent={{-40,64},{-36,-96}},
lineColor={0,0,255},
pattern=LinePattern.None,
fillColor={0,0,0},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{2,64},{6,-96}},
extent={{-2,64},{2,-96}},
lineColor={0,0,255},
pattern=LinePattern.None,
fillColor={0,0,0},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{40,64},{44,-96}},
extent={{36,64},{40,-96}},
lineColor={0,0,255},
pattern=LinePattern.None,
fillColor={0,0,0},
Expand Down
10 changes: 7 additions & 3 deletions IBPSA/Fluid/Storage/BaseClasses/PartialStratified.mo
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
within IBPSA.Fluid.Storage.BaseClasses;
model PartialStratified
"Partial model of a stratified tank for thermal energy storage"
extends IBPSA.Fluid.Interfaces.PartialTwoPortInterface(
port_a_x=0, port_a_y=100, port_b_x=0, port_b_y=-100);
extends IBPSA.Fluid.Storage.BaseClasses.PartialTwoPortInterface;

import Modelica.Fluid.Types;
import Modelica.Fluid.Types.Dynamics;

parameter Modelica.Units.SI.Volume VTan "Tank volume";
parameter Modelica.Units.SI.Length hTan "Height of tank (without insulation)";
parameter Modelica.Units.SI.Length dIns "Thickness of insulation";
Expand Down Expand Up @@ -77,6 +77,7 @@ model PartialStratified
each final m_flow_small=m_flow_small,
each final allowFlowReversal=allowFlowReversal) "Tank segment"
annotation (Placement(transformation(extent={{6,-16},{26,4}})));

protected
parameter Medium.ThermodynamicState sta_default = Medium.setState_pTX(
T=Medium.T_default,
Expand Down Expand Up @@ -393,5 +394,8 @@ Icon(graphics={
Line(
points={{22,-74},{70,-74},{70,72}},
color={127,0,0},
pattern=LinePattern.Dot)}));
pattern=LinePattern.Dot), Text(
extent={{-100,100},{-8,70}},
textString="%name",
textColor={0,0,255})}));
end PartialStratified;
113 changes: 113 additions & 0 deletions IBPSA/Fluid/Storage/BaseClasses/PartialTwoPortInterface.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
within IBPSA.Fluid.Storage.BaseClasses;
partial model PartialTwoPortInterface
"Partial model transporting fluid between two ports without storing mass or energy"

replaceable package Medium =
Modelica.Media.Interfaces.PartialMedium "Medium in the component"
annotation (choices(
choice(redeclare package Medium = IBPSA.Media.Air "Moist air"),
choice(redeclare package Medium = IBPSA.Media.Water "Water"),
choice(redeclare package Medium =
IBPSA.Media.Antifreeze.PropyleneGlycolWater (
property_T=293.15,
X_a=0.40)
"Propylene glycol water, 40% mass fraction")));

parameter Boolean allowFlowReversal = true
"= false to simplify equations, assuming, but not enforcing, no flow reversal"
annotation(Dialog(tab="Assumptions"), Evaluate=true);

Modelica.Fluid.Interfaces.FluidPort_a port_a(
redeclare final package Medium = Medium,
m_flow(min=if allowFlowReversal then -Modelica.Constants.inf else 0),
p(start=Medium.p_default),
h_outflow(start = Medium.h_default, nominal = Medium.h_default))
"Fluid connector a (positive design flow direction is from port_a to port_b)"
annotation (Placement(transformation(extent={{-10,90},{10,110}})));
Modelica.Fluid.Interfaces.FluidPort_b port_b(
redeclare final package Medium = Medium,
m_flow(max=if allowFlowReversal then +Modelica.Constants.inf else 0),
p(start=Medium.p_default),
h_outflow(start = Medium.h_default, nominal = Medium.h_default))
"Fluid connector b (positive design flow direction is from port_a to port_b)"
annotation (Placement(transformation(extent={{10,-110},{-10,-90}})));

parameter Modelica.Units.SI.MassFlowRate m_flow_nominal
"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"));
// Diagnostics
parameter Boolean show_T = false
"= true, if actual temperature at port is computed"
annotation (
Dialog(tab="Advanced", group="Diagnostics"),
HideResult=true);

Modelica.Units.SI.MassFlowRate m_flow(start=_m_flow_start) = port_a.m_flow
"Mass flow rate from port_a to port_b (m_flow > 0 is design flow direction)";

Modelica.Units.SI.PressureDifference dp(
start=_dp_start,
displayUnit="Pa") = port_a.p - port_b.p
"Pressure difference between port_a and port_b";

Medium.ThermodynamicState sta_a=
if allowFlowReversal then
Medium.setState_phX(port_a.p,
noEvent(actualStream(port_a.h_outflow)),
noEvent(actualStream(port_a.Xi_outflow)))
else
Medium.setState_phX(port_a.p,
noEvent(inStream(port_a.h_outflow)),
noEvent(inStream(port_a.Xi_outflow)))
if show_T "Medium properties in port_a";

Medium.ThermodynamicState sta_b=
if allowFlowReversal then
Medium.setState_phX(port_b.p,
noEvent(actualStream(port_b.h_outflow)),
noEvent(actualStream(port_b.Xi_outflow)))
else
Medium.setState_phX(port_b.p,
noEvent(port_b.h_outflow),
noEvent(port_b.Xi_outflow))
if show_T "Medium properties in port_b";

protected
final parameter Modelica.Units.SI.MassFlowRate _m_flow_start=0
"Start value for m_flow, used to avoid a warning if not set in m_flow, and to avoid m_flow.start in parameter window";
final parameter Modelica.Units.SI.PressureDifference _dp_start(displayUnit=
"Pa") = 0
"Start value for dp, used to avoid a warning if not set in dp, and to avoid dp.start in parameter window";

annotation (
preferredView="info",
Documentation(info="<html>
<p>
This partial class implements the same functionality as
<a href=\"modelica://IBPSA.Fluid.Interfaces.PartialTwoPortInterface\">
IBPSA.Fluid.Interfaces.PartialTwoPortInterface</a>,
except that <code>port_a</code> and <code>port_b</code> are placed at the top and bottom
of the component.
</p>
<h4>Implementation</h4>
<p>
The implementation is done in this package as opposed to
<a href=\"modelica://IBPSA.Fluid.Interfaces\">
IBPSA.Fluid.Interfaces</a>
as it is only used by the storage model, and may be removed when the tool limitations
that are discussed in
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1794\">IBPSA, #1794</a>.
are removed.
</p>
</html>", revisions="<html>
<ul>
<li>
September 20, 2023, by Michael Wetter:<br/>
First implementation to address
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1794\">IBPSA, #1794</a>.
</li>
</ul>
</html>"));
end PartialTwoPortInterface;
1 change: 1 addition & 0 deletions IBPSA/Fluid/Storage/BaseClasses/package.order
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Buoyancy
IndirectTankHeatExchanger
PartialStratified
PartialTwoPortInterface
ThirdOrderStratifier
Examples
Loading

0 comments on commit 4f6e0df

Please sign in to comment.