Buildings.Utilities.Math.Functions.BaseClasses

Library with base classes for mathematical functions

Information

Extends from Modelica.Fluid.Icons.BaseClassLibrary (Icon for library).

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  


Buildings.Utilities.Math.Functions.BaseClasses.der_2_regNonZeroPower

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

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

encapsulated 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 * x^2 + ...
This function computes new coefficients
   b1 = a2, b2 = 2*a3, ...
and then calls recursively Buildings.Utilities.Math.polynomial

Inputs

TypeNameDefaultDescription
Reala[:]  
Realx  
Realdx  

Outputs

TypeNameDescription
Realy 

Modelica definition

function der_polynomial "Derivative for polynomial function"

    input Real a[:];
    input Real x;
    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

Inputs

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

Outputs

TypeNameDescription
Realder_yFunction value

Modelica definition

encapsulated function der_regNonZeroPower 
  "Power function, regularized near zero, but nonzero value for x=0"
  annotation(derivative=BaseClasses.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

Inputs

TypeNameDefaultDescription
Realpos  
Realneg  
Realx  
Realdeltax1 
Realdpos  
Realdneg  
Realdx  
Realddeltax0 

Outputs

TypeNameDescription
Realout 

Modelica definition

function der_spliceFunction
    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;

HTML-documentation generated by Dymola Fri Jul 30 18:07:11 2010.