.Modelica.Fluid.Utilities.regRoot2

Information

Approximates the function

y = if x ≥ 0 then sqrt(k1*x) else -sqrt(k2*abs(x)), with k1, k2 ≥ 0

in such a way that within the region -x_small ≤ x ≤ x_small, the function is described by two polynomials of third order (one in the region -x_small .. 0 and one within the region 0 .. x_small) such that

Typical screenshots for two different configurations are shown below. The first one with k1=k2=1:

regRoot2_a.png

and the second one with k1=1 and k2=3:

regRoot2_b.png

The (smooth) derivative of the function with k1=1, k2=3 is shown in the next figure:

regRoot2_c.png

Literature

Fritsch F.N. and Carlson R.E. (1980):
Monotone piecewise cubic interpolation. SIAM J. Numerc. Anal., Vol. 17, No. 2, April 1980, pp. 238-246

Interface

function regRoot2
  extends Modelica.Icons.Function;
  input Real x "Abscissa value";
  input Real x_small(min = 0) = 0.01 "Approximation of function for |x| <= x_small";
  input Real k1(min = 0) = 1 "y = if x>=0 then sqrt(k1*x) else -sqrt(k2*|x|)";
  input Real k2(min = 0) = 1 "y = if x>=0 then sqrt(k1*x) else -sqrt(k2*|x|)";
  input Boolean use_yd0 = false "= true, if yd0 shall be used";
  input Real yd0(min = 0) = 1 "Desired derivative at x=0: dy/dx = yd0";
  output Real y "Ordinate value";
end regRoot2;

Revisions


Generated at 2020-06-05T21:39:08Z by OpenModelica 1.16.0~dev-442-g2e5bc9f