Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing default connection equations for unconnected flow/effort connectors in expandable connectors #12159

Closed
casella opened this issue Mar 27, 2024 · 5 comments · Fixed by #12215
Assignees
Labels
COMP/OMC/Frontend Issue and pull request related to the frontend
Milestone

Comments

@casella
Copy link
Contributor

casella commented Mar 27, 2024

Description

Consider this MWE package:

package TestExpandableConnectors3
   
  expandable connector C
  end C;

  model ModelA
    C c;
    Modelica.Electrical.Analog.Basic.Ground ground1, ground2, ground3;
  equation
    connect(ground1.p, c.p1);
    connect(ground2.p, c.p2);
    connect(ground3.p, c.p3);
  end ModelA;
  
  model ModelB
    C c;
    Modelica.Electrical.Analog.Basic.Ground ground1;
  equation
    connect(ground1.p, c.p1);
  end ModelB;

  model System
    ModelA m1;
    ModelA m2;
    ModelB m3;
  equation
    connect(m1.c, m2.c);
    connect(m1.c, m3.c);
  end System;
end TestExpandableConnectors3;

Checking System gives:

Class TestExpandableConnectors3.System has 30 equation(s) and 32 variable(s).

Inspection of the flattened model reveals that connector m3.c contains all the flow variables obtained by gathering the components of the expandable connectors:

  Real m3.c.p1.i "virtual variable in expandable connector";
  Real m3.c.p2.i "virtual variable in expandable connector";
  Real m3.c.p3.i "virtual variable in expandable connector";

Unfortunately, only one equation is generated from the connect(ground1.p, c.p1); statement in ModelB

  m3.ground1.p.i - m3.c.p1.i = 0.0;

leaving m3.c.p2.i and m3.c.p3.i orphans of their matched equations.

As I understand, what are missing here are the default equations for unconnected ports in m3:

  m3.c.p2.i = 0.0;
  m3.c.p3.i = 0.0;
@casella casella added the COMP/OMC/Frontend Issue and pull request related to the frontend label Mar 27, 2024
@casella casella added this to the 1.23.0 milestone Mar 27, 2024
@casella
Copy link
Contributor Author

casella commented Mar 27, 2024

Keeping @albertoleva in the loop

@casella
Copy link
Contributor Author

casella commented Apr 8, 2024

Possibly related to discussion #12160

@perost
Copy link
Member

perost commented Apr 8, 2024

We discussed this issue during the meeting, but afterwards I realised I was still confused about why the model shouldn't be unbalanced since all the flow variables are connected as inside connectors due to the connect equations in System.

But it turns out that I'd missed one very crucial thing in the specification (9.2): flow variables added when augmenting expandable connectors should be added as connection sets both as inside and as outside. So we need to keep track of what's added during augmentation and add sets with such flow variables as outside too in addition to the usual inside ones.

@casella
Copy link
Contributor Author

casella commented Apr 8, 2024

But it turns out that I'd missed one very crucial thing in the specification (9.2): flow variables added when augmenting expandable connectors should be added as connection sets both as inside and as outside.

Yes, that is the crucial point.

So we need to keep track of what's added during augmentation and add sets with such flow variables as outside too in addition to the usual inside ones.

Yep.

If we follow my proposal in #12160, we could eventually avoid adding a lot of these variables and connection sets. Given the currently standing specification, however, we have to track them all, even though they will lead to a lot of alias equations and a lot of trivial c.f = 0 equations.

perost added a commit to perost/OpenModelica that referenced this issue Apr 9, 2024
- Generate default connect equations for unconnected outside flow
  variables that were added during augmentation of expandable
  connectors.

Fixes OpenModelica#12159
perost added a commit that referenced this issue Apr 9, 2024
- Generate default connect equations for unconnected outside flow
  variables that were added during augmentation of expandable
  connectors.

Fixes #12159
@casella
Copy link
Contributor Author

casella commented Apr 9, 2024

@albertoleva tomorrow's nightly build should work fine with expandable connectors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
COMP/OMC/Frontend Issue and pull request related to the frontend
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants