# Connectors

Connectors

## Library

Modelica/UsersGuide

## Description

The Modelica standard library defines the most important**elementary connectors** in various domains. If any possible,a user should utilize these connectors in order that componentsfrom the Modelica Standard Library and from other librariescan be combined without problems.The following elementary connectors are defined(the meaning of potential, flow, and streamvariables is explained in section "Connector Equations" below):

domain | potentialvariables | flowvariables | streamvariables | connector definition | icons |

electricalanalog | electrical potential | electrical current | Modelica.Electrical.Analog.Interfaces Pin, PositivePin, NegativePin | ||

electricalmulti-phase | vector of electrical pins | Modelica.Electrical.MultiPhase.Interfaces Plug, PositivePlug, NegativePlug | |||

electricalspace phasor | 2 electrical potentials | 2 electrical currents | Modelica.Electrical.Machines.Interfaces SpacePhasor | ||

quasistationary single phase | complex electrical potential | complex electrical current | Modelica.Electrical.QuasiStationary.SinglePhase.Interfaces Pin, PositivePin, NegativePin | ||

quasistationary multi-phase | vector of quasi stationary single phase pins | Modelica.Electrical.QuasiStationary.MultiPhase.Interfaces Plug, PositivePlug, NegativePlug | |||

electricaldigital | Integer (1..9) | Modelica.Electrical.Digital.Interfaces DigitalSignal, DigitalInput, DigitalOutput | |||

magneticflux tubes | magnetic potential | magnetic flux | Modelica.Magnetic.FluxTubes.Interfaces MagneticPort, PositiveMagneticPort, NegativeMagneticPort | ||

magneticfundamental wave | complex magnetic potential | complex magnetic flux | Modelica.Magnetic.FundamentalWave.Interfaces MagneticPort, PositiveMagneticPort, NegativeMagneticPort | ||

translational | distance | cut-force | Modelica.Mechanics.Translational.Interfaces Flange_a, Flange_b | ||

rotational | angle | cut-torque | Modelica.Mechanics.Rotational.Interfaces Flange_a, Flange_b | ||

3-dim.mechanics | position vector orientation object | cut-force vector cut-torque vector | Modelica.Mechanics.MultiBody.Interfaces Frame, Frame_a, Frame_b, Frame_resolve | ||

simplefluid flow | pressure specific enthalpy | mass flow rate enthalpy flow rate | Modelica.Thermal.FluidHeatFlow.Interfaces FlowPort, FlowPort_a, FlowPort_b | ||

thermofluid flow | pressure | mass flow rate | specific enthalpy mass fractions | Modelica.Fluid.Interfaces FluidPort, FluidPort_a, FluidPort_b | |

heattransfer | temperature | heat flow rate | Modelica.Thermal.HeatTransfer.Interfaces HeatPort, HeatPort_a, HeatPort_b | ||

blocks | Real variable Integer variable Boolean variable | Modelica.Blocks.Interfaces RealSignal, RealInput, RealOutput IntegerSignal, IntegerInput, IntegerOutput BooleanSignal, BooleanInput, BooleanOutput | |||

complexblocks | Complex variable | Modelica.ComplexBlocks.Interfaces ComplexSignal, ComplexInput, ComplexOutput | |||

statemachine | Boolean variables (occupied, set, available, reset) | Modelica.StateGraph.Interfaces Step_in, Step_out, Transition_in, Transition_out |

In all domains, usually 2 connectors are defined. The variable declarationsare **identical**, only the icons are different in order that it is easyto distinguish connectors of the same domain that are attached at the samecomponent.

#### Hierarchical Connectors

Modelica supports also hierarchical connectors, in a similar way as hierarchical models.As a result, it is, e.g., possible, to collect elementary connectors together.For example, an electrical plug consisting of two electrical pins can be defined as:

connectorPlugimportModelica.Electrical.Analog.Interfaces; Interfaces.PositivePin phase; Interfaces.NegativePin ground;endPlug;

With one connect(..) equation, either two plugs can be connected(and therefore implicitly also the phase and ground pins) or aPin connector can be directly connected to the phase or ground ofa Plug connector, such as "connect(resistor.p, plug.phase)".

#### Connector Equations

The connector variables listed above have been basically determinedwith the following strategy:

- State the relevant balance equations and boundary conditions of a volume for the particular physical domain.
- Simplify the balance equations and boundary conditions of (1) by taking the limit of an infinitesimal small volume (e.g., thermal domain: temperatures are identical and heat flow rates sum up to zero).
- Use the variables needed for the balance equations and boundary conditions of (2) in the connector and select appropriate Modelica
**prefixes**, so that these equations are generated by the Modelica connection semantics.

The Modelica connection semantics is sketched at handof an example: Three connectors c1, c2, c3 with the definition

connectorDemo Real p; // potential variableflowReal f; // flow variablestreamReal s; // stream variableendDemo;

are connected together with

connect(c1,c2);connect(c1,c3);

then this leads to the following equations:

// Potential variables are identical c1.p = c2.p; c1.p = c3.p; // The sum of the flow variables is zero 0 = c1.f + c2.f + c3.f; /* The sum of the product of flow variables and upstream stream variables is zero (this implicit set of equations is explicitly solved when generating code; the "<undefined>" parts are defined in such a way that inStream(..) is continuous). */ 0 = c1.f*(ifc1.f > 0thens_mixelsec1.s) + c2.f*(ifc2.f > 0thens_mixelsec2.s) + c3.f*(ifc3.f > 0thens_mixelsec3.s);inStream(c1.s) =ifc1.f > 0thens_mixelse<undefined>;inStream(c2.s) =ifc2.f > 0thens_mixelse<undefined>;inStream(c3.s) =ifc3.f > 0thens_mixelse<undefined>;