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

Revert most of the changes from #1782 #1795

Merged
merged 5 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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: 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
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"
mwetter marked this conversation as resolved.
Show resolved Hide resolved

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.StaticTwoPortHeatMassExchanger\">
IBPSA.Fluid.Interfaces.StaticTwoPortHeatMassExchanger</a>,
mwetter marked this conversation as resolved.
Show resolved Hide resolved
mwetter marked this conversation as resolved.
Show resolved Hide resolved
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