- smooth (p, expr ),表示
expr
至少p
次可导
对于分段构造的表达式:
x = if (x<0) then 0 else x^3;
It is hard for a Modelica compiler to reliably determine that such a function is continuous and has continuous derivatives. For this reason, Modelica includes the smooth
operator to explicitly express such conditions. For example, using the smooth
operator as follows:
x = smooth(if (x<0) then 0 else x^3, 2);
indicates that the expression is continuous as is and will remain continuous if differentiated up to 2 times because
Real x, y, z;
parameter Real p;
equation
x = if time < 1 then 2 else time - 2;
z = smooth (0, if time < 0 then 0 else time );
y = smooth (1, noEvent (if x < 0 then 0 else sqrt (x) * x)); // noEvent i s necessary.
事件http://modelicabyexample.globalcrown.com.cn/behavior/discrete/events/