Skip to content

Commit

Permalink
Merged IBPSA, issue1580_OpenModelicaCI (#2878)
Browse files Browse the repository at this point in the history
This also merges the update to the calculation of sta_a and sta_b
  • Loading branch information
mwetter authored Feb 7, 2022
1 parent 595eb3c commit 6d06852
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 45 deletions.
1 change: 1 addition & 0 deletions Buildings/.copiedFiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2005,6 +2005,7 @@ Buildings/Resources/Scripts/Dymola/Utilities/Time/Validation/CalendarTimeMonthsM
Buildings/Resources/Scripts/Dymola/Utilities/Time/Validation/CalendarTimeMonthsPlus.mos
Buildings/Resources/Scripts/JModelica/buildingspy_to_csv.py
Buildings/Resources/Scripts/travis/dymola/dymola
Buildings/Resources/Scripts/travis/omc/omc
Buildings/Resources/bin/ConvertWeatherData.jar
Buildings/Resources/src/convertEPW/Makefile
Buildings/Resources/src/convertEPW/doc/ConvertWeatherData.html
Expand Down
117 changes: 87 additions & 30 deletions Buildings/Fluid/Interfaces/PartialEightPortInterface.mo
Original file line number Diff line number Diff line change
Expand Up @@ -32,63 +32,106 @@ partial model PartialEightPortInterface
HideResult=true);
Medium1.MassFlowRate m1_flow = port_a1.m_flow
"Mass flow rate from port_a1 to port_b1 (m1_flow > 0 is design flow direction)";
Modelica.Units.SI.Pressure dp1(displayUnit="Pa")
Modelica.Units.SI.Pressure dp1(displayUnit="Pa") = port_a1.p - port_b1.p
"Pressure difference between port_a1 and port_b1";
Medium2.MassFlowRate m2_flow = port_a2.m_flow
"Mass flow rate from port_a2 to port_b2 (m2_flow > 0 is design flow direction)";
Modelica.Units.SI.Pressure dp2(displayUnit="Pa")
Modelica.Units.SI.Pressure dp2(displayUnit="Pa") = port_a2.p - port_b2.p
"Pressure difference between port_a2 and port_b2";

Medium3.MassFlowRate m3_flow = port_a3.m_flow
"Mass flow rate from port_a3 to port_b3 (m3_flow > 0 is design flow direction)";
Modelica.Units.SI.Pressure dp3(displayUnit="Pa")
Modelica.Units.SI.Pressure dp3(displayUnit="Pa") = port_a3.p - port_b3.p
"Pressure difference between port_a3 and port_b3";
Medium4.MassFlowRate m4_flow = port_a4.m_flow
"Mass flow rate from port_a4 to port_b4 (m4_flow > 0 is design flow direction)";
Modelica.Units.SI.Pressure dp4(displayUnit="Pa")
Modelica.Units.SI.Pressure dp4(displayUnit="Pa") = port_a4.p - port_b4.p
"Pressure difference between port_a4 and port_b4";

Medium1.ThermodynamicState sta_a1=
if allowFlowReversal1 then
Medium1.setState_phX(port_a1.p,
noEvent(actualStream(port_a1.h_outflow)),
noEvent(actualStream(port_a1.Xi_outflow)))
noEvent(actualStream(port_a1.h_outflow)),
noEvent(actualStream(port_a1.Xi_outflow)))
else
Medium1.setState_phX(port_a1.p,
inStream(port_a1.h_outflow),
inStream(port_a1.Xi_outflow))
if show_T "Medium properties in port_a1";
Medium1.ThermodynamicState sta_b1=
if allowFlowReversal1 then
Medium1.setState_phX(port_b1.p,
noEvent(actualStream(port_b1.h_outflow)),
noEvent(actualStream(port_b1.Xi_outflow)))
else
Medium1.setState_phX(port_b1.p,
noEvent(actualStream(port_b1.h_outflow)),
noEvent(actualStream(port_b1.Xi_outflow)))
if show_T "Medium properties in port_b1";
port_b1.h_outflow,
port_b1.Xi_outflow)
if show_T "Medium properties in port_b1";

Medium2.ThermodynamicState sta_a2=
if allowFlowReversal2 then
Medium2.setState_phX(port_a2.p,
noEvent(actualStream(port_a2.h_outflow)),
noEvent(actualStream(port_a2.Xi_outflow)))
noEvent(actualStream(port_a2.h_outflow)),
noEvent(actualStream(port_a2.Xi_outflow)))
else
Medium2.setState_phX(port_a2.p,
inStream(port_a2.h_outflow),
inStream(port_a2.Xi_outflow))
if show_T "Medium properties in port_a2";
Medium2.ThermodynamicState sta_b2=
if allowFlowReversal2 then
Medium2.setState_phX(port_b2.p,
noEvent(actualStream(port_b2.h_outflow)),
noEvent(actualStream(port_b2.Xi_outflow)))
else
Medium2.setState_phX(port_b2.p,
noEvent(actualStream(port_b2.h_outflow)),
noEvent(actualStream(port_b2.Xi_outflow)))
if show_T "Medium properties in port_b2";
port_b2.h_outflow,
port_b2.Xi_outflow)
if show_T "Medium properties in port_b2";

