Modelica.Fluid.Utilities

Utility models to construct fluid components (should not be used directly)

Information

Extends from Modelica.Icons.UtilitiesPackage (Icon for utility packages).

Package Content

Name Description
Modelica.Fluid.Utilities.checkBoundary checkBoundary Check whether boundary definition is correct
Modelica.Fluid.Utilities.regRoot regRoot Anti-symmetric square root approximation with finite derivative in the origin
Modelica.Fluid.Utilities.regRoot_der regRoot_der Derivative of regRoot
Modelica.Fluid.Utilities.regSquare regSquare Anti-symmetric square approximation with non-zero derivative in the origin
Modelica.Fluid.Utilities.regPow regPow Anti-symmetric power approximation with non-zero derivative in the origin
Modelica.Fluid.Utilities.regRoot2 regRoot2 Anti-symmetric approximation of square root with discontinuous factor so that the first derivative is finite and continuous
Modelica.Fluid.Utilities.regSquare2 regSquare2 Anti-symmetric approximation of square with discontinuous factor so that the first derivative is non-zero and is continuous
Modelica.Fluid.Utilities.regStep regStep Approximation of a general step, such that the characteristic is continuous and differentiable
Modelica.Fluid.Utilities.evaluatePoly3_derivativeAtZero evaluatePoly3_derivativeAtZero Evaluate polynomial of order 3 that passes the origin with a predefined derivative
Modelica.Fluid.Utilities.regFun3 regFun3 Co-monotonic and C1 smooth regularization function
Modelica.Fluid.Utilities.cubicHermite cubicHermite Evaluate a cubic Hermite spline
Modelica.Fluid.Utilities.cubicHermite_withDerivative cubicHermite_withDerivative Evaluate a cubic Hermite spline, return value and derivative

Modelica.Fluid.Utilities.checkBoundary Modelica.Fluid.Utilities.checkBoundary

Check whether boundary definition is correct

Information

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

Inputs

NameDescription
mediumName 
substanceNames[:]Names of substances
singleState 
define_p 
X_boundary[:] 
modelName 

Modelica.Fluid.Utilities.regRoot Modelica.Fluid.Utilities.regRoot

Anti-symmetric square root approximation with finite derivative in the origin

Information

This function approximates sqrt(abs(x))*sgn(x), such that the derivative is finite and smooth in x=0.

FunctionApproximationRange
y = regRoot(x)y ~= sqrt(abs(x))*sgn(x)abs(x) >>delta
y = regRoot(x)y ~= x/sqrt(delta)abs(x) << delta

With the default value of delta=0.01, the difference between sqrt(x) and regRoot(x) is 16% around x=0.01, 0.25% around x=0.1 and 0.0025% around x=1.

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

Inputs

NameDescription
x 
deltaRange of significant deviation from sqrt(abs(x))*sgn(x)

Outputs

NameDescription
y 

Modelica.Fluid.Utilities.regRoot_der Modelica.Fluid.Utilities.regRoot_der

Derivative of regRoot

Information

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

Inputs

NameDescription
x 
deltaRange of significant deviation from sqrt(x)
dxDerivative of x

Outputs

NameDescription
dy 

Modelica.Fluid.Utilities.regSquare Modelica.Fluid.Utilities.regSquare

Anti-symmetric square approximation with non-zero derivative in the origin

Information

This function approximates x^2*sgn(x), such that the derivative is non-zero in x=0.

FunctionApproximationRange
y = regSquare(x)y ~= x^2*sgn(x)abs(x) >>delta
y = regSquare(x)y ~= x*deltaabs(x) << delta

With the default value of delta=0.01, the difference between x^2 and regSquare(x) is 41% around x=0.01, 0.4% around x=0.1 and 0.005% around x=1.

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

Inputs

NameDescription
x 
deltaRange of significant deviation from x^2*sgn(x)

Outputs

NameDescription
y 

Modelica.Fluid.Utilities.regPow Modelica.Fluid.Utilities.regPow

Anti-symmetric power approximation with non-zero derivative in the origin

Information

This function approximates abs(x)^a*sign(x), such that the derivative is positive, finite and smooth in x=0.

FunctionApproximationRange
y = regPow(x)y ~= abs(x)^a*sgn(x)abs(x) >>delta
y = regPow(x)y ~= x*delta^(a-1)abs(x) << delta

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

Inputs

NameDescription
x 
a 
deltaRange of significant deviation from x^a*sgn(x)

Outputs

NameDescription
y 

Modelica.Fluid.Utilities.regRoot2 Modelica.Fluid.Utilities.regRoot2

Anti-symmetric approximation of square root with discontinuous factor so that the first derivative is finite and continuous

Information

Approximates the function

y = if x ≥ 0 then sqrt(k1*x) else -sqrt(k2*abs(x)), with k1, k2 ≥ 0

in such a way that within the region -x_small ≤ x ≤ x_small, the function is described by two polynomials of third order (one in the region -x_small .. 0 and one within the region 0 .. x_small) such that

Typical screenshots for two different configurations are shown below. The first one with k1=k2=1:

regRoot2_a.png

and the second one with k1=1 and k2=3:

regRoot2_b.png

The (smooth) derivative of the function with k1=1, k2=3 is shown in the next figure:

regRoot2_c.png

Literature

Fritsch F.N. and Carlson R.E. (1980):
Monotone piecewise cubic interpolation. SIAM J. Numerc. Anal., Vol. 17, No. 2, April 1980, pp. 238-246

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

Inputs

