Buildings.Utilities.Math.Functions.Examples
Collection of models that illustrate model use and test models
Information
This package contains examples for the use of models that can be found in Buildings.Utilities.Math.Functions.
Extends from Modelica.Icons.ExamplesPackage (Icon for packages containing runnable examples).
Package Content
Name | Description |
---|---|
BesselJ0 | Test case for Bessel function J0 |
BesselJ1 | Test case for Bessel function J1 |
BesselY0 | Test case for Bessel function Y0 |
BesselY1 | Test case for Bessel function Y1 |
Binomial | Test case for evaluation of binomial coefficients |
CubicHermite | Test problem for cubic hermite splines |
ExponentialIntegralE1 | Test case for the exponential integral, E1 |
Factorial | Test case for evaluation of factorials |
FallingFactorial | Test case for evaluation of falling factorials |
InverseXDerivativeCheck | Model that checks the correct implementation of the 1st order derivative of InverseXRegularized |
InverseXDerivative_2_Check | Model that checks the correct implementation of the 2nd order derivative of InverseXRegularized |
InverseXRegularized | Test problem for function that replaces 1/x around the origin by a twice continuously differentiable function |
IsMonotonic | Tests the correct implementation of the function isMonotonic |
Polynomial | |
PowerLinearized | Test problem for function that linearizes y=x^n below some threshold |
QuinticHermite | Example model using quintic Hermite spline |
RegNonZeroPower | |
RegNonZeroPowerDerivativeCheck | |
RegNonZeroPowerDerivative_2_Check | |
RegStep | Example for inlined regStep function |
Round | Example for round function |
SmoothExponentialDerivativeCheck | |
SmoothHeavisideDerivatives | Test model for the derivatives of the smoothHeavisidefunction |
SmoothInterpolation | Test problem for cubic hermite splines that takes a vector of values as an argument |
SpliceFunction | |
SpliceFunctionDerivativeCheck | |
TrapezoidalIntegration | Tests the correct implementation of the function trapezoidalIntegration |
Buildings.Utilities.Math.Functions.Examples.BesselJ0
Test case for Bessel function J0
Information
This example demonstrates the use of the function for Bessel functions of the first kind of order 0, J0.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
Buildings.Utilities.Math.Functions.Examples.BesselJ1
Test case for Bessel function J1
Information
This example demonstrates the use of the function for Bessel functions of the first kind of order 1, J1.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
Buildings.Utilities.Math.Functions.Examples.BesselY0
Test case for Bessel function Y0
Information
This example demonstrates the use of the function for Bessel functions of the second kind of order 0, Y0.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
Buildings.Utilities.Math.Functions.Examples.BesselY1
Test case for Bessel function Y1
Information
This example demonstrates the use of the function for Bessel functions of the second kind of order 1, Y1.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
Buildings.Utilities.Math.Functions.Examples.Binomial
Test case for evaluation of binomial coefficients
Information
This example demonstrates the use of the function for the evaluation of the binomial coefficient "n choose k".
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
Buildings.Utilities.Math.Functions.Examples.CubicHermite
Test problem for cubic hermite splines
Information
This example demonstrates the use of the function for cubic hermite interpolation and linear extrapolation. The example use interpolation with two different settings: One settings produces a monotone cubic hermite, whereas the other setting does not enforce monotonicity. The resulting plot should look as shown below, where for better visibility, the support points have been marked with black dots. Notice that the red curve is monotone increasing.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | xd[:] | {-1,1,5,6} | Support points |
Real | yd[size(xd, 1)] | {-1,1,2,10} | Support points |
Real | d[size(xd, 1)] | Derivatives at the support points | |
Real | dMonotone[size(xd, 1)] | Derivatives at the support points | |
Boolean | ensureMonotonicity | true |
Modelica definition
Buildings.Utilities.Math.Functions.Examples.ExponentialIntegralE1
Test case for the exponential integral, E1
Information
This example demonstrates the use of the function for the exponential integral, E1.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
Buildings.Utilities.Math.Functions.Examples.Factorial
Test case for evaluation of factorials
Information
This example demonstrates the use of the function for the evaluation of factorials.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
Buildings.Utilities.Math.Functions.Examples.FallingFactorial
Test case for evaluation of falling factorials
Information
This example demonstrates the use of the function for the evaluation of falling factorials.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
Buildings.Utilities.Math.Functions.Examples.InverseXDerivativeCheck
Model that checks the correct implementation of the 1st order derivative of InverseXRegularized
Information
This model validates the implementation of Buildings.Utilities.Math.Functions.inverseXRegularized and its first order derivative Buildings.Utilities.Math.Functions.BaseClasses.der_smoothTransition. If the derivative implementation is wrong, the simulation will stop with an error.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | delta | 0.7 | Smoothing coefficient |
Modelica definition
Buildings.Utilities.Math.Functions.Examples.InverseXDerivative_2_Check
Model that checks the correct implementation of the 2nd order derivative of InverseXRegularized
Information
This model validates the implementation of Buildings.Utilities.Math.Functions.inverseXRegularized and its second order derivative Buildings.Utilities.Math.Functions.BaseClasses.der_2_smoothTransition. If the derivative implementation is wrong, the simulation will stop with an error.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | delta | 0.7 | Smoothing coefficient |
Modelica definition
Buildings.Utilities.Math.Functions.Examples.InverseXRegularized
Test problem for function that replaces 1/x around the origin by a twice continuously differentiable function
Information
This example tests the implementation of Buildings.Utilities.Math.Functions.inverseXRegularized.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | delta | 0.5 | Small value for approximation |
Modelica definition
Buildings.Utilities.Math.Functions.Examples.IsMonotonic
Tests the correct implementation of the function isMonotonic
Information
This example tests the correct implementation of the function Buildings.Utilities.Math.Functions.isMonotonic. If the function is implemented incorrect, the example will stop with an error.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
Buildings.Utilities.Math.Functions.Examples.Polynomial
Information
This example verifies the correct implementation of Buildings.Utilities.Math.Functions.polynomial.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
Buildings.Utilities.Math.Functions.Examples.PowerLinearized
Test problem for function that linearizes y=x^n below some threshold
Information
This example tests the implementation of Buildings.Utilities.Math.Functions.powerLinearized.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
Buildings.Utilities.Math.Functions.Examples.QuinticHermite
Example model using quintic Hermite spline
Information
Demonstration of the use of a quintic Hermite spline interpolation function.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | a | 0.5 | Exponential argument coefficient |
Real | x1 | 1 | Lower abscissa value |
Real | x2 | 2.6 | Upper abscissa value |
Real | y1 | -x1 | Lower ordinate value |
Real | y1d | -1 | Lower derivative |
Real | y2d | a*exp(a*x2) | Upper derivative |
Real | y1dd | 0 | Lower second derivative |
Real | y2dd | a^2*exp(a*x2) | Upper second derivative |
Modelica definition
Buildings.Utilities.Math.Functions.Examples.RegNonZeroPower
Information
This example tests the implementation of Buildings.Utilities.Math.Functions.regNonZeroPower.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
Buildings.Utilities.Math.Functions.Examples.RegNonZeroPowerDerivativeCheck
Information
This example checks whether the function derivative is implemented correctly. If the derivative implementation is not correct, the model will stop with an assert statement.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | n | 0.33 | Exponent |
Real | delta | 0.1 | Abscissa value where transition occurs |
Modelica definition
Buildings.Utilities.Math.Functions.Examples.RegNonZeroPowerDerivative_2_Check
Information
This example checks whether the function derivative is implemented correctly. If the derivative implementation is not correct, the model will stop with an assert statement.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | n | 0.33 | Exponent |
Real | delta | 0.7 | Smoothing coefficient |
Modelica definition
Buildings.Utilities.Math.Functions.Examples.RegStep
Example for inlined regStep function
Information
This example tests the implementation of Buildings.Utilities.Math.Functions.regStep.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
Buildings.Utilities.Math.Functions.Examples.Round
Example for round function
Information
This example tests the implementation of Buildings.Utilities.Math.Functions.round for different values of n. Arguments and return values are scale to simplify the show that the scaling for the rounding is implemented correctly.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
Buildings.Utilities.Math.Functions.Examples.SmoothExponentialDerivativeCheck
Information
This example checks whether the function derivative is implemented correctly. If the derivative implementation is not correct, the model will stop with an assert statement.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | delta | 0.5 | Smoothing area |
Modelica definition
Buildings.Utilities.Math.Functions.Examples.SmoothHeavisideDerivatives
Test model for the derivatives of the smoothHeavisidefunction
Information
This model tests the first and second derivative of the twice Lipschitz continuously differentiable function Buildings.Utilities.Math.Functions.smoothHeaviside.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
Buildings.Utilities.Math.Functions.Examples.SmoothInterpolation
Test problem for cubic hermite splines that takes a vector of values as an argument
Information
This example demonstrates the use of the function for cubic hermite interpolation and linear extrapolation. The example use interpolation with two different settings: One settings produces a monotone cubic hermite, whereas the other setting does not enforce monotonicity. The resulting plot should look as shown below, where for better visibility, the support points have been marked with black dots. Notice that the red curve is monotone increasing.
This example also tests the function for the situation where only 2 or only 1 support points are provided. In the first case, the result will be linear function and in the second case, a constant value.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | xSup[:] | {-1,1,5,6} | Support points |
Real | ySup[size(xSup, 1)] | {-1,1,2,10} | Support points |
Modelica definition
Buildings.Utilities.Math.Functions.Examples.SpliceFunction
Information
This example checks whether the function derivative is implemented correctly. If the derivative implementation is not correct, the model will stop with an assert statement.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Modelica definition
Buildings.Utilities.Math.Functions.Examples.SpliceFunctionDerivativeCheck
Information
This example checks whether the function derivative is implemented correctly. If the derivative implementation is not correct, the model will stop with an assert statement.
Extends from Modelica.Icons.Example (Icon for runnable examples).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | delta | 0.2 | Smoothing area |
Modelica definition
Buildings.Utilities.Math.Functions.Examples.TrapezoidalIntegration
Tests the correct implementation of the function trapezoidalIntegration
Information
Tests the correct implementation of function Buildings.Utilities.Math.Functions.trapezoidalIntegration.
Integrands y1[7]={72, 70, 64, 54, 40, 22, 0} are the function values of y = -2*x^2-72 for x = {0,1,2,3,4,5,6}. The trapezoidal integration over the 7 integrand points should give a result of 286.
Extends from Modelica.Icons.Example (Icon for runnable examples).