Medium3.ThermodynamicState sta_a3=
Medium3.ThermodynamicState sta_a3=
if allowFlowReversal3 then
Medium3.setState_phX(port_a3.p,
noEvent(actualStream(port_a3.h_outflow)),
noEvent(actualStream(port_a3.Xi_outflow)))
noEvent(actualStream(port_a3.h_outflow)),
noEvent(actualStream(port_a3.Xi_outflow)))
else
Medium3.setState_phX(port_a3.p,
inStream(port_a3.h_outflow),
inStream(port_a3.Xi_outflow))
if show_T "Medium properties in port_a3";
Medium3.ThermodynamicState sta_b3=
if allowFlowReversal3 then
Medium3.setState_phX(port_b3.p,
noEvent(actualStream(port_b3.h_outflow)),
noEvent(actualStream(port_b3.Xi_outflow)))
else
Medium3.setState_phX(port_b3.p,
noEvent(actualStream(port_b3.h_outflow)),
noEvent(actualStream(port_b3.Xi_outflow)))
if show_T "Medium properties in port_b3";
port_b3.h_outflow,
port_b3.Xi_outflow)
if show_T "Medium properties in port_b3";

Medium4.ThermodynamicState sta_a4=
if allowFlowReversal4 then
Medium4.setState_phX(port_a4.p,
noEvent(actualStream(port_a4.h_outflow)),
noEvent(actualStream(port_a4.Xi_outflow)))
noEvent(actualStream(port_a4.h_outflow)),
noEvent(actualStream(port_a4.Xi_outflow)))
else
Medium4.setState_phX(port_a4.p,
inStream(port_a4.h_outflow),
inStream(port_a4.Xi_outflow))
if show_T "Medium properties in port_a4";
Medium4.ThermodynamicState sta_b4=
if allowFlowReversal4 then
Medium4.setState_phX(port_b4.p,
noEvent(actualStream(port_b4.h_outflow)),
noEvent(actualStream(port_b4.Xi_outflow)))
else
Medium4.setState_phX(port_b4.p,
noEvent(actualStream(port_b4.h_outflow)),
noEvent(actualStream(port_b4.Xi_outflow)))
if show_T "Medium properties in port_b4";
port_b4.h_outflow,
port_b4.Xi_outflow)
if show_T "Medium properties in port_b4";

protected
Medium1.ThermodynamicState state_a1_inflow=
Medium1.setState_phX(port_a1.p, inStream(port_a1.h_outflow), inStream(port_a1.Xi_outflow))
Expand All @@ -114,11 +157,8 @@ protected
Medium4.ThermodynamicState state_b4_inflow=
Medium4.setState_phX(port_b4.p, inStream(port_b4.h_outflow), inStream(port_b4.Xi_outflow))
"state for medium inflowing through port_b4";
equation
dp1 = port_a1.p - port_b1.p;
dp2 = port_a2.p - port_b2.p;
dp3 = port_a3.p - port_b3.p;
dp4 = port_a4.p - port_b4.p;


annotation (
preferredView="info",
Documentation(info="<html>
Expand All @@ -133,6 +173,23 @@ mass transfer and pressure drop equations.
</html>", revisions="<html>
<ul>
<li>
February 3, 2022, by Michael Wetter:<br/>
If <code>allowFlowReversal==false</code>, removed <code>noEvent()</code> declaration
for <code>sta_a</code> and for <code>sta_b</code> because the variable is either
already used with <code>inStream()</code> in the computation of <code>state_*_inflow</code>,
or the result of a variable of the model that already may generate an event.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1578\">IBPSA, #1578</a>.
</li>
<li>
February 2, 2022, by Hongxiang Fu:<br/>
If <code>allowFlowReversal==false</code>, replaced <code>actualStream()</code>
with <code>inStream()</code> for <code>sta_a</code> and
removed <code>actualStream()</code> for <code>sta_b</code>.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1578\">IBPSA, #1578</a>.
</li>
<li>
March 30, 2021, by Michael Wetter:<br/>
Added annotation <code>HideResult=true</code>.<br/>
This is for
Expand Down
67 changes: 53 additions & 14 deletions Buildings/Fluid/Interfaces/PartialFourPortInterface.mo
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,56 @@ partial model PartialFourPortInterface

Medium1.MassFlowRate m1_flow = port_a1.m_flow
"Mass flow rate from port_a1 to port_b1 (m1_flow > 0 is design flow direction)";
Modelica.Units.SI.PressureDifference dp1(displayUnit="Pa") = port_a1.p -
port_b1.p "Pressure difference between port_a1 and port_b1";
Modelica.Units.SI.PressureDifference dp1(displayUnit="Pa") = port_a1.p - port_b1.p
"Pressure difference between port_a1 and port_b1";

Medium2.MassFlowRate m2_flow = port_a2.m_flow
"Mass flow rate from port_a2 to port_b2 (m2_flow > 0 is design flow direction)";
Modelica.Units.SI.PressureDifference dp2(displayUnit="Pa") = port_a2.p -
port_b2.p "Pressure difference between port_a2 and port_b2";
Modelica.Units.SI.PressureDifference dp2(displayUnit="Pa") = port_a2.p - port_b2.p
"Pressure difference between port_a2 and port_b2";

Medium1.ThermodynamicState sta_a1=
if allowFlowReversal1 then
Medium1.setState_phX(port_a1.p,
noEvent(actualStream(port_a1.h_outflow)),
noEvent(actualStream(port_a1.Xi_outflow)))
noEvent(actualStream(port_a1.h_outflow)),
noEvent(actualStream(port_a1.Xi_outflow)))
else
Medium1.setState_phX(port_a1.p,
inStream(port_a1.h_outflow),
inStream(port_a1.Xi_outflow))
if show_T "Medium properties in port_a1";
Medium1.ThermodynamicState sta_b1=
if allowFlowReversal1 then
Medium1.setState_phX(port_b1.p,
noEvent(actualStream(port_b1.h_outflow)),
noEvent(actualStream(port_b1.Xi_outflow)))
else
Medium1.setState_phX(port_b1.p,
noEvent(actualStream(port_b1.h_outflow)),
noEvent(actualStream(port_b1.Xi_outflow)))
if show_T "Medium properties in port_b1";
port_b1.h_outflow,
port_b1.Xi_outflow)
if show_T "Medium properties in port_b1";

