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.
References
-
Filip Jorissen, Michael Wetter and Lieve Helsen.
Simulation speed analysis and improvements of Modelica
models for building energy simulation.
Submitted: 11th Modelica Conference. Paris, France. Sep. 2015.
-
March 6, 2023, by Michael Wetter:
Added a constant in order for unit check to pass.
See #1711
for a discussion.
-
July 14, 2015, by Michael Wetter:
Revised documentation.
-
April 17, 2015, by Filip Jorissen:
First implementation.
Generated at 2024-12-21T19:25:56Z
by OpenModelicaOpenModelica 1.24.3 using GenerateDoc.mos