Skip to content

Commit

Permalink
Added example documentation on periodicity
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul van der Hulst committed Apr 19, 2024
1 parent 85eb0f4 commit cb2d083
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion Modelica/Blocks/package.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1679,7 +1679,29 @@ we can compare the numerical solution with the analytical solution:
The output is constant from the beginning.
</p>
</html>"));
end DemoSignalCharacteristic;
end DemoSignalCharacteristic;

model ContinuityPeriodicTableExtrapolation "Compare continuity of period extrapolation of CombiTable1Ds/CombiTable1Dv"
extends Modelica.Icons.Example;
Modelica.Blocks.Sources.Ramp ramp(height = 15, offset = -5, duration = 1.5) annotation(
Placement(transformation(origin = {-18, 0}, extent = {{-10, -10}, {10, 10}})));
Modelica.Blocks.Tables.CombiTable1Ds discontinuousExtrapol(table = [0, -1; 4, 1], extrapolation = Modelica.Blocks.Types.Extrapolation.Periodic, smoothness = Modelica.Blocks.Types.Smoothness.ModifiedContinuousDerivative) "Table block with discontinuous periodic extrapolation" annotation(
Placement(transformation(origin = {22, 30}, extent = {{-10, -10}, {10, 10}})));
Modelica.Blocks.Tables.CombiTable1Ds continuousC0ExtraPol(table = [0, -1; 1, 0; 2, 1; 3, 0; 4, -1], extrapolation = Modelica.Blocks.Types.Extrapolation.Periodic, smoothness = Modelica.Blocks.Types.Smoothness.ModifiedContinuousDerivative) "Table block with C0 periodic extrapolation" annotation(
Placement(transformation(extent = {{12, -10}, {32, 10}})));
Modelica.Blocks.Tables.CombiTable1Ds continuousC1Extrapol(table = [0, -1; 0.25, -1; 0.5, -1; 2, 1; 3.5, -1; 3.75, -1; 4, -1], extrapolation = Modelica.Blocks.Types.Extrapolation.Periodic, smoothness = Modelica.Blocks.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.02),
Documentation(info = "<html><head></head><body>This model demonstrates the less obvious charactristics of <u>periodic</u> table interpolation.<div>This is relevant to both 1D and 2D tables.</div><div><br></div><div><b>Periodicity</b></div><div>The periodicity of a one-dimensional table is defined as table[end,1]-table[1,1].</div><div>This implies that the first and last points in the table 'overlap' when extrapolating.&nbsp;</div><div>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.</div><div>The values at the ends of the definition interval (from <i>t</i>=0.5s to <i>t</i>=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]</div><div><br></div><div>Outside of the definition interval, the <i>limit</i> towards the definition interval is used. On the left side, the table is evaluated excluding the end value: [start, end&gt;. On the right side it is evaluated excluding the start value: &lt;start, end].</div><div>This effect is deliberately exaggerated in this model by choosing a large simulation interval.</div><div>It is clear that for <i>t</i> &gt; 0.9s, the table output approaches -1 when <i>t</i> decreases, but <i>at</i>&nbsp;t=0.9s (and t=1.3s, etc.), the output will be exactly equal to 1.</div><div>Likewise, the table output will be&nbsp;&lt;1 &nbsp;but never equal to 1 for <i>t</i>&lt;0.5s. Instead at <i>t</i>=0.5 (and t=0.1 etc.), the output will be exactly -1.</div><div><br></div><div><b>Differentiability</b></div><div><br></div></body></html>"));
end ContinuityPeriodicTableExtrapolation;

package Noise "Library of examples to demonstrate the usage of package Blocks.Noise"
extends Modelica.Icons.ExamplesPackage;
Expand Down

0 comments on commit cb2d083

Please sign in to comment.