Skip to content

Commit

Permalink
Merge pull request #1156 from open-ideas/issue1029_portVector2
Browse files Browse the repository at this point in the history
implementation for #1029
  • Loading branch information
Damien Picard committed Jul 22, 2020
2 parents ee3701e + 6c43190 commit 3153b6f
Show file tree
Hide file tree
Showing 17 changed files with 241 additions and 124 deletions.
17 changes: 8 additions & 9 deletions IDEAS/Buildings/Components/Examples/ZoneStatic.mo
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@ model ZoneStatic "Zone with constant boundary conditions"
A=10, T=Medium.T_default,
inc(k=IDEAS.Types.Tilt.Ceiling))
annotation (Placement(transformation(extent={{-40,20},{-20,40}})));

IDEAS.Fluid.Sources.MassFlowSource_T sou(
redeclare package Medium = Medium,
nPorts=1,
m_flow=0.1) "Mass flow source" annotation (Placement(transformation(
m_flow=0.1,
nPorts=2) "Mass flow source" annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={30,70})));
Fluid.Sources.Boundary_pT sin(nPorts=1, redeclare package Medium = Medium)
Fluid.Sources.Boundary_pT sin( redeclare package Medium = Medium,
nPorts=2)
"Mass flow sink"
annotation (Placement(transformation(extent={{0,40},{20,60}})));

equation
connect(zone.propsBus[1], dummyConnection.zoneBus) annotation (Line(
points={{20,15},{12,15},{-20,15},{-20,-10.2}},
Expand All @@ -40,10 +39,10 @@ equation
points={{-20,29.8},{-20,13},{20,13}},
color={255,204,51},
thickness=0.5));
connect(sou.ports[1], zone.port_a)
annotation (Line(points={{30,60},{32,60},{32,20}}, color={0,127,255}));
connect(sin.ports[1], zone.port_b)
annotation (Line(points={{20,50},{28,50},{28,20}}, color={0,127,255}));
connect(zone.ports[1], sin.ports[1]) annotation (Line(points={{30,20},{30,46},
{20,46},{20,52}},color={0,127,255}));
connect(zone.ports[2], sou.ports[1])
annotation (Line(points={{30,20},{32,20},{32,60}}, color={0,127,255}));
annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
coordinateSystem(preserveAspectRatio=false)),
experiment(
Expand Down
18 changes: 14 additions & 4 deletions IDEAS/Buildings/Components/Interfaces/PartialZone.mo
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ model PartialZone "Building zone model"
constrainedby
IDEAS.Buildings.Components.InterzonalAirFlow.BaseClasses.PartialInterzonalAirFlow(
redeclare package Medium = Medium,
final nPortsExt=nPorts,
V=V,
n50=n50,
n50toAch=n50toAch,
Expand Down Expand Up @@ -227,6 +228,8 @@ equation
through the zone to/from the surroundings, at ambient temperature.
This may be unintended.", AssertionLevel.warning);
end if;


for i in 1:nSurf loop
connect(dummy1, propsBusInt[i].Qgai);
connect(dummy2, propsBusInt[i].E);
Expand Down Expand Up @@ -382,10 +385,10 @@ end for;
annotation (Line(points={{-24,40},{-24,60}}, color={0,127,255}));
connect(interzonalAirFlow.ports, airModel.ports) annotation (Line(points={{
-29.8,60},{-30,60},{-30,40}}, color={0,127,255}));
connect(interzonalAirFlow.port_b_exterior, port_b) annotation (Line(points={{
-32,80},{-32,92},{-20,92},{-20,100}}, color={0,127,255}));
connect(interzonalAirFlow.port_a_exterior, port_a) annotation (Line(points={{
-28,80},{-28,84},{20,84},{20,100}}, color={0,127,255}));
connect(interzonalAirFlow.port_b_exterior, port_b) annotation (Line(points={{-36,80},
{-36,92},{-60,92},{-60,100}}, color={0,127,255}));
connect(interzonalAirFlow.port_a_exterior, port_a) annotation (Line(points={{-24,80},
{-24,84},{60,84},{60,100}}, color={0,127,255}));
connect(ppm, airModel.ppm) annotation (Line(points={{110,0},{52,0},{52,16},{-8,
16},{-8,28},{-19,28}}, color={0,0,127}));
connect(intGaiLig.portRad, gainRad) annotation (Line(points={{20,60},{4,60},{4,
Expand All @@ -394,6 +397,8 @@ end for;
-30},{100,-30}}, color={191,0,0}));
connect(ligCtr.ctrl, intGaiLig.ctrl)
annotation (Line(points={{58,62},{41,62}}, color={0,0,127}));
connect(interzonalAirFlow.portsExt, ports) annotation (Line(points={{-30,80},{
-30,90},{0,90},{0,100}}, color={0,127,255}));
annotation (Placement(transformation(extent={{
140,48},{100,88}})),
Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}),
Expand All @@ -403,7 +408,12 @@ end for;
</html>", revisions="<html>
<ul>
<li>
March 17, 2020, Filip Jorissen:<br/>
Added support for vector fluidport.
See <a href=\"https://github.com/open-ideas/IDEAS/issues/1029\">#1029</a>.
April 26, 2020, by Filip Jorissen:<br/>
</li>
<li>
Refactored <code>SolBus</code> to avoid many instances in <code>PropsBus</code>.
See <a href=\"https://github.com/open-ideas/IDEAS/issues/1131\">
#1131</a>
Expand Down
38 changes: 32 additions & 6 deletions IDEAS/Buildings/Components/Interfaces/ZoneInterface.mo
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ partial model ZoneInterface "Partial model for thermal building zones"
annotation (Placement(transformation(extent={{-100,80},{-80,100}})));

parameter Integer nSurf(min=2)
"Number of surfaces adjacent to and heat exchangeing with the zone";
"Number of surfaces adjacent to and heat exchanging with the zone";
parameter Integer nPorts(min=0)=2
"Number of ports for ventilation connections";
parameter Modelica.SIunits.Volume V "Total zone air volume"
annotation(Dialog(group="Building physics"));
parameter Modelica.SIunits.Length hZone = 2.8
Expand All @@ -35,18 +37,20 @@ partial model ZoneInterface "Partial model for thermal building zones"
annotation (Placement(transformation(extent={{90,-40},{110,-20}})));
Modelica.Blocks.Interfaces.RealOutput TSensor(unit="K", displayUnit="degC")
"Sensor temperature of the zone, i.e. operative temeprature" annotation (
Placement(transformation(extent={{90,20},{110,40}}), iconTransformation(
extent={{90,20},{110,40}})));
Placement(transformation(extent={{100,10},{120,30}}), iconTransformation(
extent={{100,10},{120,30}})));

