Skip to content

Local balance, connect equations and over-determined connectors. #3732

@qlambert-pro

Description

@qlambert-pro

Consider the two following models.

model Balance9
  connector Pin
    Real v;
    flow Real i;
  end Pin;

  model Ground
    Pin p;
  equation
    p.v = 0;
  end Ground;

  model Nand
    Pin x1;
    Pin y;
  equation
    x1.v = y.v;
    0 = x1.i + y.i;
  end Nand;

  Ground Gnd4;
  Nand nand;
equation
  connect(Gnd4.p, nand.x1);
end Balance9;

and

model Balance12
  connector Frame
    Orientation R;
    flow Real f;
  end Frame;

  record Orientation
    Real w[2];

    function equalityConstraint
      input Orientation R1;
      input Orientation R2;
      output Real residue[1];
    algorithm
      residue := {0};
    end equalityConstraint;
  end Orientation;

  model M
    Frame f;
  equation
    Connections.root(f.R);
    f.R = Orientation(w = zeros(2));
  end M;

  model A
    Frame frame_a;
    Frame frame_b;
  equation
    Connections.branch(frame_a.R, frame_b.R);
    frame_b.R = frame_a.R;
    0 = frame_a.f + frame_b.f;
  end A;

  M m;
  A a;

equation
  connect(m.f, a.frame_a);
end Balance12;

Both models have the same structure, the difference is that one of the connectors is overdetermined.

As a result, I would expect both models to have the same number of variables at the top level.
But the number of equations generated by the connectors, at the top level is:
for Balance9

  • from Gnd4.p and nand.x1
    1 flow equation and 1 potential equation
  • from nand.y
    1 flow equation

for Balance12

  • from m.f and a.frame_a
    1 flow equation and 2 potential equations
  • from a.frame_b
    1 flow equation

Which would make Balance9 locally balanced and Balance12 locally imbalanced, although I would expect both to be balanced since they are simpler versions of models present in the MSL.

What am I missing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions