Package with utility functions
Package Content
| Name | Description |
BaseClasses
| Library with base classes for utility functions |
EfficiencyCurves
| Package with functions for efficiency curves |
Examples
| Collection of models that illustrate model use and test models |
extendedPolynomial
| Polynomial that is linearly extended at user specified values |
polynomial
| Polynomial, used because OpenModelica 1.4.3 does not expand the sum() into a scalar |
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.
Extends from Modelica.Icons.Function (Icon for a function).
Inputs
| Type | Name | Default | Description |
| Real | c[:] | | Polynomial coefficients |
| Real | x | | x value |
| Real | xMin | | Minimum x value for polynomial |
| Real | xMax | | Maximum x value for polynomial |
Outputs
| Type | Name | Description |
| Real | y | y 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;
Polynomial, used because OpenModelica 1.4.3 does not expand the sum() into a scalar
Inputs
| Type | Name | Default | Description |
| Real | c[:] | | Coefficients |
| Real | x | | Independent variable |
Outputs
| Type | Name | Description |
| Real | y | Dependent 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;
HTML-documentation generated by Dymola Tue Sep 29 08:09:26 2009.