Skip to content

Commit

Permalink
spliceFunction_der check limits
Browse files Browse the repository at this point in the history
there are two if-conditions that used a different value:
1 versus 0.9999999999
this PR makes sure the identical limit is used
  • Loading branch information
thorade committed Sep 27, 2022
1 parent f325ed3 commit 1b0d450
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Modelica/Media/Air/MoistAir.mo
Expand Up @@ -1429,15 +1429,16 @@ Specific entropy of moist air is computed from pressure, temperature and composi
input Real deltax=1 "Region around x with spline interpolation";
output Real out;
protected
constant Real lim = 0.9999999999;
Real scaledX1 "x scaled to -1 ... 1 interval";
Real scaledXp "x scaled to -pi/2 ... pi/2 interval";
Real scaledXt "x scaled to -inf ... inf interval";
Real y;
algorithm
scaledX1 := x/deltax;
if scaledX1 <= -0.999999999 then
if scaledX1 <= -lim then
y := 0.0;
elseif scaledX1 >= 0.999999999 then
elseif scaledX1 >= lim then
y := 1.0;
else
scaledXp := scaledX1*0.5*Modelica.Constants.pi;
Expand All @@ -1461,16 +1462,17 @@ Specific entropy of moist air is computed from pressure, temperature and composi
input Real ddeltax=0;
output Real out;
protected
constant Real lim = 0.9999999999;
Real scaledX1 "x scaled to -1 ... 1 interval";
Real scaledXp "x scaled to -pi/2 ... pi/2 interval";
Real scaledXt "x scaled to -inf ... inf interval";
Real dscaledX1;
Real y;
algorithm
scaledX1 := x/deltax;
if scaledX1 <= -0.9999999999 then
if scaledX1 <= -lim then
y := 0.0;
elseif scaledX1 >= 0.9999999999 then
elseif scaledX1 >= lim then
y := 1.0;
else
scaledXp := scaledX1*0.5*Modelica.Constants.pi;
Expand All @@ -1479,7 +1481,7 @@ Specific entropy of moist air is computed from pressure, temperature and composi
end if;
out := dpos*y + (1 - y)*dneg;

if (abs(scaledX1) < 1) then
if (abs(scaledX1) < lim) then
dscaledX1 := (dx - scaledX1*ddeltax)/deltax;
out := out + (pos - neg)*dscaledX1*0.25*Modelica.Constants.pi*(1 - Modelica.Math.tanh(scaledXt)^2)*(scaledXt^2 + 1);
end if;
Expand Down

0 comments on commit 1b0d450

Please sign in to comment.