Define differentiability of function body
annotation"(" smoothOrder "=" UNSIGNED_INTEGER ")" annotation"(" smoothOrder "(" normallyConstant=NAME ["," normallyConstant=NAME] ")" "=" UNSIGNED_NUMBER ")"
This annotation has only an effect within a function declaration.
smoothOrder defines the number of differentiations of the function, in order that all of the differentiated outputs are continuous provided all input arguments and their derivatives up to order smoothOrder are continuous.
This means that the function is at least CsmoothOrder. smoothOrder = 1 means that the function can be differentiated at least once in order that all output arguments are still continuous, provided the input arguments are continuous. If a tool needs the derivative of a function, e.g., for index reduction or to compute an analytic Jacobian, the function can be differentiated analytically at most smoothOrder times.
The optional argument normallyConstant
of smoothOrder
defines that the function argument NAME
is usually constant.
This annotation is used by many functions of the Modelica.Fluid library, such as Modelica.Fluid.Dissipation.PressureLoss.StraightPipe.dp_laminar_DP, since geometric arguments to these functions are usually constant.
function SpecialPolynomial input Real u; output Real y; algorithm y = if u > 0 then u^2 else 0; annotation(smoothOrder = 1); end SpecialPolynomial; model TestSpecialPolynomial Real y; Real yd; Real ydd; equation y = SpecialPolynomial(sin(time)); yd = der(y); // fine, SpecialPolynomial is analytically differentiated once ydd = der(yd); // error, SpecialPolynomial cannot be differentiated twice end TestSpecialPolynomial;