Skip to content

Commit 4ef804b

Browse files
committed
IBPSA
1 parent 80fc870 commit 4ef804b

File tree

3,392 files changed

+708199
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,392 files changed

+708199
-0
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
within BuildSysPro.IBPSA.Airflow.Multizone.BaseClasses;
2+
partial model Door
3+
"Partial door model for bi-directional flow"
4+
extends IBPSA.Fluid.Interfaces.PartialFourPortInterface(
5+
redeclare final package Medium1 = Medium,
6+
redeclare final package Medium2 = Medium,
7+
final allowFlowReversal1=true,
8+
final allowFlowReversal2=true,
9+
final m1_flow_nominal=10/3600*1.2,
10+
final m2_flow_nominal=m1_flow_nominal,
11+
final m1_flow_small=1E-4*abs(m1_flow_nominal),
12+
final m2_flow_small=1E-4*abs(m2_flow_nominal));
13+
14+
replaceable package Medium =
15+
Modelica.Media.Interfaces.PartialMedium "Medium in the component"
16+
annotation (choices(
17+
choice(redeclare package Medium = IBPSA.Media.Air "Moist air")));
18+
19+
parameter Modelica.Units.SI.Length wOpe=0.9 "Width of opening"
20+
annotation (Dialog(group="Geometry"));
21+
parameter Modelica.Units.SI.Length hOpe=2.1 "Height of opening"
22+
annotation (Dialog(group="Geometry"));
23+
24+
parameter Modelica.Units.SI.PressureDifference dp_turbulent(
25+
min=0,
26+
displayUnit="Pa") = 0.01
27+
"Pressure difference where laminar and turbulent flow relation coincide"
28+
annotation (Dialog(tab="Advanced"));
29+
30+
Modelica.Units.SI.VolumeFlowRate VAB_flow(nominal=0.001)
31+
"Volume flow rate from A to B if positive";
32+
Modelica.Units.SI.VolumeFlowRate VBA_flow(nominal=0.001)
33+
"Volume flow rate from B to A if positive";
34+
35+
input Modelica.Units.SI.Velocity vAB(nominal=0.01)
36+
"Average velocity from A to B";
37+
input Modelica.Units.SI.Velocity vBA(nominal=0.01)
38+
"Average velocity from B to A";
39+
40+
protected
41+
final parameter Modelica.Units.SI.Area AOpe=wOpe*hOpe "Open aperture area";
42+
43+
constant Real conTP=IBPSA.Media.Air.dStp *Modelica.Media.IdealGases.Common.SingleGasesData.Air.R_s
44+
"Conversion factor for converting temperature difference to pressure difference";
45+
46+
parameter Medium.ThermodynamicState sta_default=Medium.setState_pTX(
47+
T=Medium.T_default,
48+
p=Medium.p_default,
49+
X=Medium.X_default);
50+
51+
parameter Modelica.Units.SI.Density rho_default=Medium.density(sta_default)
52+
"Density";
53+
54+
Modelica.Units.SI.VolumeFlowRate VABp_flow(nominal=0.001)
55+
"Volume flow rate from A to B if positive due to static pressure difference";
56+
Modelica.Units.SI.MassFlowRate mABt_flow(nominal=0.001)
57+
"Mass flow rate from A to B if positive due to buoyancy";
58+
59+
equation
60+
// Net flow rate
61+
port_a1.m_flow = (rho_default * VABp_flow/2 + mABt_flow);
62+
port_b2.m_flow = (rho_default * VABp_flow/2 - mABt_flow);
63+
64+
// Average velocity (using the whole orifice area)
65+
VAB_flow = (max(port_a1.m_flow, 0) + max(port_b2.m_flow, 0))/rho_default;
66+
VBA_flow = (max(port_a2.m_flow, 0) + max(port_b1.m_flow, 0))/rho_default;
67+
68+
// Energy balance (no storage, no heat loss/gain)
69+
port_a1.h_outflow = inStream(port_b1.h_outflow);
70+
port_b1.h_outflow = inStream(port_a1.h_outflow);
71+
port_a2.h_outflow = inStream(port_b2.h_outflow);
72+
port_b2.h_outflow = inStream(port_a2.h_outflow);
73+
74+
// Mass balance (no storage)
75+
port_a1.m_flow = -port_b1.m_flow;
76+
port_a2.m_flow = -port_b2.m_flow;
77+
78+
port_a1.Xi_outflow = inStream(port_b1.Xi_outflow);
79+
port_b1.Xi_outflow = inStream(port_a1.Xi_outflow);
80+
port_a2.Xi_outflow = inStream(port_b2.Xi_outflow);
81+
port_b2.Xi_outflow = inStream(port_a2.Xi_outflow);
82+
83+
// Transport of trace substances
84+
port_a1.C_outflow = inStream(port_b1.C_outflow);
85+
port_b1.C_outflow = inStream(port_a1.C_outflow);
86+
port_a2.C_outflow = inStream(port_b2.C_outflow);
87+
port_b2.C_outflow = inStream(port_a2.C_outflow);
88+
89+
annotation (
90+
Icon(graphics={
91+
Rectangle(
92+
extent={{-60,80},{60,-84}},
93+
lineColor={0,0,255},
94+
pattern=LinePattern.None,
95+
fillColor={85,75,55},
96+
fillPattern=FillPattern.Solid),
97+
Rectangle(
98+
extent={{-54,72},{56,-84}},
99+
lineColor={0,0,0},
100+
fillColor={215,215,215},
101+
fillPattern=FillPattern.Solid),
102+
Polygon(
103+
points={{56,72},{-36,66},{-36,-90},{56,-84},{56,72}},
104+
lineColor={0,0,0},
105+
fillColor={95,95,95},
106+
fillPattern=FillPattern.Solid),
107+
Polygon(
108+
points={{-30,-10},{-16,-8},{-16,-14},{-30,-16},{-30,-10}},
109+
lineColor={0,0,255},
110+
pattern=LinePattern.None,
111+
fillColor={0,0,0},
112+
fillPattern=FillPattern.Solid)}),
113+
Documentation(info="<html>
114+
<p>
115+
This is a partial model for the bi-directional air flow through a door.
116+
</p>
117+
</html>",
118+
revisions="<html>
119+
<ul>
120+
<li>
121+
October 6, 2020, by Michael Wetter:<br/>
122+
First implementation for
123+
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1353\">#1353</a>.
124+
</li>
125+
</ul>
126+
</html>"));
127+
end Door;
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
within BuildSysPro.IBPSA.Airflow.Multizone.BaseClasses;
2+
partial model DoorDiscretized
3+
"Door model using discretization along height coordinate"
4+
extends
5+
IBPSA.Airflow.Multizone.BaseClasses.TwoWayFlowElementBuoyancy;
6+
7+
parameter Integer nCom=10 "Number of compartments for the discretization";
8+
9+
parameter Modelica.Units.SI.PressureDifference dp_turbulent(
10+
min=0,
11+
displayUnit="Pa") = 0.01
12+
"Pressure difference where laminar and turbulent flow relation coincide. Recommended: 0.01";
13+
14+
Modelica.Units.SI.PressureDifference dpAB[nCom](each nominal=1)
15+
"Pressure difference between compartments";
16+
Modelica.Units.SI.Velocity v[nCom](each nominal=0.01)
17+
"Velocity in compartment from A to B";
18+
Modelica.Units.SI.Velocity vTop "Velocity at top of opening from A to B";
19+
Modelica.Units.SI.Velocity vBot "Velocity at bottom of opening from A to B";
20+
21+
protected
22+
parameter Modelica.Units.SI.Length dh=hOpe/nCom "Height of each compartment";
23+
24+
parameter Medium.ThermodynamicState sta_default=Medium.setState_pTX(
25+
T=Medium.T_default,
26+
p=Medium.p_default,
27+
X=Medium.X_default);
28+
29+
parameter Modelica.Units.SI.Density rho_default=Medium.density(sta_default)
30+
"Density, used to compute fluid volume";
31+
32+
parameter Real hAg[nCom](each unit="m2/s2")=
33+
{Modelica.Constants.g_n*(hA - (i - 0.5)*dh) for i in 1:nCom}
34+
"Product g*h_i for each compartment";
35+
36+
parameter Real hBg[nCom](each unit="m2/s2")=
37+
{Modelica.Constants.g_n*(hB - (i - 0.5)*dh) for i in 1:nCom}
38+
"Product g*h_i for each compartment";
39+
Modelica.Units.SI.AbsolutePressure pA[nCom](each nominal=101325)
40+
"Pressure in compartments of room A";
41+
Modelica.Units.SI.AbsolutePressure pB[nCom](each nominal=101325)
42+
"Pressure in compartments of room B";
43+
44+
Modelica.Units.SI.VolumeFlowRate dV_flow[nCom]
45+
"Volume flow rate through compartment from A to B";
46+
Modelica.Units.SI.VolumeFlowRate dVAB_flow[nCom]
47+
"Volume flow rate through compartment from A to B if positive";
48+
Modelica.Units.SI.VolumeFlowRate dVBA_flow[nCom]
49+
"Volume flow rate through compartment from B to A if positive";
50+
Modelica.Units.SI.VolumeFlowRate VZerCom_flow=VZer_flow/nCom
51+
"Small flow rate for regularization";
52+
53+
Real m(min=0.5, max=1) "Flow exponent, m=0.5 for turbulent, m=1 for laminar";
54+
Real CVal "Flow coefficient for each compartment, C = V_flow/ dp^m";
55+
Modelica.Units.SI.Area dA "Compartment area";
56+
Real gaiFlo[nCom] "Gain to sum up the positive flows and set the negative to zero in a differentiable way";
57+
equation
58+
dA = A/nCom;
59+
60+
for i in 1:nCom loop
61+
// pressure drop in each compartment
62+
pA[i] = port_a1.p + rho_a1_inflow*hAg[i];
63+
pB[i] = port_a2.p + rho_a2_inflow*hBg[i];
64+
dpAB[i] = pA[i] - pB[i];
65+
v[i] = dV_flow[i]/dA;
66+
// assignment of net volume flows
67+
gaiFlo[i] = IBPSA.Utilities.Math.Functions.smoothHeaviside(x=dV_flow[i],
68+
delta=VZerCom_flow);
69+
dVAB_flow[i] = dV_flow[i] * gaiFlo[i];
70+
dVBA_flow[i] = -dV_flow[i] * (1-gaiFlo[i]);
71+
end for;
72+
// add positive and negative flows
73+
VAB_flow = sum(dVAB_flow);
74+
VBA_flow = sum(dVBA_flow);
75+
vTop = v[nCom];
76+
vBot = v[1];
77+
annotation (
78+
Icon(graphics={
79+
Rectangle(
80+
extent={{-60,80},{60,-84}},
81+
lineColor={0,0,255},
82+
pattern=LinePattern.None,
83+
fillColor={85,75,55},
84+
fillPattern=FillPattern.Solid),
85+
Rectangle(
86+
extent={{-54,72},{56,-84}},
87+
lineColor={0,0,0},
88+
fillColor={215,215,215},
89+
fillPattern=FillPattern.Solid),
90+
Polygon(
91+
points={{56,72},{-36,66},{-36,-90},{56,-84},{56,72}},
92+
lineColor={0,0,0},
93+
fillColor={95,95,95},
94+
fillPattern=FillPattern.Solid),
95+
Polygon(
96+
points={{-30,-10},{-16,-8},{-16,-14},{-30,-16},{-30,-10}},
97+
lineColor={0,0,255},
98+
pattern=LinePattern.None,
99+
fillColor={0,0,0},
100+
fillPattern=FillPattern.Solid),
101+
Line(points={{-54,48},{-36,48}}, color={0,0,0}),
102+
Line(points={{-54,20},{-36,20}}, color={0,0,0}),
103+
Line(points={{-54,-6},{-36,-6}}, color={0,0,0}),
104+
Line(points={{-54,-58},{-36,-58}}, color={0,0,0}),
105+
Line(points={{-54,-32},{-36,-32}}, color={0,0,0})}),
106+
Documentation(info="<html>
107+
<p>
108+
This is a partial model for the bi-directional air flow through a door.
109+
</p>
110+
<p>
111+
To compute the bi-directional flow,
112+
the door is discretize along the height coordinate, and uses
113+
an orifice equation to compute the flow for each compartment.
114+
</p>
115+
<p>
116+
The compartment area <code>dA</code> is a variable, which allows
117+
using the model for a door that can be open or closed.
118+
</p>
119+
</html>",
120+
revisions="<html>
121+
<ul>
122+
<li>
123+
January 8, 2019, by Michael Wetter:<br/>
124+
Moved parameter <code>CD</code> from
125+
<a href=\"modelica://BuildSysPro.IBPSA.Airflow.Multizone.BaseClasses.DoorDiscretized\">
126+
IBPSA.Airflow.Multizone.BaseClasses.DoorDiscretized</a>
127+
to
128+
<a href=\"modelica://BuildSysPro.IBPSA.Airflow.Multizone.DoorDiscretizedOpen\">
129+
IBPSA.Airflow.Multizone.DoorDiscretizedOpen</a>.<br/>
130+
This is for
131+
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/971\">#971</a>.
132+
</li>
133+
<li>
134+
June 27, 2018, by Michael Wetter:<br/>
135+
Corrected old parameter annotation.
136+
</li>
137+
<li>
138+
June 6, 2018, by Michael Wetter:<br/>
139+
Removed term that assures non-zero flow rate in each path, and
140+
reformulated flow balance to ensure that model is symmetric.
141+
This is
142+
for <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/937\">#937</a>.
143+
</li>
144+
<li>
145+
January 22, 2016, by Michael Wetter:<br/>
146+
Corrected type declaration of pressure difference.
147+
This is
148+
for <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/404\">#404</a>.
149+
</li>
150+
<li>
151+
September 26, 2013 by Michael Wetter:<br/>
152+
Added missing <code>each</code> keyword.
153+
</li>
154+
<li>
155+
December 14, 2012 by Michael Wetter:<br/>
156+
Renamed protected parameters for consistency with the naming conventions.
157+
</li>
158+
<li><i>December 6, 2011</i> by Michael Wetter:<br/>
159+
Removed protected variable <code>rhoAve</code>.
160+
</li>
161+
<li><i>August 12, 2011</i> by Michael Wetter:<br/>
162+
Changed model to use the new function
163+
<a href=\"modelica://BuildSysPro.IBPSA.Airflow.Multizone.BaseClasses.powerLawFixedM\">
164+
Buildings.Airflow.Multizone.BaseClasses.powerLawFixedM</a>.
165+
</li>
166+
<li><i>July 20, 2010</i> by Michael Wetter:<br/>
167+
Migrated model to Modelica 3.1 and integrated it into the Buildings library.
168+
</li>
169+
<li><i>February 8, 2005</i> by Michael Wetter:<br/>
170+
Released first version.
171+
</li>
172+
</ul>
173+
</html>"));
174+
end DoorDiscretized;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
within BuildSysPro.IBPSA.Airflow.Multizone.BaseClasses;
2+
model ErrorControl "Interface that defines parameters for error control"
3+
parameter Boolean forceErrorControlOnFlow = true
4+
"Flag to force error control on m_flow. Set to true if interested in flow rate"
5+
annotation(Dialog(tab="Advanced"));
6+
7+
annotation (Documentation(info="<html>
8+
<p>
9+
This is an interface that defines parameters used for error control.
10+
</p>
11+
<p>
12+
Dymola does error control on state variables, such as temperature, pressure and
13+
species concentration.
14+
Flow variables such as <code>m_flow</code> are typically not checked during the error control.
15+
This can give large errors in flow variables, as long as the error on the volume's state variables
16+
that are coupled to the flow variables is small.
17+
Obtaining accurate flow variables can be achieved by imposing an error control
18+
on the exchanged mass, which can be defined as
19+
</p>
20+
<pre>
21+
dm/dt = m_flow.
22+
</pre>
23+
<p>
24+
By setting <code>forceErrorControlOnFlow = true</code>, such an equation is imposed
25+
by models that extend this class.
26+
</p>
27+
</html>",
28+
revisions="<html>
29+
<ul>
30+
<li>
31+
June 27, 2018, by Michael Wetter:<br/>
32+
Moved parameter <code>forceErrorControlOnFlow</code> to the Advanced tab.
33+
</li>
34+
<li>
35+
July 20, 2010 by Michael Wetter:<br/>
36+
Integrated model into the Buildings library.
37+
</li>
38+
<li>
39+
November 1, 2005 by Michael Wetter:<br/>
40+
Released first version.
41+
</li>
42+
</ul>
43+
</html>"));
44+
end ErrorControl;

0 commit comments

Comments
 (0)