Documentation

branches

Establish relationship between component Through variables and nodes

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
    

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

If a component declaration section contains two electrical nodes, p and n, and a variable i = { 0, 'A' }; specifying current, you can establish the following relationship in the branches section:

branches
   i : p.i -> n.i;
end 

This statement defines current i as a Through variable flowing from node p to node n.

For a grounding component, which has one electrical node V, define current i as a Through variable flowing from node V to the reference node:

branches
   i : V.i -> *;
end 

For a mutual inductor or transformer, with primary and secondary windings, the branches section must contain two statements, one for each winding:

branches
    i1 : p1.i -> n1.i;
    i2 : p2.i -> n2.i;
end 

For a component such as a constant volume pneumatic chamber, where you need to establish the heat flow exchange between the pneumatic and the thermal domains, the declaration section contains the two nodes and the heat flow variable:

nodes
   A = foundation.pneumatic.pneumatic; 
   H = foundation.thermal.thermal; 
end 
variables
   h = { 0 , 'J/s' };
end

and the branches section establishes the heat flow exchange between the two domains:

branches
   h : A.Q -> H.Q;
end 

This statement defines the heat flow h as a Through variable flowing from the pneumatic node A, associated with the chamber inlet, to the thermal node H, associated with the thermal mass of gas in the chamber.

Introduced in R2013b

Was this topic helpful?