@@ -52,6 +52,33 @@ should also be noted that even a simple variable assignment, *e.g.,*
52
52
53
53
can trigger an event to be generated.
54
54
55
+ Piecewise Constructions
56
+ ***********************
57
+
58
+ There is an important special case when dealing with conditional
59
+ expressions. In some cases, it is useful to create an expression that
60
+ is constructed piecewise. For example,
61
+
62
+ .. code-block :: modelica
63
+
64
+ x = if (x<0) then 0 else x^2;
65
+
66
+ It is hard for a Modelica compiler to reliably determine that such a
67
+ function is continuous or whether it has continuous derivatives. For
68
+ this reason, Modelica includes the ``smooth `` operator to explicitly
69
+ express such conditions. For example, using the ``smooth `` operator
70
+ as follows:
71
+
72
+ .. code-block :: modelica
73
+
74
+ x = smooth(if (x<0) then 0 else x^2, 2);
75
+
76
+ indicates that the expression is continuous as is and will remain
77
+ continuous if differentiated up to 2 times. Of course, in this case
78
+ the expression is continuous regardless of the number of
79
+ differentiations. But the ``smooth `` operator requires an upper bound
80
+ to be specified.
81
+
55
82
Events and Functions
56
83
^^^^^^^^^^^^^^^^^^^^
57
84
@@ -108,4 +135,6 @@ Function Description
108
135
``previous(x) `` During clock tick, value of ``x `` during previous clock tick
109
136
``hold(x) `` Anytime, value of ``x `` during previous clock tick
110
137
``sample(expr,clock) `` During clock tick, value of ``expr ``
138
+ ``noEvent(expr) `` Suppresses events generated by ``expr ``
139
+ ``smooth(expr,p) `` Indicates ``expr `` can be safely differentiated ``p `` times.
111
140
====================== ========================================================
0 commit comments