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

New (and updated) Airflow Classes #1437

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
22dde74
New and updated Multizone Baseclasses
kldjonge Dec 10, 2020
1823d32
New and updated 1-way-flow airflow components
kldjonge Dec 10, 2020
08612d1
IDEAL prescribed mover and Outside_CpData
kldjonge Dec 10, 2020
cb0891e
Suitable component names and package order
kldjonge Jan 19, 2021
f4ea191
Cherry Picked review from Massimo Cimmino
kldjonge Mar 26, 2021
17da543
Changed names in Multizone package and fixes
kldjonge Apr 6, 2021
a1b235c
Deleted PrescibedFlow
kldjonge Apr 6, 2021
2a7212d
Fixes for various flow elements
kldjonge Apr 6, 2021
5a88acc
set missing default m_flow_nominal for TableData models
kldjonge Apr 6, 2021
68eb9a1
Updated m_flow_nominal for powerlaw airflow models.
kldjonge Apr 6, 2021
aad4cac
Validation case with embedded CONTAM reference results
kldjonge Apr 6, 2021
c366ba0
Outside_CpData (fixes and example)
kldjonge Apr 6, 2021
c7e4c6b
Updates to annotation
kldjonge Apr 6, 2021
3e6a16d
Examples for flowElementData and windPressureProfile functions
kldjonge Apr 6, 2021
1160e3d
Fixes for flowElementData and windPressureProfile
kldjonge Apr 6, 2021
ac239a6
Updated userguide and revision history
kldjonge Apr 6, 2021
223239a
Cleaned up models where fix was unnecessary
kldjonge Apr 6, 2021
c2b0448
Flow element annotation changes
kldjonge May 3, 2021
2a37982
Examples for new flow elements
kldjonge May 3, 2021
dbca4e7
Updated Outside_CpData and it's example
kldjonge May 3, 2021
c13be0d
Cleaned up OneWayFlow validation case
kldjonge May 3, 2021
3008208
Optional: script for airflow element validation
kldjonge May 3, 2021
9100efb
Updates for OneWayFlow validation case and .mos file
kldjonge Jun 10, 2021
8ff0d7c
Additional comments in example models
kldjonge Jun 10, 2021
03710b7
Deleted obsolete script for OneWayFlow validation
kldjonge Jun 10, 2021
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
51 changes: 51 additions & 0 deletions IBPSA/Airflow/Multizone/BaseClasses/Examples/FlowElementData.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
within IBPSA.Airflow.Multizone.BaseClasses.Examples;
model FlowElementData "Test model for flowElementData function"
extends Modelica.Icons.Example;


parameter Real table[:,:]=[-50,-0.08709; -25,-0.06158; -10,-0.03895; -5,-0.02754;
-3,-0.02133; -2,-0.01742; -1,-0.01232; 0,0; 1,0.01232; 2,0.01742; 3,0.02133;
4.5,0.02613; 50,0.02614] "Table of mass flow rate in kg/s (second column) as a function of pressure difference in Pa (first column)";

Modelica.SIunits.PressureDifference dp;
Modelica.SIunits.MassFlowRate m_flow "Wind pressure coefficient";

protected
parameter Real[:] xd=table[:,1] "X-axis support points";
parameter Real[size(xd, 1)] yd=table[:,2] "Y-axis support points";
parameter Real[size(xd, 1)] d(each fixed=false) "Derivatives at the support points";

Modelica.Blocks.Sources.Ramp ramp(
duration=500,
height=100,
offset=-50) "min50pa_plus50pa";
initial equation
d =IBPSA.Utilities.Math.Functions.splineDerivatives(
x=xd,
y=yd,
ensureMonotonicity=true);
equation
dp=ramp.y;
m_flow =IBPSA.Airflow.Multizone.BaseClasses.flowElementData(u=dp,xd=xd,yd=yd,d=d);

