Opened 9 years ago

Last modified 6 years ago

#3221 assigned defect

Equation count of models containing expandable connectors

Reported by: anonymous Owned by: mahge930
Priority: normal Milestone: 2.0.0
Component: New Instantiation Version: trunk
Keywords: Cc:

Description

Consider the following code

package ExpandableConn
  model IntegInput
    Modelica.Blocks.Interfaces.RealInput u;
    Modelica.Blocks.Continuous.Integrator integrator;
  equation 
    connect(integrator.u, u);
  end IntegInput;

  model IntegConn
    Modelica.Blocks.Continuous.Integrator integrator;
    Modelica.Icons.SignalBus conn;
  equation 
    connect(integrator.u, conn.signal);
  end IntegConn;
end ExpandableConn;

For me both models in the package should be balanced (=have the same number of equations and variables).
Indeed Dymola reports 2 equations and variables in both cases.
OM, instead, in the case of IntegConn reports three variables ad two equations.
Then this model is inserted in to a larger one, the count gests balanced again.

However i think the OM behaviour is worse. In fact one of the most beautiful characteristics of Modelica is that, when balanced models are connected to each other, the whole model stays balanced; when a large model is unbalanced, usually one expects to find where the unbalance comes from by looking at individual submodels: this OM counting technique makes this process more difficult.

I must add that I've not checked what Modelica Specifications say about how to count model variables when expandable connectors are present.

Change History (5)

comment:1 Changed 9 years ago by adrpo

Using this script: ExpandableConn.mos

loadModel(Modelica); getErrorString();
loadFile("ExpandableConn.mo"); getErrorString();
checkModel(ExpandableConn.IntegInput); getErrorString();
checkModel(ExpandableConn.IntegConn); getErrorString();

we get:

adrpo@ida-liu050 ~/dev/OpenModelica/build/bin/
$ ../omc +locale=C ExpandableConn.mos
true
""
true
""
"Check of ExpandableConn.IntegInput completed successfully.


Class ExpandableConn.IntegInput has 2 equation(s) and 2 variable(s).
1 of these are trivial equation(s).
"
""
"Check of ExpandableConn.IntegConn completed successfully.


Class ExpandableConn.IntegConn has 2 equation(s) and 3 variable(s).
1 of these are trivial equation(s).
"
""

The first one is counted correctly.
The second one is not, but Dymola also complains about the second one:

Check of ExpandableConn.IntegConn:
Use of undeclared variable conn.signal
Errors found in: connect(integrator.u, conn.signal)
Modelica Text: line 13
The model contained invalid expressions.
Check aborted.
ERROR: 1 error was found

And indeed the Modelica.Icons.SignalBus conn; is just a connector, not an expandable one.
Are you sure you did the correct code?

There seems to be a bug in OpenModelica as we should not find the variable signal inside conn as conn is not expandable.

Also, you're right OpenModelica should check local balancing of models but we don't yet do it.

comment:2 Changed 9 years ago by anonymous

I made a mistake when copying the code.
Here follows the code that corresponds to what I wanted to point out.

package ExpandableConn
  model IntegInput
    Modelica.Blocks.Interfaces.RealInput u;
    Modelica.Blocks.Continuous.Integrator integrator;
  equation 
    connect(integrator.u, u);
  end IntegInput;

  model IntegConn

    Modelica.Blocks.Continuous.Integrator integrator;
    Conn conn;
  equation 
    connect(integrator.u, conn.signal);
  end IntegConn;

  expandable connector Conn
    extends Modelica.Icons.SignalBus;
  end Conn;

end ExpandableConn;

I'm glad to see that you intend to revise the equation count (I infer this from your "yet" in the end of your message).

comment:3 Changed 9 years ago by adrpo

Yes, we're working on improving the front-end and that will include local balance checking.
Hopefully will be available sometime in the fall.

comment:4 Changed 6 years ago by casella

  • Component changed from *unknown* to NF - New FrontEnd
  • Milestone changed from Future to 2.0.0
  • Owner changed from somebody to mahge930
  • Status changed from new to assigned
  • Type changed from discussion to defect

See #4138 under "Local balanced checking"

comment:5 Changed 6 years ago by perost

  • Component changed from NF - New FrontEnd to New Instantiation

Move all tickets from NF - New Frontend to New Instantiation so we don't have two different categories for the same thing.

Note: See TracTickets for help on using tickets.