NameDescription
xAbscissa value
x_smallApproximation of function for |x| <= x_small
k1y = if x>=0 then sqrt(k1*x) else -sqrt(k2*|x|)
k2y = if x>=0 then sqrt(k1*x) else -sqrt(k2*|x|)
use_yd0= true, if yd0 shall be used
yd0Desired derivative at x=0: dy/dx = yd0

Outputs

NameDescription
yOrdinate value

Modelica.Fluid.Utilities.regSquare2 Modelica.Fluid.Utilities.regSquare2

Anti-symmetric approximation of square with discontinuous factor so that the first derivative is non-zero and is continuous

Information

Approximates the function

y = if x ≥ 0 then k1*x*x else -k2*x*x, with k1, k2 > 0

in such a way that within the region -x_small ≤ x ≤ x_small, the function is described by two polynomials of third order (one in the region -x_small .. 0 and one within the region 0 .. x_small) such that

A typical screenshot for k1=1, k2=3 is shown in the next figure:

regSquare2_b.png

The (smooth, non-zero) derivative of the function with k1=1, k2=3 is shown in the next figure:

regSquare2_b.png

Literature

Fritsch F.N. and Carlson R.E. (1980):
Monotone piecewise cubic interpolation. SIAM J. Numerc. Anal., Vol. 17, No. 2, April 1980, pp. 238-246

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

Inputs

NameDescription
xAbscissa value
x_smallApproximation of function for |x| <= x_small
k1y = (if x>=0 then k1 else k2)*x*|x|
k2y = (if x>=0 then k1 else k2)*x*|x|
use_yd0= true, if yd0 shall be used
yd0Desired derivative at x=0: dy/dx = yd0

Outputs

NameDescription
yOrdinate value

Modelica.Fluid.Utilities.regStep Modelica.Fluid.Utilities.regStep

Approximation of a general step, such that the characteristic is continuous and differentiable

Information

This function is used to approximate the equation

y = if x > 0 then y1 else y2;

by a smooth characteristic, so that the expression is continuous and differentiable:

y = smooth(1, if x >  x_small then y1 else
              if x < -x_small then y2 else f(y1, y2));

In the region -x_small < x < x_small a 2nd order polynomial is used for a smooth transition from y1 to y2.

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

Inputs

NameDescription
xAbscissa value
y1Ordinate value for x > 0
y2Ordinate value for x < 0
x_smallApproximation of step for -x_small <= x <= x_small; x_small >= 0 required

Outputs

NameDescription
yOrdinate value to approximate y = if x > 0 then y1 else y2

Modelica.Fluid.Utilities.evaluatePoly3_derivativeAtZero Modelica.Fluid.Utilities.evaluatePoly3_derivativeAtZero

Evaluate polynomial of order 3 that passes the origin with a predefined derivative

Information

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

Inputs

NameDescription
xValue for which polynomial shall be evaluated
x1Abscissa value
y1y1=f(x1)
y1dFirst derivative at y1
y0dFirst derivative at f(x=0)

Outputs

NameDescription
y 

Modelica.Fluid.Utilities.regFun3 Modelica.Fluid.Utilities.regFun3

Co-monotonic and C1 smooth regularization function

Information

Approximates a function in a region between x0 and x1 such that

In this region, a continuation is constructed from the given points (x0, y0), (x1, y1) and the respective derivatives. For this purpose, a single polynomial of third order or two cubic polynomials with a linear section in between are used [Gasparo and Morandi, 1991]. This algorithm was extended with two additional conditions to avoid saddle points with zero/infinite derivative that lead to integrator step size reduction to zero.

This function was developed for pressure loss correlations properly addressing the static head on top of the established requirements for monotonicity and smoothness. In this case, the present function allows to implement the exact solution in the limit of x1-x0 -> 0 or y1-y0 -> 0.

Typical screenshots for two different configurations are shown below. The first one illustrates five different settings of xi and yid:

regFun3_a.png

The second graph shows the continuous derivative of this regularization function:

regFun3_a.png

Literature

Gasparo M. G. and Morandi R. (1991):
Piecewise cubic monotone interpolation with assigned slopes. Computing, Vol. 46, Issue 4, December 1991, pp. 355 - 365.

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

Inputs

NameDescription
xAbscissa value
x0Lower abscissa value
x1Upper abscissa value
y0Ordinate value at lower abscissa value
y1Ordinate value at upper abscissa value
y0dDerivative at lower abscissa value
y1dDerivative at upper abscissa value

Outputs

NameDescription
yOrdinate value
cSlope of linear section between two cubic polynomials or dummy linear section slope if single cubic is used

Modelica.Fluid.Utilities.cubicHermite Modelica.Fluid.Utilities.cubicHermite

Evaluate a cubic Hermite spline

Information

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

Inputs

NameDescription
xAbscissa value
x1Lower abscissa value
x2Upper abscissa value
y1Lower ordinate value
y2Upper ordinate value
y1dLower gradient
y2dUpper gradient

Outputs

NameDescription
yInterpolated ordinate value

Modelica.Fluid.Utilities.cubicHermite_withDerivative Modelica.Fluid.Utilities.cubicHermite_withDerivative

Evaluate a cubic Hermite spline, return value and derivative

Information

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

Inputs

NameDescription
xAbscissa value
x1Lower abscissa value
x2Upper abscissa value
y1Lower ordinate value
y2Upper ordinate value
y1dLower gradient
y2dUpper gradient

Outputs

NameDescription
yInterpolated ordinate value
dy_dxDerivative dy/dx at abscissa value x
Automatically generated Thu Oct 1 16:08:00 2020.