Written by: Romain Gillot – Project Engineer
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:
Modelica.Electrical.Analog.Interfaces.PositivePin positive annotation (
Modelica.Electrical.Analog.Interfaces.NegativePin negative annotation (
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.
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.