OpenModelica / OpenModelica

OpenModelica is an open-source Modelica-based modeling and simulation environment intended for industrial and academic usage.
https://openmodelica.org
Other
813 stars 305 forks source link

Internal error NFConnection when connecting buses #12694

Open arouhan opened 2 months ago

arouhan commented 2 months ago

Hello, I have issues with connecting 2 buses : two instances of a "high level buses" containing sub-buses, and different connections to each of these top buses lead to Interal error NFConnection. Signals to different sub-buses are sent to the each of the high level buses.

Here is the sample code to reproduce the issue :

package TestBus
  package Interfaces
    //sub bus A
    expandable connector SubBusA
    end SubBusA;
    //sub bus B
    expandable connector SubBusB
    end SubBusB;
    //main bus of the system
    expandable connector Bus
      parameter Integer no=1;
      SubBusB b;
      SubBusA a[no];
    end Bus;
    connector RI = input Real;
    connector RO = output Real;
    //set O in sub bus B
    model SetO
      SubBusB busB;
      RI u;
    equation 
      connect(busB.dataO, u);
    end SetO;
    //get O in sub bus B
    model GetO
      SubBusB busB;
      RO y;
    equation 
      connect(busB.dataO, y);
    end GetO;
    //set L in sub bus A
    model SetL
      SubBusA busA;
      RI u;
    equation 
      connect(busA.dataL, u);
    end SetL;
  end Interfaces;

  model Test
    //definition of main buses
    TestBus.Interfaces.Bus bus1;
    TestBus.Interfaces.Bus bus2;

    //adaptors to set O, L in main buses
    TestBus.Interfaces.SetO setO;
    TestBus.Interfaces.GetO getO;
    TestBus.Interfaces.SetL setL;

    //values to be set to main buses
    Real oData=1;
    Real lData=3;
  equation 
    oData = setO.u;
    lData = setL.u;
    //connect the main buses
    connect(bus1, bus2);
    //connect adaptors and main buses
    connect(setO.busB, bus1.b);
    connect(getO.busB, bus1.b);
    connect(setL.busA, bus2.a[1]);
  end Test;
end TestBus;

when checking, the output is Error Buffer:

[C:/OM123/OM64bit/OMCompiler/Compiler/NFFrontEnd/NFConnection.mo:134:7-136:109:writable] Error: Internal error NFConnection.checkBalance got unbalanced connection connect(bus1, bus2): lhs: {bus1.b.dataO} rhs: {bus2.a.dataL, bus2.b.dataO}

Tests performed under:

casella commented 2 months ago

@arouhan, @perost will take care of that in August.

casella commented 2 days ago

@perost can you please check

casella commented 2 days ago

@arouhan, @perost reports that this is unfortunately not a quick fix, he needs to rewrite the expandable connector handling from scratch to get this right. We are going to release 1.24.0 soon, we'll try to handle this in the following release

arouhan commented 2 days ago

@casella, well noted with tanks, will wait with hope for the following release of 1.24.0.