LBL logo

Buildings.Fluid.Utilities

Package with utility functions

Information

This package contains utility classes that are used by the package Buildings.Fluid.

Extends from Modelica.Icons.Package (Icon for standard packages).

Package Content

NameDescription
Buildings.Fluid.Utilities.extendedPolynomial extendedPolynomial Polynomial that is linearly extended at user specified values
Buildings.Fluid.Utilities.polynomial polynomial Polynomial, used because OpenModelica 1.4.3 does not expand the sum() into a scalar
Buildings.Fluid.Utilities.Examples Examples Collection of models that illustrate model use and test models
Buildings.Fluid.Utilities.BaseClasses BaseClasses Package with base classes for Buildings.Fluid.Utilities


Buildings.Fluid.Utilities.extendedPolynomial Buildings.Fluid.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 = ∑i=1n ci xi-1

where N > 1 and xmin, xmax are parameters. For x < xmin and x > xmax, the polynomial is replaced by a linear function in such a way that the first derivative is continuous everywhere.

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

TypeNameDefaultDescription
Realx x value
Realc[:] Polynomial coefficients
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 x "x value";
  input Real[:] c "Polynomial coefficients";
  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.Fluid.Utilities.polynomial Buildings.Fluid.Utilities.polynomial

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

Information

Function that computes

y = ∑i=1n ci xi-1

Extends from Modelica.Icons.Function (Icon for functions).

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;

Automatically generated Wed Feb 29 16:53:32 2012.