// icons removed to discourage the use of these ports
Modelica.Fluid.Interfaces.FluidPort_b port_b(
redeclare package Medium = Medium,
m_flow(nominal=m_flow_nominal),
h_outflow(nominal=Medium.h_default))
annotation (Placement(transformation(extent={{-30,90},{-10,110}})));
"Port for ventilation connections, deprecated, use 'ports' instead";
Modelica.Fluid.Interfaces.FluidPort_a port_a(
redeclare package Medium = Medium,
m_flow(nominal=m_flow_nominal),
h_outflow(nominal=Medium.h_default))
annotation (Placement(transformation(extent={{10,90},{30,110}})));
"Port for ventilation connections, deprecated, use 'ports' instead";
Modelica.Blocks.Interfaces.RealInput yOcc if useOccNumInput
"Control input for number of occupants, used by Occupants.Input and Occupants.AreaWeightedInput"
annotation (Placement(transformation(extent={{140,20},{100,60}})));
Expand All @@ -57,6 +61,12 @@ partial model ZoneInterface "Partial model for thermal building zones"
Modelica.Blocks.Interfaces.RealOutput ppm(unit="1")
"CO2 concentration in the zone" annotation (Placement(transformation(extent={{100,-10},
{120,10}}), iconTransformation(extent={{100,-10},{120,10}})));
Modelica.Fluid.Interfaces.FluidPorts_a ports[nPorts](redeclare package Medium =
Medium) "Ports for ventilation connetions" annotation (Placement(
transformation(
extent={{-10,-40},{10,40}},
rotation=90,
origin={0,100})));
protected
Modelica.Blocks.Sources.RealExpression Eexpr "Internal energy model";
BaseClasses.ConservationOfEnergy.PrescribedEnergy prescribedHeatFlowE
Expand All @@ -74,7 +84,18 @@ protected
initial equation
assert(nSurf>1, "In " + getInstanceName() +
": A minimum of 2 surfaces must be connected to the zone.");

