Skip to content

Commit

Permalink
Merge branch 'issue169_smoothMin' of https://github.com/Mathadon/mode…
Browse files Browse the repository at this point in the history
…lica-annex60 into issue169_smoothMin
  • Loading branch information
mwetter committed Mar 12, 2015
2 parents 2537625 + aafdd31 commit 7a2118a
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
last-generated=2015-03-12
smoLim[2].y=[0.00000000000000000000, 0.01000000000000000021, 0.02000000000000000042, 0.02999999999999999889, 0.04000000000000000083, 0.05000000000000000278, 0.05999999999999999778, 0.07000000000000000666, 0.08000000000000000167, 0.08999999999999999667, 0.10000000000000000555, 0.11000000000000000056, 0.11999999999999999556, 0.13000000000000000444, 0.14000000000000001332, 0.14999999999999999445, 0.16000000000000000333, 0.17000000000000001221, 0.17999999999999999334, 0.19000000000000000222, 0.20000000000000001110, 0.20999999999999999223, 0.22000000000000000111, 0.23000000000000000999, 0.23999999999999999112, 0.25000000000000000000, 0.26000000000000000888, 0.27000000000000001776, 0.28000000000000002665, 0.28999999999999998002, 0.29999999999999998890, 0.30999999999999999778, 0.32000000000000000666, 0.33000000000000001554, 0.34000000000000002442, 0.34999999999999997780, 0.35999999999999998668, 0.36999999999999999556, 0.38000000000000000444, 0.39000000000000001332, 0.40000000000000002220, 0.40999999999999997558, 0.41999999999999998446, 0.42999999999999999334, 0.44000000000000000222, 0.45000000000000001110, 0.46000000000000001998, 0.46999999999999997335, 0.48000000000031972647, 0.49119203103603126248, 0.50000000000000000000, 0.50119203103620701967, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000]
smoLim[1].y=[0.00000000000000000000, 0.01000000000000000021, 0.02000000000000000042, 0.02999999999999999889, 0.04000000000000000083, 0.05000000000000000278, 0.05999999999999999778, 0.07000000000000000666, 0.08000000000000000167, 0.08999999999999999667, 0.10000000000000000555, 0.11000000000000000056, 0.11999999999999999556, 0.13000000000000000444, 0.14000000000000001332, 0.14999999999999999445, 0.16000000000000000333, 0.17000000000000001221, 0.17999999999999999334, 0.19000000000000000222, 0.20000000000000001110, 0.20999999999999999223, 0.22000000000000000111, 0.23000000000000000999, 0.23999999999999999112, 0.25000000000000000000, 0.26000000000000000888, 0.27000000000000001776, 0.28000000000000002665, 0.28999999999999998002, 0.29999999999999998890, 0.30999999999999999778, 0.32000000000000000666, 0.33000000000000001554, 0.34000000000000002442, 0.34999999999999997780, 0.35999999999999998668, 0.36999999999999999556, 0.38000000000000000444, 0.39000000000000001332, 0.40000000000000002220, 0.41000029802711407401, 0.42016942706213822323, 0.43135490175766755261, 0.44359585940314721908, 0.45596016886749107799, 0.46758108398321712729, 0.47795635575202533030, 0.48686052224826820156, 0.49421461775058495025, 0.50000000000000000000, 0.50421464755271871994, 0.50686049787469922290, 0.50795638615902805046, 0.50758111675328099199, 0.50596016886727745998, 0.50359582960083359993, 0.50135487195557659756, 0.50016939568672358352, 0.50000029801931600293, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000, 0.50000000000000000000]
time=[0.00000000000000000000, 1.00000000000000000000]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
removePlots();
simulateModel("Annex60.Utilities.Math.Examples.SmoothMin", startTime=0, method="dassl", resultFile="SmoothMin");
createPlot(id=1,
position={4, 21, 531, 524},
y={"smoLim[2].y", "smoLim[1].y"},
range={0.0, 1.0, -0.05, 0.55},
grid=true,
leftTitleType=1,
bottomTitleType=1,
colors={{0,0,255}, {255,0,0}});
4 changes: 2 additions & 2 deletions Annex60/Utilities/Math/Examples/SmoothBlocks.mo
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ model SmoothBlocks "Test model for smooth min and smooth max functions"
extent={{-100,0},{-80,20}})));
Diagnostics.AssertEquality assEquMax(threShold=0.08)
annotation (Placement(transformation(extent={{40,20},{60,40}})));
SmoothMin smoMin(deltaX=0.5) annotation (Placement(transformation(extent={{
-20,-40},{0,-20}})));
Annex60.Utilities.Math.SmoothMin smoMin(deltaX=0.5)
annotation (Placement(transformation(extent={{-20,-40},{0,-20}})));
Modelica.Blocks.Math.Min Min annotation (Placement(transformation(extent={{
-20,-80},{0,-60}})));
Diagnostics.AssertEquality assEquMin(threShold=0.08)
Expand Down
55 changes: 55 additions & 0 deletions Annex60/Utilities/Math/Examples/SmoothMin.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
within Annex60.Utilities.Math.Examples;
model SmoothMin "Test model for smooth minimum"
import Annex60;
extends Modelica.Icons.Example;
Annex60.Utilities.Math.SmoothMin smoLim[2](deltaX={0.1,0.02}) "Smooth limit"
annotation (Placement(transformation(extent={{0,-10},{20,10}})));
Modelica.Blocks.Sources.Ramp ramp(height=1, duration=1) "Ramp input"
annotation (Placement(transformation(extent={{-40,10},{-20,30}})));
Modelica.Blocks.Sources.Constant const(k=0.5) "Constant input"
annotation (Placement(transformation(extent={{-40,-30},{-20,-10}})));
equation

