@@ -691,7 +691,7 @@ for a smooth transition from y1 to y2.
691691 c := 0.1 * Delta0;
692692 end if ;
693693 theta0 := (y0d* mu + y1d* eta)/ h0;
694- if abs (theta0 - c) < 1e-6 then
694+ if abs (theta0 - c) < 1e-6 * abs (c) then
695695 // Slightly reduce c in order to avoid ill-posed problem
696696 c := (1 - 1e-6 )* theta0;
697697 end if ;
@@ -700,22 +700,18 @@ for a smooth transition from y1 to y2.
700700 eta_tilde := rho* eta;
701701 xi1 := x0 + mu_tilde;
702702 xi2 := x1 - eta_tilde;
703- if xi1 < x0 or xi2> x1 then
704- // The limits don't make sense, just use linear interpolation
705- y := (y1- y0)* (x- x0)/ (x1- x0) + y0;
703+
704+ a1 := (y0d - c)/ max (mu_tilde^ 2 , 100 * Modelica.Constants.eps);
705+ a2 := (y1d - c)/ max (eta_tilde^ 2 , 100 * Modelica.Constants.eps);
706+ const12 := y0 - a1/ 3 * (x0 - xi1)^ 3 - c* x0;
707+ const3 := y1 - a2/ 3 * (x1 - xi2)^ 3 - c* x1;
708+ // Do actual interpolation
709+ if (x < xi1) then
710+ y := a1/ 3 * (x - xi1)^ 3 + c* x + const12;
711+ elseif (x < xi2) then
712+ y := c* x + const12;
706713 else
707- a1 := (y0d - c)/ max (mu_tilde^ 2 , 100 * Modelica.Constants.eps);
708- a2 := (y1d - c)/ max (eta_tilde^ 2 , 100 * Modelica.Constants.eps);
709- const12 := y0 - a1/ 3 * (x0 - xi1)^ 3 - c* x0;
710- const3 := y1 - a2/ 3 * (x1 - xi2)^ 3 - c* x1;
711- // Do actual interpolation
712- if (x < xi1) then
713- y := a1/ 3 * (x - xi1)^ 3 + c* x + const12;
714- elseif (x < xi2) then
715- y := c* x + const12;
716- else
717- y := a2/ 3 * (x - xi2)^ 3 + c* x + const3;
718- end if ;
714+ y := a2/ 3 * (x - xi2)^ 3 + c* x + const3;
719715 end if ;
720716 else
721717 // Cubic S0 is monotonic, use it as is
0 commit comments