This package contains base classes that are used to construct the models in Buildings.Utilities.Math.Functions.
Extends from Modelica.Icons.BasesPackage (Icon for packages containing base classes).
Name | Description |
---|---|
der_2_regNonZeroPower | Power function, regularized near zero, but nonzero value for x=0 |
der_polynomial | Derivative for polynomial function |
der_regNonZeroPower | Power function, regularized near zero, but nonzero value for x=0 |
der_spliceFunction | Derivative of splice function |
Implementation of the second derivative of the function Buildings.Utilities.Math.Functions.regNonZeroPower.
Type | Name | Default | Description |
---|---|---|---|
Real | x | Abscissa value | |
Real | n | Exponent | |
Real | delta | 0.01 | Abscissa value where transition occurs |
Real | der_x | ||
Real | der_2_x |
Type | Name | Description |
---|---|---|
Real | der_2_y | Function value |
function der_2_regNonZeroPower "Power function, regularized near zero, but nonzero value for x=0" input Real x "Abscissa value"; input Real n "Exponent"; input Real delta = 0.01 "Abscissa value where transition occurs"; input Real der_x; input Real der_2_x; output Real der_2_y "Function value"; protected Real a1; Real a3; Real delta2; Real x2; Real y_d "=y(delta)"; Real yP_d "=dy(delta)/dx"; Real yPP_d "=d^2y(delta)/dx^2"; algorithm if abs(x) > delta then der_2_y := n*(n-1)*abs(x)^(n-2); else delta2 :=delta*delta; x2 :=x*x; y_d :=delta^n; yP_d :=n*delta^(n - 1); yPP_d :=n*(n - 1)*delta^(n - 2); a1 := -(yP_d/delta - yPP_d)/delta2/8; a3 := (yPP_d - 12 * a1 * delta2)/2; der_2_y := 12*a1*x2+2*a3; end if;end der_2_regNonZeroPower;
y = a1 + a2 x + a3 x2 + ...
This function computes new coefficients
b1 = a2, b2 = 2 a3, ...
and then calls recursively Buildings.Utilities.Math.polynomial
Type | Name | Default | Description |
---|---|---|---|
Real | x | ||
Real | a[:] | ||
Real | dx |
Type | Name | Description |
---|---|---|
Real | y |
function der_polynomial "Derivative for polynomial function" input Real x; input Real a[:]; input Real dx; output Real y; protected parameter Integer n = size(a, 1)-1; Real b[n] "Coefficients of derivative polynomial"; algorithm for i in 1:n loop b[i] :=a[i+1]*i; end for; y := Buildings.Utilities.Math.Functions.polynomial( a=b, x=x);end der_polynomial;
Implementation of the first derivative of the function Buildings.Utilities.Math.Functions.regNonZeroPower.
Type | Name | Default | Description |
---|---|---|---|
Real | x | Abscissa value | |
Real | n | Exponent | |
Real | delta | 0.01 | Abscissa value where transition occurs |
Real | der_x |
Type | Name | Description |
---|---|---|
Real | der_y | Function value |
function der_regNonZeroPower "Power function, regularized near zero, but nonzero value for x=0" annotation(derivative=der_2_regNonZeroPower); input Real x "Abscissa value"; input Real n "Exponent"; input Real delta = 0.01 "Abscissa value where transition occurs"; input Real der_x; output Real der_y "Function value"; protected Real a1; Real a3; Real delta2; Real x2; Real y_d "=y(delta)"; Real yP_d "=dy(delta)/dx"; Real yPP_d "=d^2y(delta)/dx^2"; algorithm if abs(x) > delta then der_y := sign(x)*n*abs(x)^(n-1); else delta2 :=delta*delta; x2 :=x*x; y_d :=delta^n; yP_d :=n*delta^(n - 1); yPP_d :=n*(n - 1)*delta^(n - 2); a1 := -(yP_d/delta - yPP_d)/delta2/8; a3 := (yPP_d - 12 * a1 * delta2)/2; der_y := x * ( 4 * a1 * x * x + 2 * a3); end if;end der_regNonZeroPower;
Implementation of the first derivative of the function Buildings.Utilities.Math.Functions.spliceFunction.
Type | Name | Default | Description |
---|---|---|---|
Real | pos | ||
Real | neg | ||
Real | x | ||
Real | deltax | 1 | |
Real | dpos | ||
Real | dneg | ||
Real | dx | ||
Real | ddeltax | 0 |
Type | Name | Description |
---|---|---|
Real | out |
function der_spliceFunction "Derivative of splice function" input Real pos; input Real neg; input Real x; input Real deltax=1; input Real dpos; input Real dneg; input Real dx; input Real ddeltax=0; output Real out; protected Real scaledX; Real scaledX1; Real dscaledX1; Real y; algorithm scaledX1 := x/deltax; scaledX := scaledX1*Modelica.Math.asin(1); dscaledX1 := (dx - scaledX1*ddeltax)/deltax; if scaledX1 <= -0.99999999999 then y := 0; elseif scaledX1 >= 0.9999999999 then y := 1; else y := (Modelica.Math.tanh(Modelica.Math.tan(scaledX)) + 1)/2; end if; out := dpos*y + (1 - y)*dneg; if (abs(scaledX1) < 1) then out := out + (pos - neg)*dscaledX1*Modelica.Math.asin(1)/2/( Modelica.Math.cosh(Modelica.Math.tan(scaledX))*Modelica.Math.cos( scaledX))^2; end if;end der_spliceFunction;