LBL logo

Buildings.Utilities.Math.Functions.BaseClasses

Package with base classes for Buildings.Utilities.Math.Functions

Information

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).

Package Content

NameDescription
Buildings.Utilities.Math.Functions.BaseClasses.der_2_regNonZeroPower der_2_regNonZeroPower Power function, regularized near zero, but nonzero value for x=0
Buildings.Utilities.Math.Functions.BaseClasses.der_polynomial der_polynomial Derivative for polynomial function
Buildings.Utilities.Math.Functions.BaseClasses.der_regNonZeroPower der_regNonZeroPower Power function, regularized near zero, but nonzero value for x=0
Buildings.Utilities.Math.Functions.BaseClasses.der_spliceFunction der_spliceFunction Derivative of splice function


Buildings.Utilities.Math.Functions.BaseClasses.der_2_regNonZeroPower

Power function, regularized near zero, but nonzero value for x=0

Information

Implementation of the second derivative of the function Buildings.Utilities.Math.Functions.regNonZeroPower.

Inputs

TypeNameDefaultDescription
Realx Abscissa value
Realn Exponent
Realdelta0.01Abscissa value where transition occurs
Realder_x  
Realder_2_x  

Outputs

TypeNameDescription
Realder_2_yFunction value

Modelica definition

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;

Buildings.Utilities.Math.Functions.BaseClasses.der_polynomial

Derivative for polynomial function

Information

This function computes the first derivative of a polynomial of arbitrary order. The original polynomial has the form

y = a1 + a2 x + a3 x2 + ...

This function computes new coefficients

b1 = a2, b2 = 2 a3, ...

and then calls recursively Buildings.Utilities.Math.polynomial

Inputs

TypeNameDefaultDescription
Realx  
Reala[:]  
Realdx  

Outputs

TypeNameDescription
Realy 

Modelica definition

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;

Buildings.Utilities.Math.Functions.BaseClasses.der_regNonZeroPower

Power function, regularized near zero, but nonzero value for x=0

Information

Implementation of the first derivative of the function Buildings.Utilities.Math.Functions.regNonZeroPower.

Inputs

TypeNameDefaultDescription
Realx Abscissa value
Realn Exponent
Realdelta0.01Abscissa value where transition occurs
Realder_x  

Outputs

TypeNameDescription
Realder_yFunction value

Modelica definition

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;

Buildings.Utilities.Math.Functions.BaseClasses.der_spliceFunction

Derivative of splice function

Information

Implementation of the first derivative of the function Buildings.Utilities.Math.Functions.spliceFunction.

Inputs

TypeNameDefaultDescription
Realpos  
Realneg  
Realx  
Realdeltax1 
Realdpos  
Realdneg  
Realdx  
Realddeltax0 

Outputs

TypeNameDescription
Realout 

Modelica definition

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;
    constant Real asin1 = Modelica.Math.asin(1);
algorithm 
    scaledX1 := x/deltax;
    if scaledX1 <= -0.99999999999 then
      out := dneg;
    elseif scaledX1 >= 0.9999999999 then
      out := dpos;
    else
      scaledX := scaledX1*asin1;
      dscaledX1 := (dx - scaledX1*ddeltax)/deltax;
      y := (Modelica.Math.tanh(Modelica.Math.tan(scaledX)) + 1)/2;
      out := dpos*y + (1 - y)*dneg;
      out := out + (pos - neg)*dscaledX1*asin1/2/(
        Modelica.Math.cosh(Modelica.Math.tan(scaledX))*Modelica.Math.cos(
        scaledX))^2;
    end if;

end der_spliceFunction;

Automatically generated Wed May 15 11:58:31 2013.