Buildings.Utilities.Math
Library with functions such as for smoothing
Information
This package contains blocks and functions for commonly used mathematical operations. The classes in this package augment the classes Modelica.Blocks.
Extends from Modelica.Icons.Package (Icon for standard packages).
Package Content
Name | Description |
---|---|
Average | Average of a vector |
Bicubic | Bicubic function |
Biquadratic | Biquadratic function |
BooleanReplicator | Boolean signal replicator |
IntegerReplicator | Integer signal replicator |
IntegratorWithReset | Output the integral of the input signal |
InverseXRegularized | Function that approximates 1/x by a twice continuously differentiable function |
Max | Maximum element of a vector |
Min | Minimum element of a vector |
Polynominal | Polynominal function |
PowerLinearized | Power function that is linearized below a user-defined threshold |
QuadraticLinear | Function that is quadratic in first argument and linear in second argument |
RegNonZeroPower | Power function, regularized near zero, but nonzero value for x=0 |
SmoothExponential | Once continuously differentiable approximation to exp(-|x|) in interval |x| < delta |
SmoothHeaviside | Once continuously differentiable approximation to the Heaviside function |
SmoothLimit | Once continuously differentiable approximation to the limit function |
SmoothMax | Once continuously differentiable approximation to the maximum function |
SmoothMin | Once continuously differentiable approximation to the minimum function |
Splice | Block for splice function opertation |
TrapezoidalIntegration | Integration using the trapezoidal rule |
Functions | Package with mathematical functions |
Examples | Collection of models that illustrate model use and test models |
Buildings.Utilities.Math.Average
Average of a vector
Information
This block outputs the average of the vector.
Extends from Modelica.Blocks.Interfaces.MISO (Multiple Input Single Output continuous control block).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Integer | nin | 1 | Number of inputs |
Connectors
Type | Name | Description |
---|---|---|
input RealInput | u[nin] | Connector of Real input signals |
output RealOutput | y | Connector of Real output signal |
Modelica definition
Buildings.Utilities.Math.Bicubic
Bicubic function
Information
This block computes
y = a1 + a2 x1 + a3 x12 + a4 x2 + a5 x22 + a6 x1 x2 + a7 x1^3 + a8 x2^3 + a9 x12 x2 + a10 x1 x22
Extends from Modelica.Blocks.Interfaces.SI2SO (2 Single Input / 1 Single Output continuous control block).
Connectors
Type | Name | Description |
---|---|---|
input RealInput | u1 | Connector of Real input signal 1 |
input RealInput | u2 | Connector of Real input signal 2 |
output RealOutput | y | Connector of Real output signal |
Modelica definition
Buildings.Utilities.Math.Biquadratic
Biquadratic function
Information
This block computes
y = a1 + a2 x1 + a3 x12 + a4 x2 + a5 x22 + a6 x1 x2
Extends from Modelica.Blocks.Interfaces.SI2SO (2 Single Input / 1 Single Output continuous control block).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | a[6] | Coefficients |
Connectors
Type | Name | Description |
---|---|---|
input RealInput | u1 | Connector of Real input signal 1 |
input RealInput | u2 | Connector of Real input signal 2 |
output RealOutput | y | Connector of Real output signal |
Modelica definition
Buildings.Utilities.Math.BooleanReplicator
Boolean signal replicator
Information
This block replicates the boolean input signal to an array of nout
identical output signals.
Extends from Modelica.Blocks.Icons.BooleanBlock (Basic graphical layout of Boolean block).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Integer | nout | 1 | Number of outputs |
Connectors
Type | Name | Description |
---|---|---|
input BooleanInput | u | Connector of boolean input signal |
output BooleanOutput | y[nout] | Connector of boolean output signals |
Modelica definition
Buildings.Utilities.Math.IntegerReplicator
Integer signal replicator
Information
This block replicates the integer input signal to an array of nout
identical output signals.
Extends from Modelica.Blocks.Icons.IntegerBlock (Basic graphical layout of Integer block).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Integer | nout | 1 | Number of outputs |
Connectors
Type | Name | Description |
---|---|---|
input IntegerInput | u | Connector of integer input signal |
output IntegerOutput | y[nout] | Connector of integer output signals |
Modelica definition
Buildings.Utilities.Math.IntegratorWithReset
Output the integral of the input signal
Information
This model is similar to
Modelica.Blocks.Continuous.Integrator
except that it optionally allows to reset the output y
of the integrator.
The output of the integrator can be reset as follows:
-
If
reset = Buildings.Types.Reset.Disabled
, which is the default, then the integrator is never reset. -
If
reset = Buildings.Types.Reset.Parameter
, then a boolean input signaltrigger
is enabled. Whenever the value of this input changes fromfalse
totrue
, the integrator is reset by settingy
to the value of the parametery_reset
. -
If
reset = Buildings.Types.Reset.Input
, then a boolean input signaltrigger
is enabled. Whenever the value of this input changes fromfalse
totrue
, the integrator is reset by settingy
to the value of the input signaly_reset_in
.
See Buildings.Utilities.Math.Examples.IntegratorWithReset for an example.
Implementation
To adjust the icon layer, the code of Modelica.Blocks.Continuous.Integrator has been copied into this model rather than extended.
Extends from Modelica.Blocks.Interfaces.SISO (Single Input Single Output continuous control block).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | k | 1 | Integrator gain [1] |
Reset | reset | Buildings.Types.Reset.Disabled | Type of integrator reset |
Initialization | |||
RealOutput | y.start | y_start | Connector of Real output signal |
Init | initType | Modelica.Blocks.Types.Init.I... | Type of initialization (1: no init, 2: steady state, 3,4: initial output) |
Real | y_start | 0 | Initial or guess value of output (= state) |
Integrator reset | |||
Real | y_reset | 0 | Value to which integrator is reset, used if reset = Buildings.Types.Reset.Parameter |
Connectors
Type | Name | Description |
---|---|---|
input RealInput | u | Connector of Real input signal |
input RealInput | y_reset_in | Input signal for state to which integrator is reset, enabled if reset = Buildings.Types.Reset.Input |
input BooleanInput | trigger | Resets the integrator output when trigger becomes true |
Modelica definition
Buildings.Utilities.Math.InverseXRegularized
Function that approximates 1/x by a twice continuously differentiable function
Information
Function that approximates y=1 ⁄ x inside the interval -δ ≤ x ≤ δ. The approximation is twice continuously differentiable with a bounded derivative on the whole real line.
See the package Examples
for the graph.
Extends from Modelica.Blocks.Interfaces.SISO (Single Input Single Output continuous control block).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | delta | Abscissa value below which approximation occurs |
Connectors
Type | Name | Description |
---|---|---|
input RealInput | u | Connector of Real input signal |
output RealOutput | y | Connector of Real output signal |
Modelica definition
Buildings.Utilities.Math.Max
Maximum element of a vector
Information
Outputs the maximum of the vector.
Extends from Modelica.Blocks.Interfaces.MISO (Multiple Input Single Output continuous control block).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Integer | nin | 1 | Number of inputs |
Connectors
Type | Name | Description |
---|---|---|
input RealInput | u[nin] | Connector of Real input signals |
output RealOutput | y | Connector of Real output signal |
Modelica definition
Buildings.Utilities.Math.Min
Minimum element of a vector
Information
Outputs the minimum of the vector.
Extends from Modelica.Blocks.Interfaces.MISO (Multiple Input Single Output continuous control block).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Integer | nin | 1 | Number of inputs |
Connectors
Type | Name | Description |
---|---|---|
input RealInput | u[nin] | Connector of Real input signals |
output RealOutput | y | Connector of Real output signal |
Modelica definition
Buildings.Utilities.Math.Polynominal
Polynominal function
Information
This block computes a polynomial of arbitrary order. The polynomial has the form
y = a1 + a2 x + a3 x2 + ...
Extends from Modelica.Blocks.Interfaces.SISO (Single Input Single Output continuous control block).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | a[:] | Coefficients |
Connectors
Type | Name | Description |
---|---|---|
input RealInput | u | Connector of Real input signal |
output RealOutput | y | Connector of Real output signal |
Modelica definition
Buildings.Utilities.Math.PowerLinearized
Power function that is linearized below a user-defined threshold
Information
Function that approximates y=xn where 0 < n so that- the function is defined and monotone increasing for all x.
- dy/dx is bounded and continuous everywhere (for n < 1).
For x < x0, this function replaces y=xn by a linear function that is continuously differentiable everywhere.
A typical use of this function is to replace T = T4(1/4) in a radiation balance to ensure that the function is defined everywhere. This can help solving the initialization problem when a solver may be far from a solution and hence T4 < 0.
See the package Examples
for the graph.
Extends from Modelica.Blocks.Interfaces.SISO (Single Input Single Output continuous control block).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | n | Exponent | |
Real | x0 | Abscissa value below which linearization occurs |
Connectors
Type | Name | Description |
---|---|---|
input RealInput | u | Connector of Real input signal |
output RealOutput | y | Connector of Real output signal |
Modelica definition
Buildings.Utilities.Math.QuadraticLinear
Function that is quadratic in first argument and linear in second argument
Information
Block for function quadraticLinear, which computes
y = a1 + a2 x1 + a3 x12 + (a4 + a5 x1 + a6 x12) x2
Extends from Modelica.Blocks.Interfaces.SI2SO (2 Single Input / 1 Single Output continuous control block).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | a[6] | Coefficients |
Connectors
Type | Name | Description |
---|---|---|
input RealInput | u1 | Connector of Real input signal 1 |
input RealInput | u2 | Connector of Real input signal 2 |
output RealOutput | y | Connector of Real output signal |
Modelica definition
Buildings.Utilities.Math.RegNonZeroPower
Power function, regularized near zero, but nonzero value for x=0
Information
Function that approximates y=|x|n where n > 0 so that- y(0) is not equal to zero.
- dy/dx is bounded and continuous everywhere.
This function replaces y=|x|n in the interval -δ...+δ by a 4-th order polynomial that has the same function value and the first and second derivative at x=± δ.
A typical use of this function is to replace the function for the convective heat transfer coefficient for forced or free convection that is of the form h=c |dT|n for some constant c and exponent 0 ≤ n ≤ 1. By using this function, the original function that has an infinite derivative near zero and that takes on zero at the origin is replaced by a function with a bounded derivative and a non-zero value at the origin. Physically, the region -δ...+δ may be interpreted as the region where heat conduction dominates convection in the boundary layer.
See the packageExamples
for the graph.
Extends from Modelica.Blocks.Interfaces.SISO (Single Input Single Output continuous control block).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | n | Exponent | |
Real | delta | 0.01 | Abscissa value where transition occurs |
Connectors
Type | Name | Description |
---|---|---|
input RealInput | u | Connector of Real input signal |
output RealOutput | y | Connector of Real output signal |
Modelica definition
Buildings.Utilities.Math.SmoothExponential
Once continuously differentiable approximation to exp(-|x|) in interval |x| < delta
Information
Function to provide a once continuously differentiable approximation to exp(- |x| ) in the interval |x| for some positive δ
Extends from Modelica.Blocks.Interfaces.SISO (Single Input Single Output continuous control block).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | delta | Transition point where approximation occurs |
Connectors
Type | Name | Description |
---|---|---|
input RealInput | u | Connector of Real input signal |
output RealOutput | y | Connector of Real output signal |
Modelica definition
Buildings.Utilities.Math.SmoothHeaviside
Once continuously differentiable approximation to the Heaviside function
Information
Once Lipschitz continuously differentiable approximation to the Heaviside(.,.) function. See Example Buildings.Utilities.Math.Examples.SmoothHeaviside.
Extends from Modelica.Blocks.Interfaces.SISO (Single Input Single Output continuous control block).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | delta | Width of transition interval |
Connectors
Type | Name | Description |
---|---|---|
input RealInput | u | Connector of Real input signal |
output RealOutput | y | Connector of Real output signal |
Modelica definition
Buildings.Utilities.Math.SmoothLimit
Once continuously differentiable approximation to the limit function
Information
Once continuously differentiable approximation to the limit(.,.) function. The output is bounded to be in [lower, upper].
Note that the limit need not be respected, such as illustrated in Buildings.Utilities.Math.Examples.SmoothMin.
Extends from Modelica.Blocks.Interfaces.SISO (Single Input Single Output continuous control block).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | deltaX | Width of transition interval | |
Real | upper | Upper limit | |
Real | lower | Lower limit |
Connectors
Type | Name | Description |
---|---|---|
input RealInput | u | Connector of Real input signal |
output RealOutput | y | Connector of Real output signal |
Modelica definition
Buildings.Utilities.Math.SmoothMax
Once continuously differentiable approximation to the maximum function
Information
Once continuously differentiable approximation to the max(.,.) function.
Note that the maximum need not be respected, such as illustrated in Buildings.Utilities.Math.Examples.SmoothMin.
Extends from Modelica.Blocks.Interfaces.SI2SO (2 Single Input / 1 Single Output continuous control block).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | deltaX | Width of transition interval |
Connectors
Type | Name | Description |
---|---|---|
input RealInput | u1 | Connector of Real input signal 1 |
input RealInput | u2 | Connector of Real input signal 2 |
output RealOutput | y | Connector of Real output signal |
Modelica definition
Buildings.Utilities.Math.SmoothMin
Once continuously differentiable approximation to the minimum function
Information
Once continuously differentiable approximation to the min(.,.) function.
Note that the minimum need not be respected, such as illustrated in Buildings.Utilities.Math.Examples.SmoothMin.
Extends from Modelica.Blocks.Interfaces.SI2SO (2 Single Input / 1 Single Output continuous control block).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | deltaX | Width of transition interval |
Connectors
Type | Name | Description |
---|---|---|
input RealInput | u1 | Connector of Real input signal 1 |
input RealInput | u2 | Connector of Real input signal 2 |
output RealOutput | y | Connector of Real output signal |
Modelica definition
Buildings.Utilities.Math.Splice
Block for splice function opertation
Information
This block implements Buildings.Utilities.Math.Functions.spliceFunction, which provides a continuously differentiable transition between two arguments.
Extends from Modelica.Blocks.Icons.Block (Basic graphical layout of input/output block).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Real | deltax | Half width of transition interval |
Connectors
Type | Name | Description |
---|---|---|
input RealInput | x | Independent value |
input RealInput | u1 | Argument of u > 0 (pos) |
input RealInput | u2 | Argument of u < 0 (neg) |
output RealOutput | y | Smoothed value |
Modelica definition
Buildings.Utilities.Math.TrapezoidalIntegration
Integration using the trapezoidal rule
Information
This function computes a definite integral using the trapezoidal rule.
Extends from Modelica.Blocks.Interfaces.MISO (Multiple Input Single Output continuous control block).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Integer | nin | 1 | Number of inputs |
Integer | N | Number of integrand points | |
Real | deltaX | Width of interval for Trapezoidal integration |
Connectors
Type | Name | Description |
---|---|---|
input RealInput | u[nin] | Connector of Real input signals |
output RealOutput | y | Connector of Real output signal |