annotation (
experiment(
StopTime=500,
Tolerance=1e-06,
__Dymola_Algorithm="Dassl"),
__Dymola_Commands(file="modelica://IBPSA/Resources/Scripts/Dymola/Airflow/Multizone/BaseClasses/Examples/WindPressureLowRise.mos"
"Simulate and plot"), Documentation(info="<html>
<p>
This examples demonstrates the
<a href=\"modelica://IBPSA.Airflow.Multizone.BaseClasses.flowElementData\">
IBPSA.Airflow.Multizone.BaseClasses.flowElementData</a>
function.
</p>
</html>", revisions="<html>
<ul>
<li>Apr 6, 2021, 2020, by Klaas De Jonge (UGent):<br/>
First implementation</li>
</ul>
</html>
"));
end FlowElementData;
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
within IBPSA.Airflow.Multizone.BaseClasses.Examples;
model WindPressureProfile
"Test model for wind pressure profile function"
extends Modelica.Icons.Example;


parameter Real table[:,:]=[0,0.4; 45,0.1; 90,-0.3; 135,-0.35; 180,-0.2; 225,-0.35; 270,-0.3; 315,0.1; 360,0.4];
Modelica.SIunits.Angle alpha "Wind incidence angle (0: normal to wall)";
Real Cp "Wind pressure coefficient";


//Extend table
protected
Real Radtable[:,:] = [Modelica.Constants.D2R*table[:,1],table[:,2]];
Real prevPoint[1,2] = [Radtable[size(table, 1)-1, 1] - (2*Modelica.Constants.pi), Radtable[size(table, 1)-1, 2]];
Real nextPoint[1,2] = [Radtable[2, 1] + (2*Modelica.Constants.pi), Radtable[2, 2]];
Real exTable[:,:]=[prevPoint;Radtable;nextPoint]; //Extended table

//Arguments for windPressureProfile function
Real[:] xd=exTable[:,1] "Support points x-value";
Real[size(xd, 1)] yd=exTable[:,2] "Support points y-value";
Real[size(xd, 1)] d=IBPSA.Utilities.Math.Functions.splineDerivatives(x=xd,y=yd,ensureMonotonicity=false) "Spline derivative values at the support points";

Modelica.Blocks.Sources.Ramp ramp(
duration=500,
height=3*360,
offset=-360);


initial equation
//continuity at 0 and 360 must be assured
assert(table[1,2]<>0 or table[end,2]<>360, "First and last point in the table must be 0 and 360", level = AssertionLevel.error);

equation
alpha=Modelica.Constants.D2R*ramp.y;
Cp =IBPSA.Airflow.Multizone.BaseClasses.windPressureProfile(u=alpha, xd=xd,yd=yd,d=d);

annotation (
experiment(
StopTime=500,
Tolerance=1e-06,
__Dymola_Algorithm="Dassl"),
__Dymola_Commands(file="modelica://IBPSA/Resources/Scripts/Dymola/Airflow/Multizone/BaseClasses/Examples/WindPressureLowRise.mos"
"Simulate and plot"), Documentation(info="<html>
<p>
This examples demonstrates the
<a href=\"modelica://IBPSA.Airflow.Multizone.BaseClasses.windPressureProfile\">
IBPSA.Airflow.Multizone.BaseClasses.windPressureProfile</a>
function.
</p>
</html>", revisions="<html>
<ul>
<li>Apr 6, 2021, 2020, by Klaas De Jonge (UGent):<br/>
First implementation</li>
</ul>
</html>
"));
end WindPressureProfile;
2 changes: 2 additions & 0 deletions IBPSA/Airflow/Multizone/BaseClasses/Examples/package.order
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
FlowElementData
PowerLaw
PowerLawFixedM
WindPressureLowRise
WindPressureProfile
112 changes: 112 additions & 0 deletions IBPSA/Airflow/Multizone/BaseClasses/PartialOneWayFlowelement.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
within IBPSA.Airflow.Multizone.BaseClasses;
partial model PartialOneWayFlowElement
"Partial model for flow resistance with one-way flow"
extends IBPSA.Fluid.Interfaces.PartialTwoPortInterface(
final allowFlowReversal=true);

extends IBPSA.Airflow.Multizone.BaseClasses.ErrorControl;

parameter Boolean useDefaultProperties=true
"Set to false to use density and viscosity based on actual medium state, rather than using default values"
annotation(Evaluate=true, Dialog(tab="Advanced"));
parameter Modelica.SIunits.PressureDifference dp_turbulent(min=0, displayUnit="Pa") = 0.1
"Pressure difference where laminar and turbulent flow relation coincide. Recommended = 0.1"
annotation(Dialog(tab="Advanced"));


constant Boolean homotopyInitialization = true "= true, use homotopy method"
annotation(HideResult=true, Dialog(tab="Advanced"));

Modelica.SIunits.VolumeFlowRate V_flow
"Volume flow rate through the component";
Modelica.SIunits.Density rho "Fluid density at port_a";

protected
parameter Medium.ThermodynamicState sta_default=Medium.setState_pTX(
T=Medium.T_default,
p=Medium.p_default,
X=Medium.X_default)
"State of the medium at the medium default properties";
parameter Modelica.SIunits.Density rho_default=Medium.density(sta_default)
"Density at the medium default properties";
parameter Modelica.SIunits.DynamicViscosity dynVis_default=
Medium.dynamicViscosity(sta_default)
"Dynamic viscosity at the medium default properties";

Medium.ThermodynamicState sta "State of the medium in the component";
Modelica.SIunits.DynamicViscosity dynVis "Dynamic viscosity";
Real mExc(quantity="Mass", final unit="kg")
"Air mass exchanged (for purpose of error control only)";

initial equation
mExc=0;
assert(homotopyInitialization, "In " + getInstanceName() +
": The constant homotopyInitialization has been modified from its default value. This constant will be removed in future releases.",
level = AssertionLevel.warning);

equation
if forceErrorControlOnFlow then
der(mExc) = port_a.m_flow;
else
der(mExc) = 0;
end if;

if useDefaultProperties then
sta = sta_default;
rho = rho_default;
dynVis = dynVis_default;

else
sta = if homotopyInitialization then
Medium.setState_phX(
port_a.p,
homotopy(
actual=actualStream(port_a.h_outflow),
simplified=inStream(port_a.h_outflow)),
homotopy(
actual=actualStream(port_a.Xi_outflow),
simplified=inStream(port_a.Xi_outflow)))
else
Medium.setState_phX(
port_a.p,
actualStream(port_a.h_outflow),
actualStream(port_a.Xi_outflow));

rho = Medium.density(sta);
dynVis = Medium.dynamicViscosity(sta);
end if;

// Isenthalpic state transformation (no storage and no loss of energy)
port_a.h_outflow = inStream(port_b.h_outflow);
port_b.h_outflow = inStream(port_a.h_outflow);

// Mass balance (no storage)
port_a.m_flow + port_b.m_flow = 0;

// Transport of substances
port_a.Xi_outflow = inStream(port_b.Xi_outflow);
port_b.Xi_outflow = inStream(port_a.Xi_outflow);

port_a.C_outflow = inStream(port_b.C_outflow);
port_b.C_outflow = inStream(port_a.C_outflow);

//relation between massflow and volumeflow
m_flow=V_flow*rho;

annotation (
Documentation(info="<html>
<p>This partial model is used to model one way flow-elements. It holds the conservation equations and should be extended by definition of <u><b>one</b></u> of the following variables:</p>
<p><span style=\"font-family: Courier New;\">m_flow = mass flow rate trough the component</span></p>
<p><span style=\"font-family: Courier New;\">or</span></p>
<p><span style=\"font-family: Courier New;\">V_flow = volume flow rate through the component</span></p>
<p><br>The flow from A-&gt;B is the positive flow. This partial model can be used as a base for the interzonal air flow models. </p>
</html>",
revisions="<html>
<ul>
<li>
Apr 06, 2021, by Klaas De Jonge (UGent):<br/>
First implementation. PartialOneWayFlowelement serves as a baseclass for a clean implementation of m_flow and V_flow models
</li>
</ul>
</html>"));
end PartialOneWayFlowElement;
Original file line number Diff line number Diff line change
@@ -1,45 +1,17 @@
within IBPSA.Airflow.Multizone.BaseClasses;
partial model PowerLawResistance "Flow resistance that uses the power law"
extends IBPSA.Fluid.Interfaces.PartialTwoPortInterface(
final allowFlowReversal=true,
final m_flow_nominal=rho_default*k*dp_turbulent,
final m_flow_small=1E-4*abs(m_flow_nominal));
extends IBPSA.Airflow.Multizone.BaseClasses.ErrorControl;

constant Boolean homotopyInitialization = true "= true, use homotopy method"
annotation(HideResult=true);
partial model PartialPowerLawResistance
"Flow resistance that uses the power law"
extends IBPSA.Airflow.Multizone.BaseClasses.PartialOneWayFlowElement(
final m_flow_nominal=rho_default*k*dp_turbulent);

parameter Real m(min=0.5, max=1)
"Flow exponent, m=0.5 for turbulent, m=1 for laminar";
parameter Boolean useDefaultProperties=true
"Set to false to use density and viscosity based on actual medium state, rather than using default values"
annotation(Evaluate=true, Dialog(tab="Advanced"));
parameter Modelica.SIunits.PressureDifference dp_turbulent(min=0, displayUnit="Pa") = 0.1
"Pressure difference where laminar and turbulent flow relation coincide. Recommended = 0.1"
annotation(Dialog(tab="Advanced"));

Modelica.SIunits.VolumeFlowRate V_flow
"Volume flow rate through the component";
Modelica.SIunits.Velocity v(nominal=1) "Average velocity";
Modelica.SIunits.Density rho "Fluid density at port_a";
parameter Real k "Flow coefficient, k = m_flow/ dp^m";

protected
constant Real gamma(min=1) = 1.5
"Normalized flow rate where dphi(0)/dpi intersects phi(1)";

parameter Real k "Flow coefficient, k = V_flow/ dp^m";

parameter Medium.ThermodynamicState sta_default=Medium.setState_pTX(
T=Medium.T_default,
p=Medium.p_default,
X=Medium.X_default)
"State of the medium at the medium default properties";
parameter Modelica.SIunits.Density rho_default=Medium.density(sta_default)
"Density at the medium default properties";
parameter Modelica.SIunits.DynamicViscosity dynVis_default=
Medium.dynamicViscosity(sta_default)
"Dynamic viscosity at the medium default properties";

parameter Real a = gamma
"Polynomial coefficient for regularized implementation of flow resistance";
parameter Real b = 1/8*m^2 - 3*gamma - 3/2*m + 35.0/8
Expand All @@ -48,43 +20,7 @@ protected
"Polynomial coefficient for regularized implementation of flow resistance";
parameter Real d = 1/8*m^2 - gamma - m + 15.0/8
"Polynomial coefficient for regularized implementation of flow resistance";

Medium.ThermodynamicState sta "State of the medium in the component";
Modelica.SIunits.DynamicViscosity dynVis "Dynamic viscosity";
Real mExc(quantity="Mass", final unit="kg")
"Air mass exchanged (for purpose of error control only)";
initial equation
mExc=0;
assert(homotopyInitialization, "In " + getInstanceName() +
": The constant homotopyInitialization has been modified from its default value. This constant will be removed in future releases.",
level = AssertionLevel.warning);

equation
if forceErrorControlOnFlow then
der(mExc) = port_a.m_flow;
else
der(mExc) = 0;
end if;

if useDefaultProperties then
sta = sta_default;
rho = rho_default;
dynVis = dynVis_default;
else
sta = if homotopyInitialization then
Medium.setState_phX(port_a.p,
homotopy(actual=actualStream(port_a.h_outflow),
simplified=inStream(port_a.h_outflow)),
homotopy(actual=actualStream(port_a.Xi_outflow),
simplified=inStream(port_a.Xi_outflow)))
else
Medium.setState_phX(port_a.p,
actualStream(port_a.h_outflow),
actualStream(port_a.Xi_outflow));

rho = Medium.density(sta);
dynVis = Medium.dynamicViscosity(sta);
end if;

V_flow = IBPSA.Airflow.Multizone.BaseClasses.powerLawFixedM(
k=k,
Expand All @@ -96,43 +32,20 @@ equation
d=d,
dp_turbulent=dp_turbulent);

port_a.m_flow = rho*V_flow;

// Isenthalpic state transformation (no storage and no loss of energy)
port_a.h_outflow = inStream(port_b.h_outflow);
port_b.h_outflow = inStream(port_a.h_outflow);

// Mass balance (no storage)
port_a.m_flow + port_b.m_flow = 0;

// Transport of substances
port_a.Xi_outflow = inStream(port_b.Xi_outflow);
port_b.Xi_outflow = inStream(port_a.Xi_outflow);

port_a.C_outflow = inStream(port_b.C_outflow);
port_b.C_outflow = inStream(port_a.C_outflow);
annotation (
Documentation(info="<html>
<p>
This model describes the mass flow rate and pressure difference relation
of an orifice in the form
</p>
<pre>
V_flow = k * dp^m,
</pre>
<p>
where <code>k</code> is a variable and
<code>m</code> a parameter.
For turbulent flow, set <code>m=1/2</code> and
for laminar flow, set <code>m=1</code>.
</p>
<p>
The model is used as a base for the interzonal air flow models.
</p>
<p>This model describes the mass flow rate and pressure difference relation in the form </p>
<p><span style=\"font-family: Courier New;\">V_flow = k * dp^m,</span></p>
<p>where <span style=\"font-family: Courier New;\">k</span> and <span style=\"font-family: Courier New;\">m</span> are parameters. For turbulent flow, set <span style=\"font-family: Courier New;\">m=1/2</span> and for laminar flow, set <span style=\"font-family: Courier New;\">m=1</span>. </p>
<p>The model is used as a base for the interzonal air flow models. </p>
</html>",
revisions="<html>
<ul>
<li>
Apr 6, 2021, by Klaas De Jonge (UGent):<br/>
Changed baseclass to PartialOneWayFlowelement
</li>
<li>
May 12, 2020, by Michael Wetter:<br/>
Changed assignment of <code>m_flow_small</code> to <code>final</code>.
This quantity are not used in this model and models that extend from it.
Expand Down Expand Up @@ -211,4 +124,4 @@ Renamed protected parameters for consistency with the naming conventions.
Released first version.
</ul>
</html>"));
end PowerLawResistance;
end PartialPowerLawResistance;
Loading