# 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(`
`          extent={{-100,100},{100,-100}},`
`          lineColor={0,0,255},`
`          lineThickness=1)}),`
`    Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}),`
`        graphics={Polygon(`
`          points={{-100,60},{-60,100},{-20,80},{40,80},{100,40},{80,-40},{80,-80},`
`              {40,-100},{-20,-100},{-20,-60},{-80,-80},{-100,-20},{-100,60}},`
`          lineColor={0,0,255},`
`          fillColor={255,255,255},`
`          fillPattern=FillPattern.Solid)}),`
`    Documentation(info="<html>`
`</html>"));`
```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