Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue1781 port placement #1782

Merged
merged 6 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions IBPSA/Fluid/Interfaces/PartialFourPort.mo
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,44 @@ 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={{-110,50},{-90,70}})));
annotation (Placement(transformation(extent={{port_a1_x-10,port_a1_y-10},{port_a1_x+10,port_a1_y+10}})));
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={{110,50},{90,70}})));
annotation (Placement(transformation(extent={{port_b1_x-10,port_b1_y-10},{port_b1_x+10,port_b1_y+10}})));

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={{90,-70},{110,-50}})));
annotation (Placement(transformation(extent={{port_a2_x-10,port_a2_y-10},{port_a2_x+10,port_a2_y+10}})));
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={{-90,-70},{-110,-50}})));
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 (
preferredView="info",
Expand Down Expand Up @@ -83,6 +101,11 @@ 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: 17 additions & 2 deletions IBPSA/Fluid/Interfaces/PartialTwoPort.mo
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,23 @@ 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={{-110,-10},{-90,10}})));
annotation (Placement(transformation(extent={{port_a_x-10,port_a_y-10},{port_a_x+10,port_a_y+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={{110,-10},{90,10}})));
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 (
Documentation(info="<html>
Expand All @@ -48,6 +58,11 @@ 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: 19 additions & 2 deletions IBPSA/Fluid/Interfaces/PartialTwoPortVector.mo
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ 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 @@ -22,14 +23,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={{-110,-10},{-90,10}})));
annotation (Placement(transformation(extent={{port_a_x-10,port_a_y-10},{port_a_x+10,port_a_y+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={{90,-40},{110,40}})));
annotation (Placement(transformation(extent={{port_b_x-10,port_b_y-40},{port_b_x+10,port_b_y+40}})));

// Diagnostics
parameter Boolean show_T = false
Expand All @@ -49,6 +50,17 @@ 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 @@ -73,6 +85,11 @@ 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
51 changes: 8 additions & 43 deletions IBPSA/Fluid/Storage/BaseClasses/PartialStratified.mo
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
within IBPSA.Fluid.Storage.BaseClasses;
model PartialStratified
"Partial model of a stratified tank for thermal energy storage"
extends IBPSA.Fluid.Interfaces.PartialTwoPortInterface;
extends IBPSA.Fluid.Interfaces.PartialTwoPortInterface(
port_a_x=0, port_a_y=100, port_b_x=0, port_b_y=-100);

import Modelica.Fluid.Types;
import Modelica.Fluid.Types.Dynamics;
Expand Down Expand Up @@ -165,11 +166,11 @@ equation
{52,74},{20,74}}, color={191,0,0}));
connect(heaFloBot.port_b, heaPorBot) annotation (Line(points={{42,20},{44,20},
{44,-74},{20,-74}}, color={191,0,0}));
connect(heaFloTop.Q_flow, mul.u1[1]) annotation (Line(points={{36,54},{50,54},
connect(heaFloTop.Q_flow, mul.u1[1]) annotation (Line(points={{36,53.4},{50,53.4},
{50,52.5},{61.2,52.5}}, color={0,0,127}));
connect(heaFloSid.Q_flow, mul.u2) annotation (Line(points={{36,34},{50,34},{
50,49},{61.2,49}}, color={0,0,127}));
connect(heaFloBot.Q_flow, mul.u3[1]) annotation (Line(points={{36,14},{36,10},
connect(heaFloSid.Q_flow, mul.u2) annotation (Line(points={{36,33.4},{50,33.4},
{50,49},{61.2,49}},color={0,0,127}));
connect(heaFloBot.Q_flow, mul.u3[1]) annotation (Line(points={{36,13.4},{36,10},
{58,10},{58,45.5},{61.2,45.5}}, color={0,0,127}));
connect(mul.y, sum1.u) annotation (Line(points={{70.4,49},{76.8,49}}, color={
0,0,127}));
Expand Down Expand Up @@ -331,49 +332,13 @@ Icon(graphics={
fillColor={0,0,127},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{-76,2},{-90,-2}},
extent={{2,100},{-2,60}},
lineColor={0,0,255},
pattern=LinePattern.None,
fillColor={0,0,127},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{0,84},{-80,80}},
lineColor={0,0,255},
pattern=LinePattern.None,
fillColor={0,0,127},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{-76,84},{-80,-2}},
lineColor={0,0,255},
pattern=LinePattern.None,
fillColor={0,0,127},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{82,0},{78,-86}},
lineColor={0,0,255},
pattern=LinePattern.None,
fillColor={0,0,127},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{0,84},{-4,60}},
lineColor={0,0,255},
pattern=LinePattern.None,
fillColor={0,0,127},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{82,-84},{2,-88}},
lineColor={0,0,255},
pattern=LinePattern.None,
fillColor={0,0,127},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{6,-60},{2,-84}},
lineColor={0,0,255},
pattern=LinePattern.None,
fillColor={0,0,127},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{92,2},{78,-2}},
extent={{2,-60},{-2,-100}},
lineColor={0,0,255},
pattern=LinePattern.None,
fillColor={0,0,127},
Expand Down
48 changes: 23 additions & 25 deletions IBPSA/Fluid/Storage/Examples/Stratified.mo
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,36 @@ model Stratified "Test model for stratified tank"
T=273.15 + 20,
use_p_in=true,
p=300000,
nPorts=2) annotation (Placement(transformation(extent={{90,-2},
{70,18}})));
nPorts=2) annotation (Placement(transformation(extent={{90,-18},
{70,2}})));
IBPSA.Fluid.FixedResistances.PressureDrop res_1(
from_dp=true,
redeclare package Medium = Medium,
dp_nominal=5000,
m_flow_nominal=0.1)
annotation (Placement(transformation(extent={{36,0},{56,20}})));
annotation (Placement(transformation(extent={{34,-18},{54,2}})));
IBPSA.Fluid.Storage.StratifiedEnhanced tanEnh(
redeclare package Medium = Medium,
hTan=3,
dIns=0.3,
nSeg=10,
m_flow_nominal=0.1,
VTan=3) "Tank"
annotation (Placement(transformation(extent={{-18,-38},{2,-18}})));
annotation (Placement(transformation(extent={{-18,-70},{2,-50}})));
IBPSA.Fluid.FixedResistances.PressureDrop res_2(
from_dp=true,
redeclare package Medium = Medium,
dp_nominal=5000,
m_flow_nominal=0.1)
annotation (Placement(transformation(extent={{38,-38},{58,-18}})));
annotation (Placement(transformation(extent={{40,-90},{60,-70}})));
IBPSA.Fluid.Sensors.EnthalpyFlowRate HOut_flow(redeclare package Medium =
Medium, m_flow_nominal=0.1) "Enthalpy flow rate"
annotation (Placement(transformation(
extent={{6,2},{22,18}})));
extent={{4,-16},{20,0}})));
IBPSA.Fluid.Sensors.EnthalpyFlowRate HOut_flow1(redeclare package Medium =
Medium, m_flow_nominal=0.1) "Enthalpy flow rate"
annotation (Placement(transformation(
extent={{18,-36},{34,-20}})));
extent={{20,-88},{36,-72}})));
Modelica.Blocks.Continuous.Integrator dH
"Differenz in enthalpy (should be zero at steady-state)"
annotation (Placement(transformation(extent={{68,30},{88,50}})));
Expand Down Expand Up @@ -87,25 +87,23 @@ equation
connect(TWat.y, sou_1.T_in) annotation (Line(
points={{-79,12},{-62,12}},
color={0,0,127}));
connect(tanSim.port_b, HOut_flow.port_a) annotation (Line(points={{
5.55112e-16,10},{5.55112e-16,10},{6,10}},
color={0,127,255}));
connect(tanSim.port_b, HOut_flow.port_a) annotation (Line(points={{-10,0},{
-10,-8},{4,-8}}, color={0,127,255}));
connect(HOut_flow.port_b, res_1.port_a)
annotation (Line(points={{22,10},{30,10},{36,10}},
color={0,127,255}));
annotation (Line(points={{20,-8},{34,-8}}, color={0,127,255}));
connect(tanEnh.port_b, HOut_flow1.port_a)
annotation (Line(points={{2,-28},{2,-28},{18,-28}},
annotation (Line(points={{-8,-70},{-8,-80},{20,-80}},
color={0,127,255}));
connect(HOut_flow1.port_b, res_2.port_a) annotation (Line(points={{34,-28},{
38,-28}}, color={0,127,255}));
connect(HOut_flow1.port_b, res_2.port_a) annotation (Line(points={{36,-80},{
40,-80}}, color={0,127,255}));
connect(add.y, dH.u)
annotation (Line(points={{53,40},{66,40}}, color={0,0,127}));
connect(HOut_flow.H_flow, add.u1) annotation (Line(points={{14,18.8},{14,46},
{30,46}}, color={0,0,127}));
connect(HOut_flow1.H_flow, add.u2) annotation (Line(points={{26,-19.2},{26,34},
connect(HOut_flow.H_flow, add.u1) annotation (Line(points={{12,0.8},{12,46},{
30,46}}, color={0,0,127}));
connect(HOut_flow1.H_flow, add.u2) annotation (Line(points={{28,-71.2},{28,34},
{30,34}}, color={0,0,127}));
connect(P.y, sin_1.p_in) annotation (Line(
points={{41,70},{100,70},{100,16},{92,16}},
points={{41,70},{100,70},{100,0},{92,0}},
color={0,0,127}));
connect(sine.y, TBCSid1.T) annotation (Line(points={{-69,72},{-55.5,72},{
-55.5,90},{-41.2,90}}, color={0,0,127}));
Expand All @@ -116,23 +114,23 @@ equation
connect(sine.y, TBCTop2.T) annotation (Line(points={{-69,72},{-56,72},{-56,38},
{-41.2,38}}, color={0,0,127}));
connect(TBCSid2.port, tanEnh.heaPorSid) annotation (Line(points={{-28,56},{
-24,56},{-24,-12},{-2,-12},{-2,-28},{-2.4,-28}}, color={191,0,0}));
-24,56},{-24,-12},{-2,-12},{-2,-60},{-2.4,-60}}, color={191,0,0}));
connect(TBCTop2.port, tanEnh.heaPorTop) annotation (Line(points={{-28,38},{
-26,38},{-26,-14},{-6,-14},{-6,-20.6}}, color={191,0,0}));
-26,38},{-26,-14},{-6,-14},{-6,-52.6}}, color={191,0,0}));
connect(sin_1.ports[1], res_1.port_b) annotation (Line(
points={{70,10},{56,10}},
points={{70,-9},{64,-9},{64,-8},{54,-8}},
color={0,127,255},
smooth=Smooth.None));
connect(sin_1.ports[2], res_2.port_b) annotation (Line(
points={{70,6},{64,6},{64,-28},{58,-28}},
points={{70,-7},{64,-7},{64,-80},{60,-80}},
color={0,127,255},
smooth=Smooth.None));
connect(sou_1.ports[1], tanSim.port_a) annotation (Line(
points={{-40,10},{-20,10}},
points={{-40,7},{-30,7},{-30,20},{-10,20}},
color={0,127,255},
smooth=Smooth.None));
connect(sou_1.ports[2], tanEnh.port_a) annotation (Line(
points={{-40,6},{-30,6},{-30,-28},{-18,-28}},
points={{-40,9},{-30,9},{-30,-40},{-8,-40},{-8,-50}},
color={0,127,255},
smooth=Smooth.None));
connect(TBCSid1.port, tanSim.heaPorSid) annotation (Line(
Expand Down
Loading