connect(ramp.y, smoLim[1].u1) annotation (Line(
points={{-19,20},{-2,20},{-2,6}},
color={0,0,127},
smooth=Smooth.None));
connect(smoLim[2].u1, ramp.y) annotation (Line(
points={{-2,6},{-2,20},{-19,20}},
color={0,0,127},
smooth=Smooth.None));
connect(const.y, smoLim[1].u2) annotation (Line(
points={{-19,-20},{-2,-20},{-2,-6}},
color={0,0,127},
smooth=Smooth.None));
connect(const.y, smoLim[2].u2) annotation (Line(
points={{-19,-20},{-2,-20},{-2,-6}},
color={0,0,127},
smooth=Smooth.None));
annotation(experiment(StopTime=1.0),
__Dymola_Commands(file=
"modelica://Annex60/Resources/Scripts/Dymola/Utilities/Math/Examples/SmoothMin.mos"
"Simulate and plot"),
Documentation(info="<html>
<p>
This model tests the implementation of
<a href=\"modelica://Annex60.Utilities.Math.SmoothMin\">
Annex60.Utilities.Math.SmoothMin</a>.
</p>
<p>
This model also illustrates that the output can be larger than
the minimum of the two input signals. Smaller values for <code>deltaX</code>
will reduce this effect. Therefore do not use this function when the minimum
output value should be respected.
</p>
</html>", revisions="<html>
<ul>
<li>
March 12, 2015, by Filip Jorissen:<br/>
First implementation.
</li>
</ul>
</html>"),
Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{
100,100}}), graphics));
end SmoothMin;
1 change: 1 addition & 0 deletions Annex60/Utilities/Math/Examples/package.order
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ RegNonZeroPower
SmoothBlocks
SmoothExponential
SmoothLimit
SmoothMin
Splice
VectorFunctions
9 changes: 9 additions & 0 deletions Annex60/Utilities/Math/Functions/smoothLimit.mo
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,18 @@ algorithm
Once continuously differentiable approximation to the <code>limit(.,.)</code> function.
The output is bounded to be in <i>[l, u]</i>.
</p>
<p>
Note that the limit need not be respected, such as illustrated in
<a href=\"modelica://Annex60.Utilities.Math.Examples.SmoothMin\">
Annex60.Utilities.Math.Examples.SmoothMin</a>.
</p>
</html>", revisions="<html>
<ul>
<li>
March 12, 2015, by Filip Jorissen:<br/>
Added documentation reference demonstrating overshoot.
</li>
<li>
February 5, 2015, by Filip Jorissen:<br/>
Added <code>smoothOrder = 1</code>.
</li>
Expand Down
9 changes: 9 additions & 0 deletions Annex60/Utilities/Math/Functions/smoothMax.mo
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,19 @@ Documentation(info="<html>
<p>
Once continuously differentiable approximation to the <code>max(.,.)</code> function.
</p>
<p>
Note that the maximum need not be respected, such as illustrated in
<a href=\"modelica://Annex60.Utilities.Math.Examples.SmoothMin\">
Annex60.Utilities.Math.Examples.SmoothMin</a>.
</p>
</html>",
revisions="<html>
<ul>
<li>
March 12, 2015, by Filip Jorissen:<br/>
Added documentation reference demonstrating overshoot.
</li>
<li>
February 5, 2015, by Filip Jorissen:<br/>
Added <code>smoothOrder = 1</code>.
</li>
Expand Down
9 changes: 9 additions & 0 deletions Annex60/Utilities/Math/Functions/smoothMin.mo
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,19 @@ Documentation(smoothOrder = 1,info="<html>
<p>
Once continuously differentiable approximation to the <code>min(.,.)</code> function.
</p>
<p>
Note that the minimum need not be respected, such as illustrated in
<a href=\"modelica://Annex60.Utilities.Math.Examples.SmoothMin\">
Annex60.Utilities.Math.Examples.SmoothMin</a>.
</p>
</html>",
revisions="<html>
<ul>
<li>
March 12, 2015, by Filip Jorissen:<br/>
Added documentation reference demonstrating overshoot.
</li>
<li>
February 5, 2015, by Filip Jorissen:<br/>
Added <code>smoothOrder = 1</code>.
</li>
Expand Down
9 changes: 9 additions & 0 deletions Annex60/Utilities/Math/SmoothLimit.mo
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,19 @@ Documentation(info="<html>
Once continuously differentiable approximation to the <i>limit(.,.)</i> function.
The output is bounded to be in <i>[lower, upper]</i>.
</p>
<p>
Note that the limit need not be respected, such as illustrated in
<a href=\"modelica://Annex60.Utilities.Math.Examples.SmoothMin\">
Annex60.Utilities.Math.Examples.SmoothMin</a>.
</p>
</html>",
revisions="<html>
<ul>
<li>
March 12, 2015, by Filip Jorissen:<br/>
Added documentation reference demonstrating overshoot.
</li>
<li>
July 14, 2010, by Wangda Zuo, Michael Wetter:<br/>
First implementation.
</li>
Expand Down
9 changes: 9 additions & 0 deletions Annex60/Utilities/Math/SmoothMax.mo
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,19 @@ Documentation(info="<html>
<p>
Once continuously differentiable approximation to the <i>max(.,.)</i> function.
</p>
<p>
Note that the maximum need not be respected, such as illustrated in
<a href=\"modelica://Annex60.Utilities.Math.Examples.SmoothMin\">
Annex60.Utilities.Math.Examples.SmoothMin</a>.
</p>
</html>",
revisions="<html>
<ul>
<li>
March 12, 2015, by Filip Jorissen:<br/>
Added documentation reference demonstrating overshoot.
</li>
<li>
August 15, 2008, by Michael Wetter:<br/>
First implementation.
</li>
Expand Down
9 changes: 9 additions & 0 deletions Annex60/Utilities/Math/SmoothMin.mo
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,19 @@ Documentation(info="<html>
<p>
Once continuously differentiable approximation to the <i>min(.,.)</i> function.
</p>
<p>
Note that the minimum need not be respected, such as illustrated in
<a href=\"modelica://Annex60.Utilities.Math.Examples.SmoothMin\">
Annex60.Utilities.Math.Examples.SmoothMin</a>.
</p>
</html>",
revisions="<html>
<ul>
<li>
March 12, 2015, by Filip Jorissen:<br/>
Added documentation reference demonstrating overshoot.
</li>
<li>
August 15, 2008, by Michael Wetter:<br/>
First implementation.
</li>
Expand Down

0 comments on commit 7a2118a

Please sign in to comment.