assert(cardinality(port_a)+cardinality(port_b)==2, "In " + getInstanceName() +
": You have made connections to port_a or port_b. These connectors will be
removed in a future release of IDEAS. Use the connector `ports' instead.",
AssertionLevel.warning);
for i in 1:nPorts loop
assert(cardinality(ports[i])<=2,
"Each element of ports should have zero or one external connections but " +
getInstanceName() +".ports[" + String(i) + "] has " + String(cardinality(ports[i]) - 1) + "." +
" This can cause air to mix at the fluid port, without entering the zone, which is usually unintended.
Instead, increase nPorts and create a separate connection.",
level=AssertionLevel.warning);
end for;
equation
connect(sim.Qgai, dummy1);
connect(sim.E, dummy2);
Expand Down Expand Up @@ -134,7 +155,12 @@ equation
Documentation(revisions="<html>
<ul>
<li>
March 17, 2020, Filip Jorissen:<br/>
Added support for vector fluidport.
See <a href=\"https://github.com/open-ideas/IDEAS/issues/1029\">#1029</a>.
March 21, 2019 by Filip Jorissen:<br/>
</li>
<li>
Revised implementation of icon for
<a href=\"https://github.com/open-ideas/IDEAS/issues/996\">#996</a>
and for <a href=\"https://github.com/open-ideas/IDEAS/pull/976\">#976</a>.
Expand Down
11 changes: 8 additions & 3 deletions IDEAS/Buildings/Components/InterzonalAirFlow/AirTight.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@ within IDEAS.Buildings.Components.InterzonalAirFlow;
model AirTight
"Airtight: Air tight zone without air infiltration"
extends IDEAS.Buildings.Components.InterzonalAirFlow.BaseClasses.PartialInterzonalAirFlow(
nPorts=0,
nPorts=nPortsExt,
prescribesPressure=false);
equation
connect(port_a_interior, port_b_exterior) annotation (Line(points={{-60,-100},
{-60,0},{-20,0},{-20,100}}, color={0,127,255}));
connect(port_a_exterior, port_b_interior) annotation (Line(points={{20,100},{20,
{-60,0},{-60,0},{-60,100}}, color={0,127,255}));
connect(port_a_exterior, port_b_interior) annotation (Line(points={{60,100},{60,
0},{60,0},{60,-100}}, color={0,127,255}));
annotation (Documentation(revisions="<html>
<ul>
<li>
March 17, 2020, Filip Jorissen:<br/>
Added support for vector fluidport.
See <a href=\"https://github.com/open-ideas/IDEAS/issues/1029\">#1029</a>.
</li>
<li>
January 25, 2019, Filip Jorissen:<br/>
Added constant <code>prescribesPressure</code> that indicates
whether this model prescribes the zone air pressure or not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ within IDEAS.Buildings.Components.InterzonalAirFlow.BaseClasses;
partial model PartialInterzonalAirFlow "Partial for interzonal air flow"
replaceable package Medium = IDEAS.Media.Air "Air medium";
parameter Integer nPorts "Number of ports for connection to zone air volume";
parameter Integer nPortsExt "Number of ports for connection to zone air volume";
parameter Modelica.SIunits.Volume V "Zone air volume for n50 computation";
parameter Real n50 "n50 value";
parameter Real n50toAch = 20
Expand Down Expand Up @@ -33,13 +34,13 @@ partial model PartialInterzonalAirFlow "Partial for interzonal air flow"
m_flow(nominal=m_flow_nominal_vent),
h_outflow(nominal=Medium.h_default))
"Port a connection to model exterior ports"
annotation (Placement(transformation(extent={{10,90},{30,110}})));
annotation (Placement(transformation(extent={{50,90},{70,110}})));
Modelica.Fluid.Interfaces.FluidPort_b port_b_exterior(
redeclare package Medium = Medium,
m_flow(nominal=m_flow_nominal_vent),
h_outflow(nominal=Medium.h_default))
"Port b connection to model exterior ports"
annotation (Placement(transformation(extent={{-30,90},{-10,110}})));
annotation (Placement(transformation(extent={{-70,90},{-50,110}})));
Modelica.Fluid.Interfaces.FluidPorts_a[nPorts] ports(
redeclare each package Medium = Medium,
each m_flow(nominal=m_flow_nominal_vent),
Expand All @@ -49,6 +50,20 @@ partial model PartialInterzonalAirFlow "Partial for interzonal air flow"
extent={{-10,40},{10,-40}},
rotation=90,
origin={2,-100})));
Modelica.Fluid.Interfaces.FluidPorts_b[nPortsExt] portsExt(
redeclare each package Medium = Medium,
each m_flow(nominal=m_flow_nominal_vent),
each h_outflow(nominal=Medium.h_default))
"Ports connector for multiple ports" annotation (Placement(
transformation(
extent={{-10,40},{10,-40}},
rotation=90,
origin={0,100})));

equation
connect(ports[1+nPorts-nPortsExt:nPorts], portsExt[1:nPortsExt]) annotation (Line(points={{2,-100},{0,-100},{0,100},{0,
100}}, color={0,127,255}));

annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={
Rectangle(
extent={{-15,80},{15,-80}},
Expand Down Expand Up @@ -104,6 +119,11 @@ partial model PartialInterzonalAirFlow "Partial for interzonal air flow"
Documentation(revisions="<html>
<ul>
<li>
March 17, 2020, Filip Jorissen:<br/>
Added support for vector fluidport.
See <a href=\"https://github.com/open-ideas/IDEAS/issues/1029\">#1029</a>.
</li>
<li>
January 25, 2019, Filip Jorissen:<br/>
Added constant <code>prescribesPressure</code> that indicates
whether this model prescribes the zone air pressure or not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ protected
equation
connect( sim.weaBus,weaBus);
connect(port_a_interior, port_b_exterior) annotation (Line(points={{-60,-100},
{-60,0},{-20,0},{-20,100}}, color={0,127,255}));
connect(port_a_exterior, port_b_interior) annotation (Line(points={{20,100},{20,
0},{60,0},{60,-100}}, color={0,127,255}));
{-60,0},{-60,0},{-60,100}}, color={0,127,255}));
connect(port_a_exterior, port_b_interior) annotation (Line(points={{60,100},{
60,0},{60,0},{60,-100}},
color={0,127,255}));
connect(preHeaFlo.port, sim.Qgai)
annotation (Line(points={{-90,76},{-90,80}}, color={191,0,0}));
connect(QGai.y, preHeaFlo.Q_flow)
Expand All @@ -50,6 +51,11 @@ equation
annotation (Documentation(revisions="<html>
<ul>
<li>
March 17, 2020, Filip Jorissen:<br/>
Added support for vector fluidport.
See <a href=\"https://github.com/open-ideas/IDEAS/issues/1029\">#1029</a>.
</li>
<li>
September 21, 2019 by Filip Jorissen:<br/>
Using OutsideAir.
See <a href=\"https://github.com/open-ideas/IDEAS/issues/1052\">#1052</a>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ partial model PartialInterzonalAirFlown50
"Model representing idealised n50 air leakage"
extends
IDEAS.Buildings.Components.InterzonalAirFlow.BaseClasses.PartialInterzonalAirFlowBoundary(
nPorts=2, bou(nPorts=2));
nPorts=2+nPortsExt, bou(nPorts=2));

parameter Modelica.SIunits.MassFlowRate m_flow_nominal_airLea=
V*rho_default/3600*n50/n50toAch
Expand Down Expand Up @@ -33,13 +33,18 @@ equation
connect(reaExpMflo.y, airInfiltration.m_flow_in) annotation (Line(points={{-28.9,
-44},{-18,-44}}, color={0,0,127}));
connect(airInfiltration.port_a, bou.ports[1]) annotation (Line(points={{-10,-40},
{-10,0},{-2,0}}, color={0,127,
{-10,0},{-1.77636e-15,0}}, color={0,127,
255}));
connect(airInfiltration.port_b, ports[1]) annotation (Line(points={{-10,-60},{
-10,-100},{-18,-100}}, color={0,127,255}));
connect(airInfiltration.port_b, ports[1]) annotation (Line(points={{-10,-60},
{-10,-100},{2,-100}}, color={0,127,255}));
annotation (Documentation(revisions="<html>
<ul>
<li>
March 17, 2020, Filip Jorissen:<br/>
Added support for vector fluidport.
See <a href=\"https://github.com/open-ideas/IDEAS/issues/1029\">#1029</a>.
</li>
<li>
April 27, 2018 by Filip Jorissen:<br/>
First version.
See <a href=\"https://github.com/open-ideas/IDEAS/issues/796\">#796</a>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ model FixedPressure "FixedPressure: idealised, fixed pressure boundary"
IDEAS.Buildings.Components.InterzonalAirFlow.BaseClasses.PartialInterzonalAirFlowBoundary(
prescribesPressure=true,
verifyBothPortsConnected=true,
nPorts=1,
nPorts=1+nPortsExt,
bou(nPorts=1));
equation
connect(bou.ports[1], ports[1]) annotation (Line(points={{-6.66134e-16,0},{2,0},{2,-100}},
color={0,127,255}));
annotation (Documentation(revisions="<html>
<ul>
<li>
March 17, 2020, Filip Jorissen:<br/>
Added support for vector fluidport.
See <a href=\"https://github.com/open-ideas/IDEAS/issues/1029\">#1029</a>.
</li>
<li>
January 25, 2019, Filip Jorissen:<br/>
Added constant <code>prescribesPressure</code> that indicates
whether this model prescribes the zone air pressure or not.
Expand Down
10 changes: 8 additions & 2 deletions IDEAS/Buildings/Components/InterzonalAirFlow/n50FixedPressure.mo
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ model n50FixedPressure
prescribesPressure=true,
verifyBothPortsConnected=true);
equation
connect(bou.ports[2], ports[2]) annotation (Line(points={{2,0},{2,-50},{2,-100},
{22,-100}},color={0,127,255}));
connect(bou.ports[2], ports[2]) annotation (Line(points={{-1.77636e-15,0},{
-1.77636e-15,-50},{-1.77636e-15,-100},{2,-100}},
color={0,127,255}));
annotation (Documentation(revisions="<html>
<ul>
<li>
March 17, 2020, Filip Jorissen:<br/>
Added support for vector fluidport.
See <a href=\"https://github.com/open-ideas/IDEAS/issues/1029\">#1029</a>.
</li>
<li>
January 25, 2019, Filip Jorissen:<br/>
Added constant <code>prescribesPressure</code> that indicates
whether this model prescribes the zone air pressure or not.
Expand Down
12 changes: 9 additions & 3 deletions IDEAS/Buildings/Components/InterzonalAirFlow/n50Tight.mo
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@ equation
connect(airExfiltration.m_flow_in, airInfiltration.m_flow_in)
annotation (Line(points={{2,-56},{-18,-56},{-18,-44}}, color={0,0,127}));
connect(airExfiltration.port_b, bou.ports[2])
annotation (Line(points={{10,-40},{10,0},{2,0}}, color={0,127,255}));
connect(airExfiltration.port_a, ports[2]) annotation (Line(points={{10,-60},{10,
-100},{22,-100},{22,-100}},
annotation (Line(points={{10,-40},{10,0},{-1.77636e-15,0}},
color={0,127,255}));
connect(airExfiltration.port_a, ports[2]) annotation (Line(points={{10,-60},{
10,-100},{2,-100},{2,-100}},
color={0,127,255}));
annotation (Documentation(revisions="<html>
<ul>
<li>
March 17, 2020, Filip Jorissen:<br/>
Added support for vector fluidport.
See <a href=\"https://github.com/open-ideas/IDEAS/issues/1029\">#1029</a>.
</li>
<li>
January 25, 2019, Filip Jorissen:<br/>
Added constant <code>prescribesPressure</code> that indicates
whether this model prescribes the zone air pressure or not.
Expand Down
Loading

0 comments on commit 3153b6f

Please sign in to comment.