Search code examples
modelicaopenmodelica

Assigning into connectors


I'm missing something elementary about Modelica connectors in that anytime a model assigns into a flange, I end up with too many equations. It seems the translator, in resolving the connections, adds equations that I don't want(/need), torpedoing the compilation.

In OMEdit 1.16 this model fails with 10 equations, 9 unknowns:

model scratch
  Modelica.Mechanics.Rotational.Interfaces.Flange_b flange;
  Modelica.Mechanics.Rotational.Components.Inertia load(J = 1.5);
equation
  flange.tau = 1;
  connect(flange, load.flange_a);
end scratch;

When instantiated, it has defined flange.tau twice:

  flange.phi = load.flange_a.phi;
  load.flange_a.tau - flange.tau = 0.0;
  flange.tau = 0.0;
  load.flange_b.tau = 0.0;
  load.phi = load.flange_a.phi;
  load.phi = load.flange_b.phi;
  load.w = der(load.phi);
  load.a = der(load.w);
  load.J * load.a = load.flange_a.tau + load.flange_b.tau;
  flange.tau = 1.0;

What am I missing or where is this discussed?

Many thanks and happy Friday.


Solution

  • Your observation is correct, connect equations are translated into normal equations.
    The defintion of flange looks like this:

    enter image description here

    In balanced physical connectors, you always have the same number of flow variables (with prefix flow, also know as "through" variables) and potential variables (without prefix, also known as "across" variables). This is discussed e.g. in this paper: https://www.modelica.org/events/modelica2008/Proceedings/sessions/session1a3.pdf

    Flow and potential variables are translated into equations, in analogy to Kirchhoff's laws:

    • the sum of flow variables (e.g. torque, or mass flow, or current) in a connection point is zero,
    • the potential variables (e.g. phi, or pressure, or voltage) are equal.

    I recommend reading this and the following chapter of Michael Tiller's book: https://mbe.modelica.university/components/connectors/