Main Content

Declare Through and Across Variables for a Domain

In a domain file, you have to declare the Through and Across variables associated with the domain. These variables characterize the energy flow and usually come in pairs, one Through and one Across. Simscape™ language does not require that you have the same number of Through and Across variables in a domain definition, but it is highly recommended. For more information, see Basic Principles of Modeling Physical Networks.

variables begins an Across variables declaration block, which is terminated by an end keyword. This block contains declarations for all the Across variables associated with the domain. A domain model class definition can contain multiple Across variables, combined in a single variables block. This block is required.

Each variable is defined as a value with unit:

variables
    domain_across_var1 = {value,'unit'};
end

value is the initial value. unit is a valid unit string, defined in the unit registry. See Declare a Mechanical Rotational Domain for more information.

You can specify initialization ranges for domain Across variables, for example, to exclude negative values for pressure or temperature. The syntax is the same as for component variables:

variables
    domain_across_var1 = {value={value,'unit'},imin={value,'unit'},imax={value,'unit'}};
end

For more information, see Variable Initialization Range.

Through variables are semantically distinct in that their values have to balance at a node: for each Through variable, the sum of all its values flowing into a branch point equals the sum of all its values flowing out. Therefore, a domain file must contain a separate declaration block for its Through variables, with the Balancing attribute set to true.

variables(Balancing = true) begins a Through variables definition block, which is terminated by an end keyword. This block contains declarations for all the Through variables associated with the domain. A domain model class definition can contain multiple Through variables, combined in a single variables(Balancing = true) block. This block is required.

variables(Balancing = true)
    domain_through_var1 = {value,'unit'};
end

Related Examples

More About