## 'connect()'connect() |

This information is part of the Modelica Standard Library maintained by the Modelica Association.

Connect objects

modelIntegrate Modelica.Blocks.Sources.Step step; Modelica.Blocks.Continuous.Integrator integrator;equationconnect(step.outPort, integrator.inPort);endIntegrate;

Example of array use:

connectorInPort =inputReal;connectorOutPort =outputReal;blockMatrixGaininputInPort u[size(A,1)];outputOutPort y[size(A,2)]parameterReal A[:,:]=[1];equationy=A*u;endMatrixGain; sin sinSource[5]; MatrixGain gain(A=5*identity(5)); MatrixGain gain2(A=ones(5,2)); OutPort x[2];equationconnect(sinSource.y, gain.u); // Legalconnect(gain.y, gain2.u); // Legalconnect(gain2.y, x); // Legal

equation_clause : [initial]equation{ equation ";" | annotation ";" } equation : ( simple_expression "=" expression | conditional_equation_e | for_clause_e | connect_clause | when_clause_e | IDENT function_call ) comment connect_clause :connect"(" component_reference "," component_reference ")"

Connections between objects are introduced by the **connect**
statement in the equation part of a class. The **connect**
construct takes two references to connectors, each of which is
either of the following forms:

- c1.c2. ... .cn, where c1 is a connector of the class, n≥1 and ci+1 is a connector element of ci for i=1:(n-1).
- m.c, where m is a non-connector element in the class and c is a connector element of m.

There may optionally be array subscripts on any of the components; the array subscripts shall be parameter expressions. If the connect construct references array of connectors, the array dimensions must match, and each corresponding pair of elements from the arrays is connected as a pair of scalar connectors.

The two main tasks are to:

- Build connection sets from
**connect**statements. - Generate equations for the complete model.

Definitions:

- Connection sets

A connection set is a set of variables connected by means of connect clauses. A connection set shall contain either only flow variables or only non-flow variables. - Inside and outside connectors

In an element instance M, each connector element of M is called an outside connector with respect to M. All other connector elements that are hierarchically inside M, but not in one of the outside connectors of M, is called an inside connector with respect to M.

*[Example: in connect(a,b.c) 'a' is an outside connector and 'b.c' is an inside connector, unless 'b' is a connector.]*