2

I am using some components from the Modelica Standard Library (MSL) in my simulations. These components each have some parameters. For example, Modelica.Fluid.Sources.MassFlowSource_T has a parameter m_flow. Usually, parameters can be changed between simulation runs without re-compilation. This is not the case for m_flow, because it has an annotation(Evaluate=true), so it is used for symbolic processing.
Is it possible to change the annotations of parameters at instantiation? I tried the following, but it didn't work.

Modelica.Fluid.Sources.MassFlowSource_T source2(
    redeclare package Medium = Medium2,
    nPorts=1,
    m_flow=22.17 annotation(Evaluate=false));

Of course there are workarounds, like making a copy first and changing the annotation there or using use_m_flow_in=true and a constant source block.

matth
  • 2,568
  • 2
  • 21
  • 41

1 Answers1

6

As far as I know this is not possible with current Modelica Specification. Some tools might support it if you extend MassFlowSource_T:

model MassFlowSource_T_2
  extends Modelica.Fluid.Sources.MassFlowSource_T;
  // declare m_flow here again with annotation(Evaluate=false);
end MassFlowSource_T_2;

use MassFlowSource_T_2 when you declare source2.

There is some work in progress to extend the way annotations are specified/handled but it will be a while until it makes it into the Modelica Specification: https://trac.modelica.org/Modelica/ticket/1293 (not open to the public yet).

Adrian Pop
  • 4,034
  • 13
  • 16
  • https://github.com/modelica/ModelicaSpecification/issues/1293 migrated, but still not open to the public – matth Mar 22 '21 at 09:06