ibpsa / modelica-ibpsa

Modelica library for building and district energy systems developed within IBPSA Project 1
https://ibpsa.github.io/project1
145 stars 84 forks source link

Modelica specification wish list #921

Open Mathadon opened 6 years ago

Mathadon commented 6 years ago

Occasionally I bump into limitations of the Modelica specification. Not all of them equally important, but I propose to collect these in this topic such that they are publicly available and such that we can identify common problems. At some point it may make sense to flag these to the broader community.

Bus parameters

Important: Expandable connectors allow the definition of parameters, but they need to be defined in each connector instantiation. I.e. it is not possible to use expandable connectors to communicate parameters between multiple blocks. It also does not seem possible to create an expandable connector with the parameter modifier, as bellow, to circumvent this:

model test

  parameter Modelica.Icons.SignalBus signalBus
    annotation (Placement(transformation(extent={{-70,0},{-30,40}})));
  parameter Modelica.Icons.SignalBus signalBus1
    annotation (Placement(transformation(extent={{10,0},{50,40}})));
  parameter Modelica.Blocks.Interfaces.RealOutput const1 = 1
    annotation (Placement(transformation(extent={{-100,10},{-80,30}})));
  parameter Modelica.Blocks.Interfaces.RealOutput const2
    annotation (Placement(transformation(extent={{76,10},{96,30}})));
  parameter Real test = const2;

equation 
  connect(signalBus, signalBus1) annotation (Line(
      points={{-50,20},{30,20}},
      color={255,204,51},
      thickness=0.5));
  connect(const1, signalBus.test) annotation (Line(points={{-90,20},{-50,20}},
        color={0,0,127}));
  connect(const2, signalBus1.test) annotation (Line(points={{86,20},{56,20},{56,
          20},{30,20}}, color={0,0,127}));
end test;

A workaround is to send continuous signals through the bus and then use a parameter declaration on the other end of the bus with fixed=false and an initial equation. However, this way the translator cannot preprocess the parameter values, which leads to less efficient code and the resulting parameters cannot be used in structural parameters, etc.

Propagate replaceables.

When instantiating a model that contains a replaceable component, it is not possible to 'propagate' this replaceable as you would do with a parameter.

Impossible to define implicit functions.

Conditional replaceables.

It is not possible to redeclare a replaceable component by one of two models based on some boolean condition.

Conditional attributes.

It could be useful at some point to be able to do something like if condition then inner else outer _some_component_definition_.

Mathadon commented 6 years ago

The cardinality() operator is deprecated, but actually I find it very useful.. For more information see http://modelica.readthedocs.io/en/latest/operators.html#operator-cardinality

thorade commented 6 years ago

Some things might be discussed in the form of Modelica Change Proposals (MCP): https://trac.modelica.org/Modelica/query?component=--MCP-- https://www.modelica.org/devs https://github.com/modelica/ModelicaSpecification