Skip to content

Commit

Permalink
Consider shiftTime for verbose extrapolation in CombiTimeTable (#4345)
Browse files Browse the repository at this point in the history
* Consider shiftTime for verbose extrapolation

The time table data is relative to the shiftTime parameter, which should also be considered for the verbose extrapolation warning.

* Simplify and fix extrapolation messages
  • Loading branch information
beutlich authored Feb 28, 2024
1 parent af02ffc commit 36e5c00
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
12 changes: 6 additions & 6 deletions Modelica/Blocks/Sources.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1684,13 +1684,13 @@ parameter Real table[:, <strong>2</strong>]=[0, 0; 1, 1; 2, 4];
if verboseExtrapolation and (
extrapolation == Modelica.Blocks.Types.Extrapolation.LastTwoPoints or
extrapolation == Modelica.Blocks.Types.Extrapolation.HoldLastPoint) then
assert(noEvent(time >= t_min), "
Extrapolation warning: Time (=" + String(time) + ") must be greater or equal
than the minimum abscissa value t_min (=" + String(t_min) + ") defined in the table.
assert(noEvent(time >= t_min + shiftTime), "
Extrapolation warning: Time must be greater or equal
than the shifted minimum abscissa value defined in the table.
", level=AssertionLevel.warning);
assert(noEvent(time <= t_max), "
Extrapolation warning: Time (=" + String(time) + ") must be less or equal
than the maximum abscissa value t_max (=" + String(t_max) + ") defined in the table.
assert(noEvent(time <= t_max + shiftTime), "
Extrapolation warning: Time must be less or equal
than the shifted maximum abscissa value defined in the table.
", level=AssertionLevel.warning);
end if;

Expand Down
30 changes: 12 additions & 18 deletions Modelica/Resources/C-Sources/ModelicaStandardTables.c
Original file line number Diff line number Diff line change
Expand Up @@ -1167,13 +1167,11 @@ double ModelicaStandardTables_CombiTimeTable_getValue(void* _tableID, int iCol,
break;

case NO_EXTRAPOLATION:
ModelicaFormatError("Extrapolation error: Time "
"(=%lf) must be %s or equal\nthan the %s abscissa "
"value %s (=%lf) defined in the table.\n", tOld,
ModelicaFormatError("Extrapolation error: Time must be "
"%s or equal\nthan the shifted %s abscissa "
"value defined in the table.\n",
(extrapolate == LEFT) ? "greater" : "less",
(extrapolate == LEFT) ? "minimum" : "maximum",
(extrapolate == LEFT) ? "t_min" : "t_max",
(extrapolate == LEFT) ? tMin : tMax);
(extrapolate == LEFT) ? "minimum" : "maximum");
return y;

case PERIODIC:
Expand Down Expand Up @@ -1425,13 +1423,11 @@ double ModelicaStandardTables_CombiTimeTable_getDerValue(void* _tableID, int iCo
break;

case NO_EXTRAPOLATION:
ModelicaFormatError("Extrapolation error: Time "
"(=%lf) must be %s or equal\nthan the %s abscissa "
"value %s (=%lf) defined in the table.\n", tOld,
ModelicaFormatError("Extrapolation error: Time must be "
"%s or equal\nthan the shifted %s abscissa "
"value defined in the table.\n",
(extrapolate == LEFT) ? "greater" : "less",
(extrapolate == LEFT) ? "minimum" : "maximum",
(extrapolate == LEFT) ? "t_min" : "t_max",
(extrapolate == LEFT) ? tMin : tMax);
(extrapolate == LEFT) ? "minimum" : "maximum");
return der_y;

case PERIODIC:
Expand Down Expand Up @@ -1685,13 +1681,11 @@ double ModelicaStandardTables_CombiTimeTable_getDer2Value(void* _tableID, int iC
break;

case NO_EXTRAPOLATION:
ModelicaFormatError("Extrapolation error: Time "
"(=%lf) must be %s or equal\nthan the %s abscissa "
"value %s (=%lf) defined in the table.\n", tOld,
ModelicaFormatError("Extrapolation error: Time must be "
"%s or equal\nthan the shifted %s abscissa "
"value defined in the table.\n",
(extrapolate == LEFT) ? "greater" : "less",
(extrapolate == LEFT) ? "minimum" : "maximum",
(extrapolate == LEFT) ? "t_min" : "t_max",
(extrapolate == LEFT) ? tMin : tMax);
(extrapolate == LEFT) ? "minimum" : "maximum");
return der2_y;

case PERIODIC:
Expand Down

0 comments on commit 36e5c00

Please sign in to comment.