diff --git a/Modelica/Blocks/Tables.mo b/Modelica/Blocks/Tables.mo index 50e38d1d56..f46f61bf58 100644 --- a/Modelica/Blocks/Tables.mo +++ b/Modelica/Blocks/Tables.mo @@ -157,6 +157,10 @@ extrapolation = 1: Hold the first or last value of the table, this means to extrapolate linearly through the first/last two table points.). = 3: Periodically repeat the table data (periodical function). + Because no assumption can be made about the spacing of the + samples -- defined in the first column -- the repetition period + is table[end,1]-table[1,1]. See 'ContinuityPeriodicTableExtrapolation' + in the examples. = 4: No extrapolation, i.e. extrapolation triggers an error
  • If the table has only one row, the table value is returned, @@ -428,6 +432,10 @@ extrapolation = 1: Hold the first or last value of the table, this means to extrapolate linearly through the first/last two table points.). = 3: Periodically repeat the table data (periodical function). + Because no assumption can be made about the spacing of the + samples -- defined in the first column -- the repetition period + is table[end,1]-table[1,1]. See 'ContinuityPeriodicTableExtrapolation' + in the examples. = 4: No extrapolation, i.e. extrapolation triggers an error
  • If the table has only one row, the table value is returned, @@ -635,6 +643,10 @@ extrapolation = 1: Hold the first or last values of the table, this means to extrapolate linearly through the first/last two table points.). = 3: Periodically repeat the table data (periodical function). + Because no assumption can be made about the spacing of the + samples, the repetition period is table[end,1]-table[2,1] + and table[1,end]-table[1,2] for columns and rows respectively. + See 'ContinuityPeriodicTableExtrapolation' in the examples. = 4: No extrapolation, i.e. extrapolation triggers an error
  • If the table has only one element, the table value is returned, @@ -833,6 +845,10 @@ extrapolation = 1: Hold the first or last values of the table, this means to extrapolate linearly through the first/last two table points.). = 3: Periodically repeat the table data (periodical function). + Because no assumption can be made about the spacing of the + samples, the repetition period is table[end,1]-table[2,1] + and table[1,end]-table[1,2] for columns and rows respectively. + See 'ContinuityPeriodicTableExtrapolation' in the examples. = 4: No extrapolation, i.e. extrapolation triggers an error
  • If the table has only one element, the table value is returned, diff --git a/Modelica/Blocks/package.mo b/Modelica/Blocks/package.mo index be701b65ea..df543bdf7c 100644 --- a/Modelica/Blocks/package.mo +++ b/Modelica/Blocks/package.mo @@ -1675,7 +1675,41 @@ we can compare the numerical solution with the analytical solution: The output is constant from the beginning.

    ")); - end DemoSignalCharacteristic; + end DemoSignalCharacteristic; + + model ContinuityPeriodicTableExtrapolation "Compare continuity of periodic extrapolation of CombiTable1Ds/CombiTable1Dv" + extends Modelica.Icons.Example; + Sources.Ramp ramp( + height=15, + offset=-5, + duration=1.5) annotation (Placement(transformation(origin={-18, 0}, extent={{-10,-10},{10,10}}))); + Tables.CombiTable1Ds discontinuousExtrapol( + table=[0,-1;4,1], + extrapolation=Types.Extrapolation.Periodic, + smoothness=Types.Smoothness.ModifiedContinuousDerivative) "Table block with discontinuous periodic extrapolation" + annotation (Placement(transformation(origin={22,30}, extent={{-10,-10},{10,10}}))); + Tables.CombiTable1Ds continuousC0ExtraPol( + table=[0,-1;1,0;2,1;3,0;4,-1], + extrapolation=Types.Extrapolation.Periodic, + smoothness=Types.Smoothness.ModifiedContinuousDerivative) "Table block with C0 periodic extrapolation" + annotation (Placement(transformation(extent={{12,-10},{32,10}}))); + Tables.CombiTable1Ds continuousC1Extrapol( + table=[0,-1;0.25,-1;0.5,-1;2,1;3.5,-1;3.75,-1;4,-1], + extrapolation=Types.Extrapolation.Periodic, + smoothness=Types.Smoothness.ModifiedContinuousDerivative) "Table block with C1 periodic extrapolation" + annotation (Placement(transformation(origin={22,-30}, extent={{-10,-10},{10,10}}))); + equation + connect(continuousC0ExtraPol.u, ramp.y) annotation( + Line(points={{10,0},{-7,0}},color={0,0,127})); + connect(discontinuousExtrapol.u, ramp.y) annotation( + Line(points={{10,30},{0,30},{0,0},{-7,0}}, color={0,0,127})); + connect(continuousC1Extrapol.u, ramp.y) annotation( + Line(points={{10,-30},{0,-30},{0,0},{-7,0}}, color={0,0,127})); + annotation( + experiment(StartTime=0, StopTime=1.5, Tolerance=1e-06, Interval=0.01), + Documentation(info="This model demonstrates the less obvious characteristics of periodic table interpolation.
    This is relevant to both 1D and 2D tables.

    Periodicity
    The periodicity of a one-dimensional table is defined as table[end,1]-table[1,1].
    This implies that the first and last points in the table 'overlap' when extrapolating. 
    The top model in this example, 'discontinuousExtrapol', illustrates how this works out during simulation. It defines a saw-tooth function by its minimum and maximum value and linear interpolation.
    The values at both ends of the definition interval (at t=0.5s and t=0.9s) are equal to the values defined in table[1,2] and table[end,2] respectively. Thus the table is evaluated including the interval limits: [start, end]

    Outside of the definition interval, the limit towards the definition interval is used. On the left side, the table is evaluated excluding the end value: [start, end>. On the right side it is evaluated excluding the start value: <start, end].
    This effect is deliberately exaggerated in this model by choosing a large simulation interval.
    It is clear that for t > 0.9s, the table output approaches -1 when t decreases, but at t=0.9s (and t=1.3s, etc.), the output will be exactly equal to 1.
    Likewise, for t<0.5s the table output will be <1  but never equal to 1. Instead at t=0.5 (and t=0.1 etc.), the output will be exactly -1.

    Differentiability
    The second model 'continuousC0Extrapolation' demonstrates that the derivative is not defined in the edges of the definition interval. The table definition [0, -1; 1, 0; 2, 1; 3, 0; 4, -1] defines a function that would be a triangle with linear interpolation.
    With continuous derivative, it is smooth in the interval, but not in the edges (t=0.5s, t= 0.9s, etc.).

    The bottom model 'continuousC1Extrapol' with table [0, -1; 0.25, -1; 0.5, -1; 2, 1; 3.5, -1; 3.75, -1; 4, -1] defines a function which is continuous in the interval edge, as well as its first 2 derivatives: around the interval edge there are 5 consecutive points at -1.
    This results in a smooth function.


    For more information, see Proceedings of the 10th International Modelica Conference. Ed. by Hubertus Tummescheit and Karl-Erik Årzén. Lund, Sweden, March 2014.
    + DOI: 10.3384/ecp14096893.")); + end ContinuityPeriodicTableExtrapolation; package Noise "Library of examples to demonstrate the usage of package Blocks.Noise" extends Modelica.Icons.ExamplesPackage;