Connections between components can be established between connectors of equivalent type. The names must be identical. And corresponding types of declared variable members in the classes of the connectors must be equivalent, but the ordering between the member declarations in the connector classes need not be the same. It is important to note that connections can only be established between connectors (instances of connector classes). Instances of the restricted classes record, block, model, function and package are not allowed in connections.
In connectors there are two kinds of variables, either non-flow variables that represent som kind of potential enegy level (ex. Voltage) or flow variables, with the prefix flow, that represent some kind of flow (ex. electric current).
Connections between connectors are realized as equations in Modelica. Note that connect equations are regarded as equations despite the fact that the syntax is different from normal equations. The reason is that connect equations are eventually expanded into normal equations. The general form of a connect equation is as follows:
The two arguments of a connect equation must be references to connectors, each of which either has to be declared within the same class where the connect equation occurs, or has to be a member of one of the declared variables in that class.
Now we connect the two connectors Pin1 and Pin2 using a connect statement. The class ConnectedPins connects the two pins so that they form one node. This produces two equations, namely: pin1.v = pin2.v and pin1.i + pin2.i = 0. The first says that the voltages at the connected wire ends are the same (equality coupling). The second equation corresponds to Kirchhoff's current law saying that the currents sum to zero at a node .
Connecting two electrical pins. The connected voltages are equal, and the sum of the corrents is zero.
The filled and non-filled squares of a component represent mechanical flanges. We connect these flanges using a connect statement so that they form one node:
Which connects the two flanges so that they form one node. This produces two equations, namely: flange1.s = flange2.s and flange1.f + flange2.f = 0.
Connecting two mechanical flanges. The positions at the connection point are identical and the sum of the forces are zero.