# branches

Establish relationship between component Through variables and nodes

**Parent Section: **component

## Syntax

branches a : node1.a -> node2.a; end

## Description

`branches`

begins the branches section, which is terminated by an
`end`

keyword. This section contains one or more branch statements,
which establish the relationship between the Through variables of the component and the
domain.

For example, a domain declaration contains a Through variable
`a`

:

variables(Balancing=true) a = { 0, 'N' } end

and a component declares two nodes, `node1`

and
`node2`

, associated with this domain, and a variable
`a`

:

variables a = { 0, 'N' }; end

The name of the component variable does not have to match that of the domain variable,
but the units must be commensurate (in this example, `'N'`

,
`'kg*m/s^2'`

, `'lbf'`

, and so on).

To establish a connection between the component variable `a`

and the
domain Through (balancing) variable `a`

, write a branch statement, such
as:

branches a : node1.a -> node2.a; end

`node1.a`

and `node2.a`

identify the conserving
equations on `node1`

and `node2`

, and the component
variable `a`

is a term participating in those conserving equations. The
branch statement declares that `a`

flows from `node1`

to `node2`

. Therefore, `a`

is subtracted from the
conserving equation identified by `node1.a`

, and `a`

is added to the conserving equation identified by `node2.a`

.

A component can use each conserving equation identifier multiple times. For example, the component declares the following variables and branches:

variables a1 = { 0, 'N' } a2 = { 0, 'N' } a3 = { 0, 'N' } end branches a1 : node1.a -> node2.a; a2 : node1.a -> node2.a; a3 : node2.a -> node1.a; end

Then, assuming that `node1`

and `node2`

are not
referenced by any other `branch`

or `connect`

statements, the conserving equations at these nodes are:

For

`node1`

- a1 - a2 + a3 == 0

For

`node2`

a1 + a2 - a3 == 0

### Syntax Rules

The following rules apply:

Each conserving equation belongs to a node associated with a domain. All variables participating in that conserving equation must have commensurate units.

A node creates one conserving equation for each of the Through (balancing) variables in the associated domain. Branch statements do not create new equations. They add and subtract terms in the existing conserving equations at the nodes.

The second and third arguments do not need to be associated with the same domain. For example, one can be associated with a gas domain, and the other with a thermal domain, with the heat flow exchange defined by the branch statement.

You can replace either the second or the third argument with

`*`

to indicate the reference node. When you use`*`

, the variable indicated by the first argument is still added to or subtracted from the equation indicated by the other identifier, but no equation is affected by the`*`

.

## Examples

## Version History

**Introduced in R2013b**