Hierarchical Connectors in Dymola

A convenient way to pass a number of variables/signals between components or subsystems in Dymola is to use hierarchical connectors.

Modelica supports hierarchical connectors (Connectors which contain sub connectors). As a result, it is possible to connect several sub connectors together with a reduced number of connection lines.

For example, an electrical plug consisting of two electrical pins (sub connectors) can be defined as:

connector Plug
  Modelica.Electrical.Analog.Interfaces.PositivePin positive annotation (
      Placement(transformation(extent={{-60,-20},{-20,20}}, rotation=0)));
  Modelica.Electrical.Analog.Interfaces.NegativePin negative annotation (
      Placement(transformation(extent={{20,-20},{60,20}}, rotation=0)));
  annotation (
    Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,
            100}}), graphics={Ellipse(
    Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}),
end Plug;

With one connect (..) equation, either two plugs can be connected (and therefore implicitly also the positive and negative pins) or a Pin connector can be directly connected to the positive or negative pin of a Plug connector, such as connect (resistor.p, plug.positive). See figure below:


Figure: Two plugs connected using a single connection line. Each plug has an electrical circuit connected to it via its pins.

Any type of signal or connector can be used in a hierarchical connector: Real input and physical connectors, etc. and there is no limit to the number of sub connectors.

However, contrarily to a Bus, a hierarchical connector is not an expandable connector. This means that we cannot connect it to a connector type that has not previously been declared in the hierarchical connector itself.

Hierarchical connectors are then a good way to reduce the number of connections in the diagram layer of a model by grouping signals together, thus making the model tidier.

Written by: Romain Gillot – Project Engineer

Please get in touch if you have any questions or have got a topic in mind that you would like us to write about. You can submit your questions / topics via: Tech Blog Questions / Topic Suggestion



Got a question? Just fill in this form and send it to us and we'll get back to you shortly.


© Copyright 2010-2024 Claytex Services Ltd All Rights Reserved

Log in with your credentials

Forgot your details?