Ticket #3252: SmoothSatTotal.mo

File SmoothSatTotal.mo, 17.5 KB (added by Francesco Casella, 7 years ago)

Save Total file

Line 
1package Test
2package Modelica "Modelica Standard Library - Version 3.2.1 (Build 2)"
3extends Modelica.Icons.Package;
4
5 package Icons "Library of icons"
6 extends Icons.Package;
7
8 partial package Package "Icon for standard packages"
9
10 annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics={
11 Rectangle(
12 lineColor={200,200,200},
13 fillColor={248,248,248},
14 fillPattern=FillPattern.HorizontalCylinder,
15 extent={{-100.0,-100.0},{100.0,100.0}},
16 radius=25.0),
17 Rectangle(
18 lineColor={128,128,128},
19 fillPattern=FillPattern.None,
20 extent={{-100.0,-100.0},{100.0,100.0}},
21 radius=25.0)}), Documentation(info="<html>
22<p>Standard package icon.</p>
23</html>"));
24 end Package;
25
26 partial package InternalPackage
27 "Icon for an internal package (indicating that the package should not be directly utilized by user)"
28
29 annotation (
30 Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,
31 100}}), graphics={
32 Rectangle(
33 lineColor={215,215,215},
34 fillColor={255,255,255},
35 fillPattern=FillPattern.HorizontalCylinder,
36 extent={{-100,-100},{100,100}},
37 radius=25),
38 Rectangle(
39 lineColor={215,215,215},
40 fillPattern=FillPattern.None,
41 extent={{-100,-100},{100,100}},
42 radius=25),
43 Ellipse(
44 extent={{-80,80},{80,-80}},
45 lineColor={215,215,215},
46 fillColor={215,215,215},
47 fillPattern=FillPattern.Solid),
48 Ellipse(
49 extent={{-55,55},{55,-55}},
50 lineColor={255,255,255},
51 fillColor={255,255,255},
52 fillPattern=FillPattern.Solid),
53 Rectangle(
54 extent={{-60,14},{60,-14}},
55 lineColor={215,215,215},
56 fillColor={215,215,215},
57 fillPattern=FillPattern.Solid,
58 origin={0,0},
59 rotation=45)}),
60 Documentation(info="<html>
61
62<p>
63This icon shall be used for a package that contains internal classes not to be
64directly utilized by a user.
65</p>
66</html>"));
67 end InternalPackage;
68 annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,
69 -100},{100,100}}), graphics={Polygon(
70 origin={-8.167,-17},
71 fillColor={128,128,128},
72 pattern=LinePattern.None,
73 fillPattern=FillPattern.Solid,
74 points={{-15.833,20.0},{-15.833,30.0},{14.167,40.0},{24.167,20.0},{
75 4.167,-30.0},{14.167,-30.0},{24.167,-30.0},{24.167,-40.0},{-5.833,
76 -50.0},{-15.833,-30.0},{4.167,20.0},{-5.833,20.0}},
77 smooth=Smooth.Bezier,
78 lineColor={0,0,0}), Ellipse(
79 origin={-0.5,56.5},
80 fillColor={128,128,128},
81 pattern=LinePattern.None,
82 fillPattern=FillPattern.Solid,
83 extent={{-12.5,-12.5},{12.5,12.5}},
84 lineColor={0,0,0})}), Documentation(info="<html>
85<p>This package contains definitions for the graphical layout of components which may be used in different libraries. The icons can be utilized by inheriting them in the desired class using &quot;extends&quot; or by directly copying the &quot;icon&quot; layer. </p>
86
87<h4>Main Authors:</h4>
88
89<dl>
90<dt><a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a></dt>
91 <dd>Deutsches Zentrum fuer Luft und Raumfahrt e.V. (DLR)</dd>
92 <dd>Oberpfaffenhofen</dd>
93 <dd>Postfach 1116</dd>
94 <dd>D-82230 Wessling</dd>
95 <dd>email: <a href=\"mailto:Martin.Otter@dlr.de\">Martin.Otter@dlr.de</a></dd>
96<dt>Christian Kral</dt>
97 <dd><a href=\"http://www.ait.ac.at/\">Austrian Institute of Technology, AIT</a></dd>
98 <dd>Mobility Department</dd><dd>Giefinggasse 2</dd>
99 <dd>1210 Vienna, Austria</dd>
100 <dd>email: <a href=\"mailto:dr.christian.kral@gmail.com\">dr.christian.kral@gmail.com</a></dd>
101<dt>Johan Andreasson</dt>
102 <dd><a href=\"http://www.modelon.se/\">Modelon AB</a></dd>
103 <dd>Ideon Science Park</dd>
104 <dd>22370 Lund, Sweden</dd>
105 <dd>email: <a href=\"mailto:johan.andreasson@modelon.se\">johan.andreasson@modelon.se</a></dd>
106</dl>
107
108<p>Copyright &copy; 1998-2013, Modelica Association, DLR, AIT, and Modelon AB. </p>
109<p><i>This Modelica package is <b>free</b> software; it can be redistributed and/or modified under the terms of the <b>Modelica license</b>, see the license conditions and the accompanying <b>disclaimer</b> in <a href=\"modelica://Modelica.UsersGuide.ModelicaLicense2\">Modelica.UsersGuide.ModelicaLicense2</a>.</i> </p>
110</html>"));
111 end Icons;
112
113 package SIunits
114 "Library of type and unit definitions based on SI units according to ISO 31-1992"
115 extends Modelica.Icons.Package;
116 annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,
117 -100},{100,100}}), graphics={
118 Line(
119 points={{-66,78},{-66,-40}},
120 color={64,64,64},
121 smooth=Smooth.None),
122 Ellipse(
123 extent={{12,36},{68,-38}},
124 lineColor={64,64,64},
125 fillColor={175,175,175},
126 fillPattern=FillPattern.Solid),
127 Rectangle(
128 extent={{-74,78},{-66,-40}},
129 lineColor={64,64,64},
130 fillColor={175,175,175},
131 fillPattern=FillPattern.Solid),
132 Polygon(
133 points={{-66,-4},{-66,6},{-16,56},{-16,46},{-66,-4}},
134 lineColor={64,64,64},
135 smooth=Smooth.None,
136 fillColor={175,175,175},
137 fillPattern=FillPattern.Solid),
138 Polygon(
139 points={{-46,16},{-40,22},{-2,-40},{-10,-40},{-46,16}},
140 lineColor={64,64,64},
141 smooth=Smooth.None,
142 fillColor={175,175,175},
143 fillPattern=FillPattern.Solid),
144 Ellipse(
145 extent={{22,26},{58,-28}},
146 lineColor={64,64,64},
147 fillColor={255,255,255},
148 fillPattern=FillPattern.Solid),
149 Polygon(
150 points={{68,2},{68,-46},{64,-60},{58,-68},{48,-72},{18,-72},{18,-64},
151 {46,-64},{54,-60},{58,-54},{60,-46},{60,-26},{64,-20},{68,-6},{68,
152 2}},
153 lineColor={64,64,64},
154 smooth=Smooth.Bezier,
155 fillColor={175,175,175},
156 fillPattern=FillPattern.Solid)}), Documentation(info="<html>
157<p>This package provides predefined types, such as <i>Mass</i>,
158<i>Angle</i>, <i>Time</i>, based on the international standard
159on units, e.g.,
160</p>
161
162<pre> <b>type</b> Angle = Real(<b>final</b> quantity = \"Angle\",
163 <b>final</b> unit = \"rad\",
164 displayUnit = \"deg\");
165</pre>
166
167<p>
168as well as conversion functions from non SI-units to SI-units
169and vice versa in subpackage
170<a href=\"modelica://Modelica.SIunits.Conversions\">Conversions</a>.
171</p>
172
173<p>
174For an introduction how units are used in the Modelica standard library
175with package SIunits, have a look at:
176<a href=\"modelica://Modelica.SIunits.UsersGuide.HowToUseSIunits\">How to use SIunits</a>.
177</p>
178
179<p>
180Copyright &copy; 1998-2013, Modelica Association and DLR.
181</p>
182<p>
183<i>This Modelica package is <u>free</u> software and the use is completely at <u>your own risk</u>; it can be redistributed and/or modified under the terms of the Modelica License 2. For license conditions (including the disclaimer of warranty) see <a href=\"modelica://Modelica.UsersGuide.ModelicaLicense2\">Modelica.UsersGuide.ModelicaLicense2</a> or visit <a href=\"https://www.modelica.org/licenses/ModelicaLicense2\"> https://www.modelica.org/licenses/ModelicaLicense2</a>.</i>
184</p>
185</html>", revisions="<html>
186<ul>
187<li><i>May 25, 2011</i> by Stefan Wischhusen:<br/>Added molar units for energy and enthalpy.</li>
188<li><i>Jan. 27, 2010</i> by Christian Kral:<br/>Added complex units.</li>
189<li><i>Dec. 14, 2005</i> by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br/>Add User&#39;;s Guide and removed &quot;min&quot; values for Resistance and Conductance.</li>
190<li><i>October 21, 2002</i> by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a> and <a href=\"http://www.robotic.dlr.de/Christian.Schweiger/\">Christian Schweiger</a>:<br/>Added new package <b>Conversions</b>. Corrected typo <i>Wavelenght</i>.</li>
191<li><i>June 6, 2000</i> by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br/>Introduced the following new types<br/>type Temperature = ThermodynamicTemperature;<br/>types DerDensityByEnthalpy, DerDensityByPressure, DerDensityByTemperature, DerEnthalpyByPressure, DerEnergyByDensity, DerEnergyByPressure<br/>Attribute &quot;final&quot; removed from min and max values in order that these values can still be changed to narrow the allowed range of values.<br/>Quantity=&quot;Stress&quot; removed from type &quot;Stress&quot;, in order that a type &quot;Stress&quot; can be connected to a type &quot;Pressure&quot;.</li>
192<li><i>Oct. 27, 1999</i> by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br/>New types due to electrical library: Transconductance, InversePotential, Damping.</li>
193<li><i>Sept. 18, 1999</i> by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br/>Renamed from SIunit to SIunits. Subpackages expanded, i.e., the SIunits package, does no longer contain subpackages.</li>
194<li><i>Aug 12, 1999</i> by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br/>Type &quot;Pressure&quot; renamed to &quot;AbsolutePressure&quot; and introduced a new type &quot;Pressure&quot; which does not contain a minimum of zero in order to allow convenient handling of relative pressure. Redefined BulkModulus as an alias to AbsolutePressure instead of Stress, since needed in hydraulics.</li>
195<li><i>June 29, 1999</i> by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br/>Bug-fix: Double definition of &quot;Compressibility&quot; removed and appropriate &quot;extends Heat&quot; clause introduced in package SolidStatePhysics to incorporate ThermodynamicTemperature.</li>
196<li><i>April 8, 1998</i> by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a> and Astrid Jaschinski:<br/>Complete ISO 31 chapters realized.</li>
197<li><i>Nov. 15, 1997</i> by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a> and <a href=\"http://www.control.lth.se/~hubertus/\">Hubertus Tummescheit</a>:<br/>Some chapters realized.</li>
198</ul>
199</html>"));
200 end SIunits;
201annotation (
202preferredView="info",
203version="3.2.1",
204versionBuild=2,
205versionDate="2013-08-14",
206dateModified = "2013-08-14 08:44:41Z",
207revisionId="$Id:: package.mo 6947 2013-08-23 07:41:37Z #$",
208uses(Complex(version="3.2.1"), ModelicaServices(version="3.2.1")),
209conversion(
210 noneFromVersion="3.2",
211 noneFromVersion="3.1",
212 noneFromVersion="3.0.1",
213 noneFromVersion="3.0",
214 from(version="2.1", script="modelica://Modelica/Resources/Scripts/Dymola/ConvertModelica_from_2.2.2_to_3.0.mos"),
215 from(version="2.2", script="modelica://Modelica/Resources/Scripts/Dymola/ConvertModelica_from_2.2.2_to_3.0.mos"),
216 from(version="2.2.1", script="modelica://Modelica/Resources/Scripts/Dymola/ConvertModelica_from_2.2.2_to_3.0.mos"),
217 from(version="2.2.2", script="modelica://Modelica/Resources/Scripts/Dymola/ConvertModelica_from_2.2.2_to_3.0.mos")),
218Icon(coordinateSystem(extent={{-100.0,-100.0},{100.0,100.0}}), graphics={
219 Polygon(
220 origin={-6.9888,20.048},
221 fillColor={0,0,0},
222 pattern=LinePattern.None,
223 fillPattern=FillPattern.Solid,
224 points={{-93.0112,10.3188},{-93.0112,10.3188},{-73.011,24.6},{-63.011,31.221},{-51.219,36.777},{-39.842,38.629},{-31.376,36.248},{-25.819,29.369},{-24.232,22.49},{-23.703,17.463},{-15.501,25.135},{-6.24,32.015},{3.02,36.777},{15.191,39.423},{27.097,37.306},{32.653,29.633},{35.035,20.108},{43.501,28.046},{54.085,35.19},{65.991,39.952},{77.897,39.688},{87.422,33.338},{91.126,21.696},{90.068,9.525},{86.099,-1.058},{79.749,-10.054},{71.283,-21.431},{62.816,-33.337},{60.964,-32.808},{70.489,-16.14},{77.368,-2.381},{81.072,10.054},{79.749,19.05},{72.605,24.342},{61.758,23.019},{49.587,14.817},{39.003,4.763},{29.214,-6.085},{21.012,-16.669},{13.339,-26.458},{5.401,-36.777},{-1.213,-46.037},{-6.24,-53.446},{-8.092,-52.387},{-0.684,-40.746},{5.401,-30.692},{12.81,-17.198},{19.424,-3.969},{23.658,7.938},{22.335,18.785},{16.514,23.283},{8.047,23.019},{-1.478,19.05},{-11.267,11.113},{-19.734,2.381},{-29.259,-8.202},{-38.519,-19.579},{-48.044,-31.221},{-56.511,-43.392},{-64.449,-55.298},{-72.386,-66.939},{-77.678,-74.612},{-79.53,-74.083},{-71.857,-61.383},{-62.861,-46.037},{-52.278,-28.046},{-44.869,-15.346},{-38.784,-2.117},{-35.344,8.731},{-36.403,19.844},{-42.488,23.813},{-52.013,22.49},{-60.744,16.933},{-68.947,10.054},{-76.884,2.646},{-93.0112,-12.1707},{-93.0112,-12.1707}},
225 smooth=Smooth.Bezier),
226 Ellipse(
227 origin={40.8208,-37.7602},
228 fillColor={161,0,4},
229 pattern=LinePattern.None,
230 fillPattern=FillPattern.Solid,
231 extent={{-17.8562,-17.8563},{17.8563,17.8562}})}),
232Documentation(info="<HTML>
233<p>
234Package <b>Modelica&reg;</b> is a <b>standardized</b> and <b>free</b> package
235that is developed together with the Modelica&reg; language from the
236Modelica Association, see
237<a href=\"https://www.Modelica.org\">https://www.Modelica.org</a>.
238It is also called <b>Modelica Standard Library</b>.
239It provides model components in many domains that are based on
240standardized interface definitions. Some typical examples are shown
241in the next figure:
242</p>
243
244<p>
245<img src=\"modelica://Modelica/Resources/Images/UsersGuide/ModelicaLibraries.png\">
246</p>
247
248<p>
249For an introduction, have especially a look at:
250</p>
251<ul>
252<li> <a href=\"modelica://Modelica.UsersGuide.Overview\">Overview</a>
253 provides an overview of the Modelica Standard Library
254 inside the <a href=\"modelica://Modelica.UsersGuide\">User's Guide</a>.</li>
255<li><a href=\"modelica://Modelica.UsersGuide.ReleaseNotes\">Release Notes</a>
256 summarizes the changes of new versions of this package.</li>
257<li> <a href=\"modelica://Modelica.UsersGuide.Contact\">Contact</a>
258 lists the contributors of the Modelica Standard Library.</li>
259<li> The <b>Examples</b> packages in the various libraries, demonstrate
260 how to use the components of the corresponding sublibrary.</li>
261</ul>
262
263<p>
264This version of the Modelica Standard Library consists of
265</p>
266<ul>
267<li><b>1360</b> models and blocks, and</li>
268<li><b>1280</b> functions</li>
269</ul>
270<p>
271that are directly usable (= number of public, non-partial classes). It is fully compliant
272to <a href=\"https://www.modelica.org/documents/ModelicaSpec32Revision2.pdf\">Modelica Specification Version 3.2 Revision 2</a>
273and it has been tested with Modelica tools from different vendors.
274</p>
275
276<p>
277<b>Licensed by the Modelica Association under the Modelica License 2</b><br>
278Copyright &copy; 1998-2013, ABB, AIT, T.&nbsp;B&ouml;drich, DLR, Dassault Syst&egrave;mes AB, Fraunhofer, A.Haumer, ITI, Modelon,
279TU Hamburg-Harburg, Politecnico di Milano, XRG Simulation.
280</p>
281
282<p>
283<i>This Modelica package is <u>free</u> software and the use is completely at <u>your own risk</u>; it can be redistributed and/or modified under the terms of the Modelica License 2. For license conditions (including the disclaimer of warranty) see <a href=\"modelica://Modelica.UsersGuide.ModelicaLicense2\">Modelica.UsersGuide.ModelicaLicense2</a> or visit <a href=\"https://www.modelica.org/licenses/ModelicaLicense2\"> https://www.modelica.org/licenses/ModelicaLicense2</a>.</i>
284</p>
285
286<p>
287<b>Modelica&reg;</b> is a registered trademark of the Modelica Association.
288</p>
289</html>"));
290end Modelica;
291
292package Cryogenics "Library of components for cryogenic circuit models"
293 import SI = Modelica.SIunits;
294
295 package Test "Test models"
296
297 model SmoothSat
298 Real x=time;
299 Real y=Internals.smoothSat(
300 time,
301 1,
302 2,
303 0.1,
304 0.3);
305 Real y1;
306 Real y2;
307 Real y3;
308 Real y4;
309 Real y5;
310 equation
311 y1 = der(y);
312 y2 = der(y1);
313 y3 = der(y2);
314 y4 = der(y3);
315 y5 = der(y4);
316 annotation (experiment(
317 StopTime=3,
318 NumberOfIntervals=10000,
319 Algorithm="Euler"), experimentSetupOutput);
320 end SmoothSat;
321 end Test;
322
323 package Internals "Intermediate class definitions"
324 extends Modelica.Icons.InternalPackage;
325
326 function smoothSat "Smooth saturation function"
327 input Real x;
328 input Real xmin "Lower bound of range where y = x";
329 input Real xmax "Upper bound of range where y = x";
330 input Real dxmin "Width of lower smoothing range";
331 input Real dxmax=dxmin "Width of upper smoothing range";
332 output Real y;
333 algorithm
334 y := if x < xmin + dxmin then xmin + dxmin - dxmin*(xmin + dxmin - x)/(
335 dxmin^4 + (xmin + dxmin - x)^4)^0.25 else if x > xmax - dxmax then xmax
336 - dxmax + dxmax*(x - xmax + dxmax)/(dxmax^4 + (x - xmax + dxmax)^4)^
337 0.25 else x;
338 annotation (smoothOrder=4, InLine=true);
339 end smoothSat;
340 end Internals;
341 annotation (uses(Modelica(version="3.2.1"), ThermoPower(version="3.1")));
342end Cryogenics;
343model Cryogenics_Test_SmoothSat
344 extends Cryogenics.Test.SmoothSat;
345 annotation(experiment(
346 StopTime=3,
347 NumberOfIntervals=10000,
348 Algorithm="Euler"));
349end Cryogenics_Test_SmoothSat;
350end Test;