Search code examples
modelicadymola

Is it possible to conditionally set equation attributes in Modelica?


I am working on a large model that includes multiple subsystems, and a fairly large number of variables/equations. I have been using the protected attribute on subystems so that only the system level results are visible in the simulation results. This makes it easier to find system level results in the Dymola simulation tab or in FMU inputs/outputs. But there are cases where it would be nice to be able to see the full level of detail for the subsystems also.

Is it possible to conditionally apply the protected attribute based upon a Boolean parameter, or some other way?

For instance, is it possible to do something like the pseudocode below?

// Parameter that sets whether or not to use the protected attribute on subsystems.
parameter Boolean useProtected = true;

// Conditionally define the subsystem with or without protected attribute
if (useProtected) then
  protected subsystem subsystem1 = ...
else
  subsystem subsystem1 = ...
end if;

Thanks, Justin


Solution

  • See HideResult annotation: https://modelica.org/documents/ModelicaSpec33Revision1.pdf

    subsystem subsystem1 annotation(HideResult = true / false);