Buildings.Utilities.Math.BaseClasses

Library with base classes for mathematical functions

Package Content

NameDescription
Buildings.Utilities.Math.BaseClasses.der_2_regNonZeroPower der_2_regNonZeroPower Power function, regularized near zero, but nonzero value for x=0
Buildings.Utilities.Math.BaseClasses.der_regNonZeroPower der_regNonZeroPower Power function, regularized near zero, but nonzero value for x=0
Buildings.Utilities.Math.BaseClasses.der_spliceFunction der_spliceFunction  


Buildings.Utilities.Math.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_n;
// input Real der_delta;
 input Real der_2_x;
// input Real der_2_n;
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.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;
// input Real der_n;
// input Real der_delta;
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.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 Thu Feb 19 16:53:25 2009.