Buildings.Utilities.Math

Library with functions such as for smoothing

Package Content

NameDescription
Buildings.Utilities.Math.BaseClasses BaseClasses Library with base classes for mathematical functions
Buildings.Utilities.Math.Examples Examples Collection of models that illustrate model use and test models
Buildings.Utilities.Math.regNonZeroPower regNonZeroPower Power function, regularized near zero, but nonzero value for x=0
Buildings.Utilities.Math.spliceFunction spliceFunction  


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

This function replaces y=|x|^n in the interval -delta...+delta by a 4-th order polynomial that has the same function value, first and second derivative at x=+/-delta.

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 -delta...+delta may be interpreted as the region where heat conduction dominates convection in the boundary layer.

See the package Examples for the graph.


Inputs

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

Outputs

TypeNameDescription
RealyFunction value

Modelica definition

function regNonZeroPower 
  "Power function, regularized near zero, but nonzero value for x=0" 
  annotation(derivative=BaseClasses.der_regNonZeroPower);  
  
 input Real x "Abscissa value";
 input Real n "Exponent";
 input Real delta = 0.01 "Abscissa value where transition occurs";
 output Real y "Function value";
protected 
  Real a1;
  Real a3;
  Real a5;
  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
   y := abs(x)^n;
  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;
   a5 := (y_d - delta2 * (a3 + delta2 * a1));
   y := a5 + x2 * (a3 + x2 * a1);
   assert(a5>0, "delta is too small for this exponent n");
  end if;
end regNonZeroPower;

Buildings.Utilities.Math.spliceFunction

Information


Function to provide a once continuously differentialbe transition between to arguments.

The function is adapted from Modelica.Media.Air.MoistAir.Utilities.spliceFunction and provided here for easier accessability to model developers.


Inputs

TypeNameDefaultDescription
Realpos Argument of x > 0
Realneg Argument of x < 0
Realx Independent value
Realdeltax1Width of transition interval

Outputs

TypeNameDescription
RealoutSmoothed value

Modelica definition

function spliceFunction 
  annotation(derivative=BaseClasses.der_spliceFunction);  
    input Real pos "Argument of x > 0";
    input Real neg "Argument of x < 0";
    input Real x "Independent value";
    input Real deltax=1 "Width of transition interval";
    output Real out "Smoothed value";
protected 
    Real scaledX;
    Real scaledX1;
    Real y;
algorithm 
    scaledX1 := x/deltax;
    scaledX := scaledX1*Modelica.Math.asin(1);
    if scaledX1 <= -0.999999999 then
      y := 0;
    elseif scaledX1 >= 0.999999999 then
      y := 1;
    else
      y := (Modelica.Math.tanh(Modelica.Math.tan(scaledX)) + 1)/2;
    end if;
    out := pos*y + (1 - y)*neg;
end spliceFunction;

HTML-documentation generated by Dymola Tue May 27 12:39:50 2008.