This example illustrates the impact of Modelica code formulations on the C-code.

Compare the C-code in dsmodel.c when setting the parameter efficient to true or false and when adding annotation(Evaluate=true) to the parameter efficient.

This produces:

Efficient = false and Evaluate = false

helpvar[0] = sin(Time);
F_[0] = helpvar[0]*(IF DP_[0] THEN W_[0] ELSE DP_[1]+DP_[2]+DP_[3]);

Efficient = false and Evaluate = true

helpvar[0] = sin(Time);
F_[0] = helpvar[0]*(DP_[0]+DP_[1]+DP_[2]);

Efficient = true and Evaluate = true

helpvar[0] = sin(Time);
F_[0] = helpvar[0]*W_[1];

The last option requires much less operations to be performed and is therefore more efficient.

See Jorissen et al. (2015) for a discussion.



Generated at 2021-05-11T00:32:40Z by OpenModelicaOpenModelica 1.18.0~dev-269-g83ff1a1 using GenerateDoc.mos