Medium2.ThermodynamicState sta_a2=
if allowFlowReversal2 then
Medium2.setState_phX(port_a2.p,
noEvent(actualStream(port_a2.h_outflow)),
noEvent(actualStream(port_a2.Xi_outflow)))
noEvent(actualStream(port_a2.h_outflow)),
noEvent(actualStream(port_a2.Xi_outflow)))
else
Medium2.setState_phX(port_a2.p,
inStream(port_a2.h_outflow),
inStream(port_a2.Xi_outflow))
if show_T "Medium properties in port_a2";
Medium2.ThermodynamicState sta_b2=
if allowFlowReversal2 then
Medium2.setState_phX(port_b2.p,
noEvent(actualStream(port_b2.h_outflow)),
noEvent(actualStream(port_b2.Xi_outflow)))
else
Medium2.setState_phX(port_b2.p,
noEvent(actualStream(port_b2.h_outflow)),
noEvent(actualStream(port_b2.Xi_outflow)))
if show_T "Medium properties in port_b2";
port_b2.h_outflow,
port_b2.Xi_outflow)
if show_T "Medium properties in port_b2";

protected
Medium1.ThermodynamicState state_a1_inflow=
Medium1.setState_phX(port_a1.p, inStream(port_a1.h_outflow), inStream(port_a1.Xi_outflow))
Expand Down Expand Up @@ -82,6 +104,23 @@ mass transfer and pressure drop equations.
</html>", revisions="<html>
<ul>
<li>
February 3, 2022, by Michael Wetter:<br/>
If <code>allowFlowReversal==false</code>, removed <code>noEvent()</code> declaration
for <code>sta_a</code> and for <code>sta_b</code> because the variable is either
already used with <code>inStream()</code> in the computation of <code>state_*_inflow</code>,
or the result of a variable of the model that already may generate an event.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1578\">IBPSA, #1578</a>.
</li>
<li>
February 2, 2022, by Hongxiang Fu:<br/>
If <code>allowFlowReversal==false</code>, replaced <code>actualStream()</code>
with <code>inStream()</code> for <code>sta_a</code> and
removed <code>actualStream()</code> for <code>sta_b</code>.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1578\">IBPSA, #1578</a>.
</li>
<li>
March 30, 2021, by Michael Wetter:<br/>
Added annotation <code>HideResult=true</code>.<br/>
This is for
Expand Down
18 changes: 18 additions & 0 deletions Buildings/Fluid/Interfaces/PartialTwoPortInterface.mo
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,25 @@ partial model PartialTwoPortInterface
"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
Expand Down Expand Up @@ -69,6 +79,14 @@ Buildings.Fluid.Interfaces.StaticTwoPortHeatMassExchanger</a>.
</html>", revisions="<html>
<ul>
<li>
February 2, 2022, by Hongxiang Fu:<br/>
If <code>allowFlowReversal==false</code>, replaced <code>actualStream()</code>
with <code>inStream()</code> for <code>sta_a</code> and
removed <code>actualStream()</code> for <code>sta_b</code>.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1578\">IBPSA, #1578</a>.
</li>
<li>
March 30, 2021, by Michael Wetter:<br/>
Added annotation <code>HideResult=true</code>.<br/>
This is for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def _simulate(spec):
# Set MODELICAPATH
#os.environ['MODELICAPATH'] = LIBPATH
# Set Model to simulate, the output dir and the package directory
s = Simulator(spec["model"], packagePath=os.path.join(wor_dir, "Buildings"))
s = Simulator(spec["model"], packagePath=os.path.join(wor_dir, library_name))
# Add all necessary parameters from Case Dict
s.addPreProcessingStatement("OutputCPUtime:= true;")
s.setSolver(spec["solver"])
Expand Down

0 comments on commit 6d06852

Please sign in to comment.