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 |
---|---|
CubicHermite | Test problem for cubic hermite splines |
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 |
RegNonZeroPower | |
RegNonZeroPowerDerivativeCheck | |
RegNonZeroPowerDerivative_2_Check | |
RegStep | Example for inlined regStep function |
SmoothExponentialDerivativeCheck | |
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.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.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.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.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.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).