Buildings.Fluids.Utilities

Package with utility functions

Package Content

NameDescription
Buildings.Fluids.Utilities.BaseClasses BaseClasses Library with base classes for utility functions
Buildings.Fluids.Utilities.Examples Examples Collection of models that illustrate model use and test models
Buildings.Fluids.Utilities.extendedPolynomial extendedPolynomial Polynomial that is linearly extended at user specified values
Buildings.Fluids.Utilities.massFlowRate_dp massFlowRate_dp Mass flow rate as a function of pressure drop
Buildings.Fluids.Utilities.polynomial polynomial Polynomial, used because OpenModelica 1.4.3 does not expand the sum() into a scalar
Buildings.Fluids.Utilities.pressureLoss_m_flow pressureLoss_m_flow Pressure loss as a function of flow rate


Buildings.Fluids.Utilities.extendedPolynomial Buildings.Fluids.Utilities.extendedPolynomial

Polynomial that is linearly extended at user specified values

Information


For x between the bounds xMin < x < xMax,
this function defines a polynomial 
   y = c1 + c2 * x + ... + cN * x^(N-1)
where N > 1 and xMin, xMax are parameters. For x < xMin and x > xMax, the polynomial is replaced with a linear function in such a way that the first derivative is continuous everywhere.

Inputs

TypeNameDefaultDescription
Realc[:] Polynomial coefficients
Realx x value
RealxMin Minimum x value for polynomial
RealxMax Maximum x value for polynomial

Outputs

TypeNameDescription
Realyy value

Modelica definition

function extendedPolynomial 
  "Polynomial that is linearly extended at user specified values" 
  annotation(derivative=BaseClasses.der_extendedPolynomial);  
  extends Modelica.Icons.Function;
  input Real[:] c "Polynomial coefficients";
  input Real x "x value";
  input Real xMin "Minimum x value for polynomial";
  input Real xMax "Maximum x value for polynomial";
  output Real y "y value";
protected 
 Integer N = size(c,1) "Number of coefficients";
algorithm 
if x < xMin then
   y := c[1];
   for i in 2:N loop
     y := y + xMin^(i - 1)*c[i] + (x - xMin)*(i - 1)*xMin^(i - 2)*c[i];
   end for;
  elseif x < xMax then
   y := c[1];
   for i in 2:N loop
     y := y + x^(i - 1)*c[i];
  end for;
  else
     y := c[1];
     for i in 2:N loop
       y := y + xMax^(i - 1)*c[i] + (x - xMax)*(i - 1)*xMax^(i - 2)*c[i];
    end for;
  end if;
end extendedPolynomial;

Buildings.Fluids.Utilities.massFlowRate_dp Buildings.Fluids.Utilities.massFlowRate_dp

Mass flow rate as a function of pressure drop

Inputs

TypeNameDefaultDescription
Pressuredp Pressure drop (dp = port_a.p - port_b.p) [Pa]
AbsolutePressuredp_small1Turbulent flow if |dp| >= dp_small [Pa]
Realk Flow coefficient, k=m_flow/sqrt(dp) [(kg*m)^(1/2)]

Outputs

TypeNameDescription
MassFlowRatem_flowMass flow rate from port_a to port_b [kg/s]

Modelica definition

function massFlowRate_dp 
  "Mass flow rate as a function of pressure drop" 
  extends Modelica.Icons.Function;
  import SI = Modelica.SIunits;
  input SI.Pressure dp "Pressure drop (dp = port_a.p - port_b.p)";
  input SI.AbsolutePressure dp_small = 1 "Turbulent flow if |dp| >= dp_small";
  input Real k(min=0, unit="(kg*m)^(1/2)") 
    "Flow coefficient, k=m_flow/sqrt(dp)";
  output SI.MassFlowRate m_flow "Mass flow rate from port_a to port_b";
protected 
   Real kk;
algorithm 
  kk:=k*k;
  m_flow:=Modelica_Fluid.Utilities.regRoot2(x=dp, x_small=dp_small, k1=kk, k2=kk);
end massFlowRate_dp;

Buildings.Fluids.Utilities.polynomial Buildings.Fluids.Utilities.polynomial

Polynomial, used because OpenModelica 1.4.3 does not expand the sum() into a scalar

Inputs

TypeNameDefaultDescription
Realc[:] Coefficients
Realx Independent variable

Outputs

TypeNameDescription
RealyDependent variable

Modelica definition

function polynomial 
  "Polynomial, used because OpenModelica 1.4.3 does not expand the sum() into a scalar" 
  extends Modelica.Icons.Function;
  input Real[:] c "Coefficients";
  input Real x "Independent variable";
  output Real y "Dependent variable";
algorithm 
 y := c[1];
 for i in 2 : size(c,1) loop
   y := y + x^(i-1) * c[i];
 end for;
end polynomial;

Buildings.Fluids.Utilities.pressureLoss_m_flow Buildings.Fluids.Utilities.pressureLoss_m_flow

Pressure loss as a function of flow rate

Inputs

TypeNameDefaultDescription
MassFlowRatem_flow Mass flow rate from port_a to port_b [kg/s]
MassFlowRatem_small_flow Mass flow rate where function is approximated [kg/s]
Realk Flow coefficient, k=dp/m_flow^2 [1/kg/m]

Outputs

TypeNameDescription
PressuredpPressure drop (dp = port_a.p - port_b.p) [Pa]

Modelica definition

function pressureLoss_m_flow 
  "Pressure loss as a function of flow rate" 
  extends Modelica.Icons.Function;
  import SI = Modelica.SIunits;
  input SI.MassFlowRate m_flow "Mass flow rate from port_a to port_b";
  input SI.MassFlowRate m_small_flow 
    "Mass flow rate where function is approximated";
  input Real k(min=0, unit="1/kg/m") "Flow coefficient, k=dp/m_flow^2";
  output SI.Pressure dp "Pressure drop (dp = port_a.p - port_b.p)";
algorithm 
  dp:=Modelica_Fluid.Utilities.regSquare2(
    x=m_flow,
    x_small=m_small_flow,
    k1=k,
    k2=k);
end pressureLoss_m_flow;

HTML-documentation generated by Dymola Fri Oct 31 16:23:54 2008.